apache / mxnet

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more
https://mxnet.apache.org
Apache License 2.0
20.77k stars 6.79k forks source link

Official version of MobileNet pretrained model and .json file #9392

Closed chowkamlee81 closed 6 years ago

chowkamlee81 commented 6 years ago

Recently i found MobileNet gluon version of model.param.

I would like to have symbolic version of mobileNet in model.param and also .json format file. Is anything are avilable in modelzoo with json and mobilenet.param file. Kindly reply... @szha do you any updates on this....

szha commented 6 years ago

Gluon model zoo has it in master branch now, which you can use to generate the json and param

mx.gluon.model_zoo.vision.mobilenet1_0(pretrained=True).export('mobilenet1_0')
chowkamlee81 commented 6 years ago

Hi szha, model has been downloaded . But while exporting to .json and .param files throws an error ""Please first call block.hybridize() and then run forward with " "this block at least once before calling export."

Kindly help to resolve the issue as it thrown an exception in mxnet/gluon/block.py below code

def export(self, path, epoch=0):
    """Export HybridBlock to json format that can be loaded by `mxnet.mod.Module`
    or the C++ interface.

    .. note:: When there are only one input, it will have name `data`. When there
              Are more than one inputs, they will be named as `data0`, `data1`, etc.

    Parameters
    ----------
    path : str
        Path to save model. Two files `path-symbol.json` and `path-xxxx.params`
        will be created, where xxxx is the 4 digits epoch number.
    epoch : int
        Epoch number of saved model.
    """
    if not self._cached_graph:
        raise RuntimeError(
            "Please first call block.hybridize() and then run forward with "
            "this block at least once before calling export.")
chowkamlee81 commented 6 years ago

@szha , model has been downloaded . But while exporting to .json and .param files throws an error ""Please first call block.hybridize() and then run forward with " "this block at least once before calling export."

Kindly help to resolve the issue as it thrown an exception in mxnet/gluon/block.py below code

def export(self, path, epoch=0): """Export HybridBlock to json format that can be loaded by mxnet.mod.Module or the C++ interface.

.. note:: When there are only one input, it will have name `data`. When there
          Are more than one inputs, they will be named as `data0`, `data1`, etc.

Parameters
----------
path : str
    Path to save model. Two files `path-symbol.json` and `path-xxxx.params`
    will be created, where xxxx is the 4 digits epoch number.
epoch : int
    Epoch number of saved model.
"""
if not self._cached_graph:
    raise RuntimeError(
        "Please first call block.hybridize() and then run forward with "
        "this block at least once before calling export.")
szha commented 6 years ago

Sorry, my bad.

net = mx.gluon.model_zoo.vision.mobilenet1_0(pretrained=True)
net.hybridize()
net(mx.nd.ones((1,3,224,224)))
net.export('mobilenet1_0')
chowkamlee81 commented 6 years ago

Got the one. Thanks its working... Closing the issue...