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.76k stars 6.8k forks source link

Some model zoo models no longer load in master #19580

Open josephevans opened 3 years ago

josephevans commented 3 years ago

Description

When using MXNet master branch, some gluon model zoo CV models no longer load when setting pretrained=True. From discussing with @leezu, it seems naming conventions may have changed between MXNet versions.

The following CV models are no longer working in master:

All the other models tested in tests/python/unittest/test_gluon_model_zoo.py work fine (see https://github.com/apache/incubator-mxnet/blob/master/tests/python/unittest/test_gluon_model_zoo.py#L31-L39).

To Reproduce

import mxnet as mx

mx.gluon.model_zoo.vision.get_model('mobilenet1.0', pretrained=True, root=".")

Error Message

[23:48:38] ../src/storage/storage.cc:199: Using Pooled (Naive) StorageManager for CPU
Traceback (most recent call last):
  File "./issue.py", line 5, in <module>
    mx.gluon.model_zoo.vision.get_model('mobilenet1.0', pretrained=True, root=".")
  File "/home/ubuntu/mxnet/python/mxnet/gluon/model_zoo/vision/__init__.py", line 152, in get_model
    return models[name](**kwargs)
  File "/home/ubuntu/mxnet/python/mxnet/gluon/model_zoo/vision/mobilenet.py", line 260, in mobilenet1_0
    return get_mobilenet(1.0, **kwargs)
  File "/home/ubuntu/mxnet/python/mxnet/gluon/model_zoo/vision/mobilenet.py", line 212, in get_mobilenet
    get_model_file('mobilenet%s' % version_suffix, root=root), ctx=ctx)
  File "/home/ubuntu/mxnet/python/mxnet/gluon/block.py", line 431, in load_parameters
    self.load_dict(full_dict, ctx, allow_missing, ignore_extra, cast_dtype, dtype_source)
  File "/home/ubuntu/mxnet/python/mxnet/gluon/block.py", line 476, in load_dict
    name, error_str, _brief_print_list(loaded.keys()))
AssertionError: Parameter 'features.0.weight' is missing in 'file: ./mobilenet1.0-6b8c5106.params', which contains parameters: 'batchnorm7_running_var', 'batchnorm10_beta', 'batchnorm26_running_mean', ..., 'batchnorm26_beta', 'batchnorm2_beta', 'batchnorm15_gamma', 'conv25_weight'. Set allow_missing=True to ignore missing parameters.
leezu commented 3 years ago

I'm referring to the change in naming convention in b9298924043b9c8316613f5bdf9bc467cb140197

The model files saved before b9298924043b9c8316613f5bdf9bc467cb140197 are no longer supported in MXNet 2. We should remove the models created prior to b9298924043b9c8316613f5bdf9bc467cb140197 from the modelzoo or re-create them.