chainer / chainercv

ChainerCV: a Library for Deep Learning in Computer Vision
MIT License
1.48k stars 304 forks source link

Impl mobilenetv2 #838

Closed okdshin closed 4 years ago

okdshin commented 5 years ago

This PR contains MobileNetV2 implementation and trained parameter converter. Trained parameters are from TensorFlow's implementation. https://github.com/tensorflow/models/tree/master/research/slim/nets/mobilenet

knorth55 commented 5 years ago

travis fails because of flake8 and test failure. flake8

$ flake8 .
./chainercv/links/__init__.py:28:1: H306  imports not in alphabetical order (chainercv.links.model.yolo.yolov3, chainercv.links.model.mobilenet.mobilenetv2)
./chainercv/links/model/mobilenet/__init__.py:2:1: H306  imports not in alphabetical order (chainercv.links.model.mobilenet.tf_convolution_2d.tfconvolution2d, chainercv.links.model.mobilenet.tf_conv_2d_bn_activ.tfconv2dbnactiv)
./chainercv/links/model/mobilenet/__init__.py:3:1: H306  imports not in alphabetical order (chainercv.links.model.mobilenet.tf_conv_2d_bn_activ.tfconv2dbnactiv, chainercv.links.model.mobilenet.expanded_conv_2d.expandedconv2d)
./chainercv/links/model/mobilenet/expanded_conv_2d.py:3:1: F401 'BatchNormalization' imported but unused
./chainercv/links/model/mobilenet/expanded_conv_2d.py:12:80: E501 line too long (100 > 79 characters)
./chainercv/links/model/mobilenet/expanded_conv_2d.py:17:80: E501 line too long (98 > 79 characters)
./chainercv/links/model/mobilenet/expanded_conv_2d.py:18:80: E501 line too long (93 > 79 characters)
./chainercv/links/model/mobilenet/expanded_conv_2d.py:19:80: E501 line too long (97 > 79 characters)
./chainercv/links/model/mobilenet/expanded_conv_2d.py:20:80: E501 line too long (104 > 79 characters)
./chainercv/links/model/mobilenet/expanded_conv_2d.py:21:80: E501 line too long (100 > 79 characters)
./chainercv/links/model/mobilenet/mobilenetv2.py:7:80: E501 line too long (99 > 79 characters)
./chainercv/links/model/mobilenet/mobilenetv2.py:12:43: H301  one import per line
./chainercv/links/model/mobilenet/mobilenetv2.py:12:80: E501 line too long (80 > 79 characters)
./chainercv/links/model/mobilenet/mobilenetv2.py:13:1: F401 'conv' imported but unused
./chainercv/links/model/mobilenet/mobilenetv2.py:16:1: H306  imports not in alphabetical order (chainercv.links.model.mobilenet.tf_convolution_2d.tfconvolution2d, chainercv.links.model.mobilenet.tf_conv_2d_bn_activ.tfconv2dbnactiv)
./chainercv/links/model/mobilenet/mobilenetv2.py:17:1: H306  imports not in alphabetical order (chainercv.links.model.mobilenet.tf_conv_2d_bn_activ.tfconv2dbnactiv, chainercv.links.model.mobilenet.expanded_conv_2d.expandedconv2d)
./chainercv/links/model/mobilenet/mobilenetv2.py:18:65: H301  one import per line
./chainercv/links/model/mobilenet/mobilenetv2.py:18:80: E501 line too long (88 > 79 characters)
./chainercv/links/model/mobilenet/mobilenetv2.py:73:80: E501 line too long (92 > 79 characters)
./chainercv/links/model/mobilenet/mobilenetv2.py:113:80: E501 line too long (82 > 79 characters)
./chainercv/links/model/mobilenet/mobilenetv2.py:118:25: E262 inline comment should start with '# '
./chainercv/links/model/mobilenet/mobilenetv2.py:118:26: H101  Use TODO(NAME)
./chainercv/links/model/mobilenet/mobilenetv2.py:119:26: H101  Use TODO(NAME)
./chainercv/links/model/mobilenet/mobilenetv2.py:120:26: H101  Use TODO(NAME)
./chainercv/links/model/mobilenet/mobilenetv2.py:204:80: E501 line too long (100 > 79 characters)
./chainercv/links/model/mobilenet/tf_conv_2d_bn_activ.py:58:80: E501 line too long (92 > 79 characters)
./chainercv/links/model/mobilenet/tf_convolution_2d.py:5:1: H306  imports not in alphabetical order (chainer.links.convolution2d, chainer.functions.pad)
./chainercv/links/model/mobilenet/tf_convolution_2d.py:47:80: E501 line too long (89 > 79 characters)
./chainercv/links/model/mobilenet/tf_convolution_2d.py:61:37: E261 at least two spaces before inline comment
./chainercv/links/model/mobilenet/tf_convolution_2d.py:62:80: E501 line too long (105 > 79 characters)
./chainercv/links/model/mobilenet/util.py:13:80: E501 line too long (80 > 79 characters)
./examples/mobilenet/tfckpt2npz.py:2:1: F401 'np' imported but unused
The command "flake8 ." exited with 1.
args = (<chainer.testing.parameterized.TestFeaturePredictor_param_71 testMethod=test_prepare>,)
kwargs = {}
e = AttributeError("'FeaturePredictor' object has no attribute 'scale'",)
s = <StringIO.StringIO instance at 0x7f8ef10a75a8>, k = 'crop_size'
v = (256, 192)
e_new = AssertionError("Parameterized test failed.\n\nBase test method: TestFeaturePre...192)\n\nAttributeError: 'FeaturePredictor' object has no attribute 'scale'\n",)
    @functools.wraps(method)
    def wrap(*args, **kwargs):
        try:
            return method(*args, **kwargs)
        except unittest.SkipTest:
            raise
        except Exception as e:
            s = six.StringIO()
            s.write('Parameterized test failed.\n\n')
            s.write('Base test method: {}.{}\n'.format(
                base.__name__, method.__name__))
            s.write('Test parameters:\n')
            for k, v in six.iteritems(param):
                s.write('  {}: {}\n'.format(k, v))
            s.write('\n')
            s.write('{}: {}\n'.format(type(e).__name__, e))
            e_new = AssertionError(s.getvalue())
            if sys.version_info < (3,):
>               six.reraise(AssertionError, e_new, sys.exc_info()[2])
yuyu2172 commented 5 years ago

pfnCI, test this please

pfn-ci-bot commented 5 years ago

Successfully created a job for commit 822e818:

okdshin commented 5 years ago

Sorry, there are no tests. I will add.

knorth55 commented 5 years ago

can you please add more tests of following code?

okdshin commented 5 years ago

I added tests.

yuyu2172 commented 4 years ago

pfnCI, test this please

pfn-ci-bot commented 4 years ago

Successfully created a job for commit 1593f3c:

okdshin commented 4 years ago

@yuyu2172 Could you run tests?

yuyu2172 commented 4 years ago

pfnCI, test this please

pfn-ci-bot commented 4 years ago

Successfully created a job for commit a06b172:

yuyu2172 commented 4 years ago

Thank you. LGTM