Skip to content

Conversation

@itrushkin
Copy link
Contributor

@itrushkin itrushkin commented Oct 28, 2025

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

  • The PR title and description are clear and descriptive
  • I have manually tested the changes
  • All changes are covered by automated tests
  • All related issues are linked to this PR (if applicable)
  • Documentation has been updated (if applicable)

Warning

This PR may increase test runtime because it involves downloading large models.

@itrushkin itrushkin requested a review from a team as a code owner October 28, 2025 09:23
@github-actions github-actions bot added the TEST Any changes in tests label Oct 28, 2025
@itrushkin itrushkin changed the title Extend EfficientNet pretrained support to B2–B8 Extend EfficientNet pretrained support to B2-B8 Oct 28, 2025
@kprokofi
Copy link
Contributor

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.
Could you provide these evidence?

@itrushkin
Copy link
Contributor Author

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.

image

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))
Copy link
Member

@sovrasov sovrasov Nov 25, 2025

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])
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

TEST Any changes in tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants