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

Fix pretrained weight for ResNet #533

Merged
merged 10 commits into from
Mar 23, 2018

Conversation

yuyu2172
Copy link
Member

@yuyu2172 yuyu2172 commented Mar 7, 2018

Some names of parameters are not updated during the code review. I am sorry about that.

@yuyu2172 yuyu2172 added the bug label Mar 7, 2018
@yuyu2172 yuyu2172 added this to the v0.9 milestone Mar 7, 2018
@yuyu2172
Copy link
Member Author

yuyu2172 commented Mar 7, 2018

I am checking if eval_imagenet.py produces the same score as before.

Edit:
Hmm... Scores differ between Python versions (ResNet50).

Python2:
Top 1 Error 0.248300015926

Python3:
Top 1 Error 0.25133997201919556

Edit:
The version of Python was not important, but the image library backend was.
By using OpenCV backend, the same scores are achieved.

@yuyu2172
Copy link
Member Author

yuyu2172 commented Mar 7, 2018

@Hakuyume
Please review this.

@Hakuyume
Copy link
Member

Hakuyume commented Mar 7, 2018

If the backend affects the performance, how about raising a warning?
In SSD, which is also affected by the backend, it raises a warning when users try to use the pretrained model without OpenCV.
https://github.com/chainer/chainercv/blob/master/chainercv/links/model/ssd/ssd_vgg16.py#L240-L245

@yuyu2172
Copy link
Member Author

yuyu2172 commented Mar 7, 2018

Thanks for your suggestion.

@Hakuyume
Copy link
Member

Hakuyume commented Mar 7, 2018

It is better to raise a warning from ResNet class and not from sample script. (please refer the example of SSD).

@yuyu2172
Copy link
Member Author

OK

@yuyu2172
Copy link
Member Author

@Hakuyume

if not _available:
warnings.warn('cv2 is not installed on your environment. '
'The scores of ResNets reported in the '
'ChainerCV\'s Github page are calculated using '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github -> GitHub.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github page sounds that we have ***.github.io page.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change the warning message from that of SSD? It is better to use the same message because they say the same thing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because Pretrained models are trained with cv2. is not accurate.
In the case of ResNet, we do not know which backend was used during training.
All we are saying is that during evaluation the scores change with different backends.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I understand the difference.

@@ -42,13 +42,13 @@ def main():
extractor = VGG16(n_class, args.pretrained_model)
elif args.model == 'resnet50':
extractor = ResNet50(
n_class, args.pretrained_model, mode=args.resnet_mode)
n_class, args.pretrained_model, arch=args.resnet_mode)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resnet_mode -> resnet_arch

@@ -201,8 +201,9 @@ def __init__(self, n_layer,
if not _available:
warnings.warn('cv2 is not installed on your environment. '
'The scores of ResNets reported in the '
'ChainerCV\'s Github page are calculated using '
'OpenCV as the backend. With Pillow as the '
'READMEs in ChainerCV\'s examples are '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scores are reported only in https://github.com/chainer/chainercv/tree/master/examples/classification. So READMEs -> README? Will you add the scores to another README?

Copy link
Member

@Hakuyume Hakuyume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Hakuyume Hakuyume merged commit 49acfb2 into chainer:master Mar 23, 2018
@yuyu2172 yuyu2172 deleted the fix-pretrained-resnet branch April 17, 2018 14:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants