tvelovraf / Pigs-segmentation-and-tracking

Solution of pigs segmentation and tracking problem by svinkotrack team within AgroCode Hack event
7 stars 0 forks source link

Can't Access colab demo code and weights drive #2

Closed sivaji123256 closed 1 year ago

sivaji123256 commented 1 year ago

Hi @tvelovraf @cassowary-bird @Hifrom , I was trying to replicate your code. But unfortunately ,I couldn't access colab version of the code and also weights link attached in the readme file. Can you share the link for pretrained weights? Also, I was trying to train on own dataset? Can you also add the steps you followed for custom training ?

tvelovraf commented 1 year ago

Hi @sivaji123256 Sorry, there is a problem with google drive where weights and colab notebook were stored. I've updated links in readme, please check.

Also some problems with dependencies occured while running in colab because of new libs versions. So I've changed 'requirements.txt' a bit to make it work in test colab notebook. Hope it will not cause new challenges with setting up local environment (but not sure) :)

About custom training steps... I'll try to recall the details and let you know if there's anything

sivaji123256 commented 1 year ago

Thanks @tvelovraf .I was able to run the demo in colab. But, I was trying to train on my own dataset. Can you try to recall the custom training steps and data preparation?

cassowary-bird commented 1 year ago

Hi @sivaji123256 Our training steps was based on two well-known repositories (as mentioned in readme):

Detection of pigs

https://github.com/WongKinYiu/ScaledYOLOv4.git

Steps: a) Label boxes with https://www.robots.ox.ac.uk/~vgg/software/via/ -> .csv with annotations for each image

b) Obtain from annotations in .csv directory with structure:

c) Create 2 files with paths to .txt files with anns of boxes:

d) Create data.yaml file like: https://github.com/WongKinYiu/ScaledYOLOv4/blob/yolov4-large/data/coco.yaml (You may left only two first lines)

e) Launch training (see readme in https://github.com/WongKinYiu/ScaledYOLOv4.git)

Maybe using of yolov7 is more reasonable today: https://github.com/WongKinYiu/yolov7

Segmenting crops from detection

https://github.com/qubvel/segmentation_models.pytorch of version 0.2.1

Steps: a) Label masks as polygons with https://www.robots.ox.ac.uk/~vgg/software/via/ -> .csv with annotations for each image b) Transforming polygons to masks files c) Next everything is similar to https://github.com/qubvel/segmentation_models.pytorch/blob/master/examples/cars%20segmentation%20(camvid).ipynb

Labeling of segmentation masks is time consuming. But You can:

  1. label small portion_1 of data
  2. training segmentation model_1
  3. inference new images throw this model_1
  4. choose images with the worst masks and put them to portion_1 (with correction of masks) --> you have portion_2
  5. repeat from 2

This strategy can also be applied to the detection.