szha commented on a change in pull request #9614: MobileNetV2
URL: https://github.com/apache/incubator-mxnet/pull/9614#discussion_r165115099
 
 

 ##########
 File path: python/mxnet/gluon/model_zoo/vision/mobilenet.py
 ##########
 @@ -89,69 +230,111 @@ def get_mobilenet(multiplier, pretrained=False, 
ctx=cpu(),
         channel size multiplied by this multiplier.
     pretrained : bool, default False
         Whether to load the pretrained weights for model.
+    ver : int, default 1
+        Model version, 1 for MobileNet, 2 for MobileNetV2
     ctx : Context, default CPU
         The context in which to load the pretrained weights.
     root : str, default '~/.mxnet/models'
         Location for keeping the model parameters.
     """
-    net = MobileNet(multiplier, **kwargs)
+    assert ver in [1, 2], '1 for MobileNet, 2 for MobileNetV2, others are not 
supported.'
+    if ver == 1:
+        version = ''
+        net = MobileNet(multiplier, **kwargs)
+    else:
+        version = 'v2_'
+        net = MobileNetV2(multiplier, **kwargs)
+
     if pretrained:
         from ..model_store import get_model_file
         version_suffix = '{0:.2f}'.format(multiplier)
         if version_suffix in ('1.00', '0.50'):
             version_suffix = version_suffix[:-1]
-        net.load_params(get_model_file('mobilenet%s'%version_suffix, 
root=root), ctx=ctx)
+        net.load_params(
+            get_model_file('mobilenet%s%s' % (version, version_suffix), 
root=root), ctx=ctx)
     return net
 
+
 def mobilenet1_0(**kwargs):
     r"""MobileNet model from the
     `"MobileNets: Efficient Convolutional Neural Networks for Mobile Vision 
Applications"
     <https://arxiv.org/abs/1704.04861>`_ paper, with width multiplier 1.0.
 
+    MobileNetV2 model from the
+    `"Inverted Residuals and Linear Bottlenecks:
+      Mobile Networks for Classification, Detection and Segmentation"
+    <https://arxiv.org/abs/1801.04381>`_ paper.
+
     Parameters
     ----------
+    ver : int, default 1
 
 Review comment:
   version. same below

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to