Anyone try mobilenet_ssd_300?


#1

i know that current gluon doesn’t support mobilenet_ssd_300x300, so i tried to build it by myself. I successfully did it with mxnet-ssd by add those line in symbol/symbol_factory.py

elif network == ‘mobilenet’:
if data_shape >= 448:
from_layers = [‘conv_12_relu’, ‘conv_14_relu’, ‘’, ‘’, ‘’, ‘’, ‘’]
num_filters = [-1, -1, 512, 256, 256, 256, 256]
strides = [-1, -1, 2, 2, 2, 2, 2]
pads = [-1, -1, 1, 1, 1, 1, 1]
sizes = get_scales(min_scale=0.15, max_scale=0.9, num_layers=len(from_layers))
ratios = [[1,2,.5], [1,2,.5,3,1./3], [1,2,.5,3,1./3], [1,2,.5,3,1./3],
[1,2,.5,3,1./3], [1,2,.5], [1,2,.5]]
normalizations = -1
steps =
else: #for input 300x300
from_layers = [‘conv_12_relu’, ‘conv_14_relu’, ‘’, ‘’, ‘’, ‘’]
num_filters = [512, 1024, 512, 256, 256, 128]
strides = [1, 1, 2, 2, 2, 2]
pads = [0, 0, 1, 1, 1, 1]
sizes = [[0.2],[0.35, 0.41833],[0.5, 0.570088],[0.65, 0.72111],[0.8, 0.87178],[0.95, 0.974679]]
ratios = [[1,2,.5], [1,2,.5,3,1./3], [1,2,.5,3,1./3], [1,2,.5,3,1./3], [1,2,.5,3,1./3], [1,2,.5,3,1./3]]
normalizations = -1
steps=
#steps = [[-1./300,-1./300],[-1./300,-1./300],[-1./300,-1./300],[-1./300,-1./300],[-1./300,-1./300],[-1./300,-1./300]]
return locals()

for now i don’t know how to config those params exactly in gluon. I tried to add those lines in gluoncv/model_zoo/ssd/ssd.py:

def ssd_300_mobilenet1_0_voc(pretrained=False, pretrained_base=True, **kwargs):
“”"SSD architecture with mobilenet1.0 base networks.

Parameters
----------
pretrained : bool or str
    Boolean value controls whether to load the default pretrained weights for model.
    String value represents the hashtag for a certain version of pretrained weights.
pretrained_base : bool or str, optional, default is True
    Load pretrained base network, the extra layers are randomized.

Returns
-------
HybridBlock
    A SSD detection network.
"""
classes = VOCDetection.CLASSES
return get_ssd('mobilenet1.0', 300,
               features=['relu22_fwd', 'relu26_fwd'],
               filters=[512, 512, 256, 256],
               sizes=[51.2, 102.4, 189.4, 276.4, 363.52, 450.6, 492],
               ratios=[[1, 2, 0.5]] + [[1, 2, 0.5, 3, 1.0/3]] * 5,
               steps=[16, 32, 64, 128, 256, 512],
               classes=classes, dataset='voc', pretrained=pretrained,
               pretrained_base=pretrained_base, **kwargs)

but it was slow to converge, after 7 epoch i got only 4.5% mAP.
Plz let me know how to config this network in gluoncv