Skip to content

Instantly share code, notes, and snippets.

@zhreshold
Last active August 20, 2018 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhreshold/30b8d3e4075c46bd738bef23c0777cb4 to your computer and use it in GitHub Desktop.
Save zhreshold/30b8d3e4075c46bd738bef23c0777cb4 to your computer and use it in GitHub Desktop.
GluonCV finetune detection models

How to finetune detection models in GluonCV

How to modify pre-trained network from VOC/COCO to custom classes

# python3 train_ssd.py --finetune ssd_300_vgg16_atrous_coco --dataset customxx
import gluoncv as gcv
# download pretrained from coco
net = gcv.model_zoo.get_model('ssd_300_vgg16_atrous_coco', pretrained=True)
# modify network to fit the new classes, say ['a', 'b', 'c']
net.reset_class(['a', 'b', 'c'])

# modify training scripts in https://github.com/dmlc/gluon-cv/tree/master/scripts/detection to load custom dataset, described in https://gluon-cv.mxnet.io/build/examples_datasets/detection_custom.html#sphx-glr-build-examples-datasets-detection-custom-py

# if dataset == customxx: load dataset, init dataloader
# and we are good to start fine-tuning

# similarly for Faster-RCNN and YOLO3
net = gcv.model_zoo.get_model('faster_rcnn_resnet50_v1b_coco', pretrained=True)
net.reset_class(['d', 'e'])
net = gcv.model_zoo.get_model('yolo3_darknet53_coco', pretrained=True)
net.reset_class(['f'])

A tiny pikachu dataset for tutorial purposes

val.rec : https://apache-mxnet.s3-accelerate.amazonaws.com/gluon/dataset/pikachu/val.rec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment