-
Notifications
You must be signed in to change notification settings - Fork 420
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
Fix Pretrained ResNet/ViT not working when features_only=True #2659
Fix Pretrained ResNet/ViT not working when features_only=True #2659
Conversation
We will probably have to bump the min version of timm we support because looks like FeatureGetterNet and FeatureListNet aren't available in the min version. Will have to search to see when they were first added |
Yes. Unfortunately, in the current min version of timm, ViT model does not support the
EDIT: it seems that |
Should we skip the tests for older versions of timm? We don't necessarily need to bump the minimum version if it's very new. |
I checked and timm 1.0.3 was released in April/May 2024, so the introduction of |
You can just skip the tests using import pytest
import timm
@pytest.mark.skipif(int(timm.__version__.split(".")[0]) < 1, reason="Requires timm 1.0.3 or higher")
def test_features_only():
... |
Or better: import pytest
def test_features_only():
pytest.importorskip('timm', minversion='1.0.3') |
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.
Just a minor request to make the tests simpler, I can do this myself if you want.
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.
Tests look much cleaner now, thanks!
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.
I think this looks good now, thanks for putting up with my tedious change requests!
Note that this PR does increase the time our unit tests take to run from 11m 34s to 12m 52s (+11%). For now that's tolerable. If we add more models in the future and this becomes too much I may only run the features_only=True
tests on the release branch.
Thanks again for the PR!
Fix the AssertionError raised when pretrained ResNet/ViT models (from timm) were created with
features_only = True
.ResNet18 and Swin models were not affected by the issue (Swin models are created with torchvision instead of timm).
Closes #2640.