Friday, January 21, 2022

Yolact

Here's a quick rundown of how I used the yolact (a well written semantic segmentation network) to train a detector and classifier for my face.

 

Labeling Data with LabelMe


Running my custom detector


LabelMe Setup (in anaconda prompt)

conda create --name=labelme python=3.6

conda activate labelme

pip install labelme

git clone https://github.com/wkentaro/labelme

pip install pycocotools

LabelMe Usage

labelme

(label your images into separate folders: train, validate, test)

(create a label.txt each folder with classes)


Convert Labels to COCO format (in anaconda prompt)

.\labelme2coco.py <path to folder with pics>\nick_train\ <output folder>\nick_train_coco --labels <path to class list>\label.txt

(repeat for each folder)

(copy output folders into yolact/data/)


Configure dataset in yolact

configure yoloact/data/config.py with your dataset according to either of these:

https://github.com/dbolya/yolact

https://www.immersivelimit.com/tutorials/train-yolact-with-a-custom-coco-dataset


Train custom network

./train.py --config=yolact_resnet50_nick_dataset_config

If you get a cpu missing error, see the post below about fixing CPU/GPU error then try again.


Run the custom network 

(webcam)

python eval.py --trained_model=./weights/yolact_plus_resnet50_nick_dataset_535_1070_interrupt.pth --config=yolact_resnet50_nick_dataset_config --score_threshold=0.15 --top_k=15 --video_multiframe=4 --video=0

(files)

python eval.py --trained_model=./weights/yolact_plus_resnet50_nick_dataset_535_1070_interrupt.pth --config=yolact_resnet50_nick_dataset_config --score_threshold=0.3 --top_k=15 --images=./data/nick_test:output_images


-----------------------------------------

References:

https://github.com/dbolya/yolact

https://github.com/wkentaro/labelme


The Papers

https://arxiv.org/pdf/1904.02689.pdf

https://arxiv.org/pdf/1912.06218.pdf


For Making Datasets

https://github.com/dbolya/yolact/issues/70#issuecomment-504283008


Tutorial for custom training

https://www.immersivelimit.com/tutorials/train-yolact-with-a-custom-coco-dataset

https://daddynkidsmakers.blogspot.com/2020/05/yolact-based-object-segmentation-with.html


Fixing training CPU/GPU error

https://github.com/dbolya/yolact/issues/664#issuecomment-878241658