Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use real weight and image for classification model test and relaxing precision requirement for general model tests #7130
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: main
Are you sure you want to change the base?
Use real weight and image for classification model test and relaxing precision requirement for general model tests #7130
Changes from all commits
dcdc8db
4e1cb65
edcb727
ff950d7
c32b4ae
0e9fc37
ef6e11c
e384ca0
8d33c56
a2ec9c1
d991bc4
7873c09
ad83ef6
ad99e28
5047b49
7661ab4
b6e83c1
60675be
ab81f0e
0b5bcec
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
should we just pass the weights all the time? What's the reason for having them in only some cases but not all?
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.
In some cases the weight are really restrictive, for instance if we use
vit_h_14
, it will only accept the image_size of the size of the min_size of the weight: https://github.com/pytorch/vision/blob/main/torchvision/models/vision_transformer.py#L321 and in this case we can't do the test with lower resolution with the weight.Also as of now, we dont use real weight for detection model test.
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.
But isn't that a good thing? i.e. if we go below the
min_size
limit, wouldn't we expect the model to output garbage? And if not, why is the limit not lower?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.
For test purpose, we might want to use smaller image even if the output is garbage but we can still check for the consistentcy (what we did so far with random image and random weight). And in this case if we set
weight=None
then it will basically behave like before, the get_image will assume that the test dont use real weight but rather initialized with random weight.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.
we don't need to pass parameters to the
weights.transforms()
, they will handle the size properly.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.
We need this if we want to control the size when the test happened, otherwise we will rely on the default size on the weight transforms (In some big model, we would like to use smaller image size for the test to speed up runtime).
Note: For test purpose, I think it is okay not to use the
preferred
image size that will yield the best accuracy for the model.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.
Could we just get the actual weights from the model name, using the helpers from https://pytorch.org/vision/main/models.html#model-registration-mechanism ?
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.
We can, I actually use the helper to get the actual weight in here.
I think I prefer this design where we dont need to specify the
weight_enum
for theweight_name
(since it can be retrieve from themodel_name
). Also, it is easier to say that the default value that we use isIMAGENET1K_V1
for the test.