Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Commit

Permalink
fix mobilenet mean and measure top 1 error
Browse files Browse the repository at this point in the history
  • Loading branch information
okdshin committed Dec 6, 2019
1 parent 85ee099 commit 012cbc8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 4 additions & 5 deletions chainercv/links/model/mobilenet/mobilenet_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _depth_multiplied_output_channels(base_out_channels,
min_depth)


_zero_mean = np.asarray([0] * 3, dtype=np.float)[:, np.newaxis, np.newaxis]
_mean = np.asarray([128] * 3, dtype=np.float)[:, np.newaxis, np.newaxis]
_tf_mobilenetv2_scale = np.asarray(
[1 / 128.0] * 3, dtype=np.float)[:, np.newaxis, np.newaxis]

Expand Down Expand Up @@ -96,8 +96,7 @@ class MobileNetV2(PickableSequentialChain):
the default values are used.
If a supported pretrained model is used,
the mean value used to train the pretrained model is used.
Otherwise, the mean value calculated from ILSVRC 2012 dataset
is used.
Otherwise, the mean value used by TF's implementation is used.
initialW (callable): Initializer for the weights.
initial_bias (callable): Initializer for the biases.
Expand All @@ -115,7 +114,7 @@ class MobileNetV2(PickableSequentialChain):
'param': {
'n_class':
1001, # first element is background
'mean': _zero_mean,
'mean': _mean,
'scale': _tf_mobilenetv2_scale,
},
'overwritable': None,
Expand Down Expand Up @@ -144,7 +143,7 @@ def __init__(self,
'scale': scale
}, pretrained_model, self._models[arch], {
'n_class': 1001,
'mean': _zero_mean,
'mean': _mean,
'scale': _tf_mobilenetv2_scale
})
self.mean = param['mean']
Expand Down
5 changes: 4 additions & 1 deletion examples/classification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Single crop error rates of the models with the weights converted from Caffe weig

| Model | Top 1 | Original Top 1 |
|:-:|:-:|:-:|
| MobileNetV2 | 29.9 % | 28.0 % [6] |
| VGG16 | 29.0 % | 28.5 % [1] |
| ResNet50 (`arch=he`) | 24.8 % | 24.7 % [2] |
| ResNet101 (`arch=he`) | 23.6 % | 23.6 % [2] |
Expand All @@ -22,6 +23,7 @@ Ten crop error rate.

| Model | Top 1 | Original Top 1 |
|:-:|:-:|:-:|
| MobileNetV2 | 27.4 % | |
| VGG16 | 27.1 % | |
| ResNet50 (`arch=he`) | 23.0 % | 22.9 % [2] |
| ResNet101 (`arch=he`) | 21.8 % | 21.8 % [2] |
Expand All @@ -37,7 +39,7 @@ The results can be reproduced by the following command.
These scores are obtained using OpenCV backend. If Pillow is used, scores would differ.

```
$ python eval_imagenet.py <path_to_val_dataset> [--model vgg16|resnet50|resnet101|resnet152|se-resnet50|se-resnet101|se-resnet152] [--pretrained-model <model_path>] [--batchsize <batchsize>] [--gpu <gpu>] [--crop center|10]
$ python eval_imagenet.py <path_to_val_dataset> [--model mobilenetv2|vgg16|resnet50|resnet101|resnet152|se-resnet50|se-resnet101|se-resnet152] [--pretrained-model <model_path>] [--batchsize <batchsize>] [--gpu <gpu>] [--crop center|10]
```

### Trained model
Expand Down Expand Up @@ -104,3 +106,4 @@ The ImageNet Large Scale Visual Recognition Challenge (ILSVRC) dataset has 1000
3. Jie Hu, Li Shen, Gang Sun. "Squeeze-and-Excitation Networks" CVPR 2018
4. https://github.com/hujie-frank/SENet
5. Priya Goyal, Piotr Dollár, Ross Girshick, Pieter Noordhuis, Lukasz Wesolowski, Aapo Kyrola, Andrew Tulloch, Yangqing Jia, Kaiming He. "Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour" https://arxiv.org/abs/1706.02677
6. Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, Liang-Chieh Chen. "MobileNetV2: Inverted Residuals and Linear Bottlenecks" https://arxiv.org/abs/1801.04381

0 comments on commit 012cbc8

Please sign in to comment.