Minimal PyTorch implementation of Yolact:《YOLACT: Real-time Instance Segmentation》.
The original project is here.
This implementation simplified the original code, preserved the main function and made the network easy to understand.
Following instruction is based on resnet-101.
PyTorch 1.1.
Python 3.6 or above.
Other common packages.
- Firstly, modify the paths of training and val datasets in
data/config.py
in line 72-77. - If some directories are missed, just create them by yourself.
- Download the pretrained weights.
ImageNet pretrained weights
Yolact pretrained weights
# Trains using the base config with a batch size of 8 (the default).
python train.py --config=yolact_base_config
# Resume training (just pass the .pth file to the model by using --resume).
python train.py --config=yolact_base_config --resume weights/yolact_base_2_35000.pth
# Using --batch_size, --lr, --momentum, --decay to set the batch size, learning rate, momentum and weight decay.
python train.py --config=yolact_base_config --batch_size=4
# Evaluate on COCO val2017.
python eval.py --trained_model=weights/yolact_base_54_800000.pth
# Create a json file and then use the COCO API to evaluate the result.
python eval.py --config=yolact_base_config --cocoapi
# Then,
python coco_eval.py
# Benchmark
python eval.py --trained_model=weights/yolact_base_54_800000.pth --benchmark --max_images=1000
# Detect images, pass the path of your image directory to --image.
python detect.py --trained_model=weights/yolact_base_54_800000.pth --image images
# Detect a video, pass the path of your video to --video.
python detect.py --trained_model=weights/yolact_base_54_800000.pth --video video/1.mp4
# Use --hide_mask, --hide_score, --show_lincomb and so on to get different results.
python detect.py --trained_model=weights/yolact_base_54_800000.pth --image images --hide_mask