Two instances of SSD on the same script


I have trained SSD512 and SSD300 using the sample script from tutorial with minimal modifications.
The problema is that I want to load both networks on the same script so I can run some comparisons.
When try to load the second network (does not matter which one I load first) I get the following error:

AssertionError: Parameter ‘ssd1_convpredictor0_conv0_weight’ is missing in file ‘…/checkpoints_ssd/_best.params’, which contains parameters: ‘ssd1_resnetv10_conv0_weight’, ‘ssd1_resnetv10_batchnorm0_gamma’, ‘ssd1_resnetv10_batchnorm0_beta’, …, ‘ssd1_ssdanchorgenerator2_anchor_2’, ‘ssd1_ssdanchorgenerator3_anchor_3’, ‘ssd1_ssdanchorgenerator4_anchor_4’, ‘ssd1_ssdanchorgenerator5_anchor_5’. Please make sure source and target networks have the same prefix.

This is the important part of the code where a load the networks:

ssd = model_zoo.get_model('ssd_512_resnet50_v1_coco', ctx=ctx)
ssd.initialize(force_reinit=True, ctx=ctx)
ssd.load_parameters('../checkpoints_ssd/_best.params', ctx=ctx)

ssd300 = model_zoo.get_model('ssd_300_vgg16_atrous_coco', pretrained=True)
ssd300.initialize(force_reinit=True, ctx=ctx)
ssd300.load_parameters('../checkpoints_ssd300/_best.params', ctx=ctx)

Is there a way to fix this prefix problem?

I tried to reproduce the problem by saving these two models first and the loading them back again - it seems working fine.

Nevertheless, you can always specify the prefix for the model by adding adding argument to get_model() function. For example:

ssd = model_zoo.get_model('ssd_512_resnet50_v1_coco', ctx=ctx, prefix='my_model_prefix_')

I am not entirely sure it will help though.

Another way is to experiment with load_params() function. It is deprecated, but maybe it will work for your case.