Examples of transfer learning from Gluon CV Image Segmentation


does anyone have any good examples of transfer learning with the gluon-cv model zoo? In the examples page, they only seem to have how to train/test the models…


This example is transfer learning where the pretrained network is finetuned on a different dataset:

1 Like

Thanks for your reply.

After reading over this a few times, I think this tutorial shows how to build up an FCN from a specific backbone (e.g., ResNet50), and then train it on the Pascal dataset. This is the gist of the tutorial.

model = gluoncv.model_zoo.get_fcn(dataset=‘pascal_voc’, backbone=‘resnet50’, pretrained=False)

Unfortunately, they don’t use it pretrained, and then move to use a different dataset, they simply move back to training it on the Pascal dataset.

In any case, the tutorial was informative.

I may have found a partial solution. To transfer learn on a segmentation model with a pretrained backbone, call the model directly, where one can specify the number of classes, namely (using DeepLabV3 as an example):

model = gluoncv.model_zoo.DeepLabV3(nclass=1,backbone=‘resnet101’,
pretrained_base=True, ctx=ctx)

So here the backbone is resnet101 pretrained. We call the model directly, instead of using ‘get_model()’ due to this discussion here, as we can directly state the number of classes we want.

Unfortunately, we cannot take advantage of the pretrained decoder section of the network if it was subsequently trained on say the COCO dataset.

From here you can train the model as usual. Although, I find there is trouble hybridizing the network for efficiency, so maybe leave that out if your training is resulting in a lot of errors.

One final thing, you may get a user warning about the Gradient of Parameter. Simply set

optimizer.step(batchsize, ignore_stale_grad=True)

where optimizer is an instantiation of your Trainer object.

1 Like

I think it uses transfer learning from trained weights of pascal_voc. the pretrained=False is for imagenet weights. This line of code shows using weights from pascal voc not imagenet. If you set the pretrained=True, it will use imagenet weights. But I don’t know if you set it to be True and use pascal_voc, which one would be used.
I’m browsing for a tutorial on fine tuning maskrcnn on custom dataset. Do you found any related thing?