Discrepancy in image_size in the config.json and the original repo (https://github.com/facebookresearch/dinov2)

#3
by hitchhiker3010 - opened

Thank you for the amazing work.
While I'm experimenting with DinoV2 for an image classification task I came across this, it seems to me that the image_size specified in the config.json of this model is 518 while the image size mentioned in the original repo is 224.

When I checked the pre-processor like below
trfms = AutoImageProcessor.from_pretrained("facebook/dinov2-small")
the crop_size is 224 too.

Should I rather resize the input images to 224x224 and not 518x518?
Is there any reason for the difference in the image sizes?

Hi,

I set it to 224 due to this being the sized used during evaluation as seen here: https://github.com/facebookresearch/dinov2/blob/e1277af2ba9496fbadf7aec6eba56e8d882d1e35/dinov2/data/transforms.py#L81. We usually match the image processor with the inference settings.

Feel free to change it to 518 in case you prefer that.

Thanks @nielsr for your comment. My question was more related to the resized image size rather than the crop.
https://github.com/facebookresearch/dinov2/blob/e1277af2ba9496fbadf7aec6eba56e8d882d1e35/dinov2/data/transforms.py#L79 here we see image is resized to 256.

Yes so they first resize to 256 after which they center crop. This is also done in the image processor: https://huggingface.co/facebook/dinov2-small/blob/main/preprocessor_config.json#L25

Yes so they first resize to 256 after which they center crop. This is also done in the image processor: https://huggingface.co/facebook/dinov2-small/blob/main/preprocessor_config.json#L25

Oh!! I missed that somehow. Thank you very much for your reply.

Sign up or log in to comment