-
Notifications
You must be signed in to change notification settings - Fork 459
Extend EfficientNet pretrained support to B2-B8 #4963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Extend EfficientNet pretrained support to B2-B8 #4963
Conversation
|
Since we used base models, we need to be sure that "c" variants are backward compatible and the performance of the b0 backbone remains same or better. |
|
Hi @kprokofi, To confirm backward compatibility: all existing unit tests continue to pass, and model calls with dummy inputs execute successfully, indicating that the integration of the "c" variants doesn’t break existing functionality. The performance improvements for the "c" variants come from the AdvProp paper. I haven't independently benchmarked the b0 backbone myself, but the original authors state that these models match or exceed the baseline performance. |
| if pretrained: | ||
| cache_dir = Path.home() / ".cache" / "torch" / "hub" / "checkpoints" | ||
| download_model(net=model, model_name=f"{model_name}", local_model_store_dir_path=str(cache_dir)) | ||
| download_model(net=model, model_name=f"{model_name}c", local_model_store_dir_path=str(cache_dir)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Ilya for the contribution. I think here we can not just replace this weights without a set of comprehensive experiments. 100% positive correlation with IN-top1 is not given, there could be sudden outlier which we'd like to avoid.
To tackle that, I'd propose moving this version parameter to init of EfficientNetBackbone and forwarding it from the endpoint classes (EfficientNetMulticlassCls etc). Once done, the model version is configurable from model recipe yaml file. Corner case of b0 and b1 should be handled.
| ) | ||
| def test_forward(self, model_name): | ||
| model = EfficientNetBackbone(model_name, pretrained=None) | ||
| @pytest.mark.parametrize("pretrained", [True, False]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, don't download anything here to avoid increase of UTs duration and reliability. You could mock download_model if the idea is to check that the URL is correct somehow.

Summary
Adds support for downloading and using pretrained EfficientNet weights for models larger than B1 (B2-B8).
In pytorchcv, the “c” denotes the community re-trained EfficientNet variants (ported via https://www.github.com/rwightman/timm) that use PyTorch-native ops and shapes, distinct from the original TF-trained baselines.
Checklist
Warning
This PR may increase test runtime because it involves downloading large models.