facebookresearch / dinov2

PyTorch code and models for the DINOv2 self-supervised learning method.
Apache License 2.0
9.28k stars 829 forks source link

Issuess of unexpected keyword argument 'antialias' when using the DINOv2 backbone for finetuing #425

Open hubery1619 opened 5 months ago

hubery1619 commented 5 months ago

features = self.dino_block.forward_features(x.to("cuda"))['x_norm_patchtokens'] File "/root/.cache/torch/hub/facebookresearch_dinov2_main/dinov2/models/vision_transformer.py", line 258, in forward_features x = self.prepare_tokens_with_masks(x, masks) File "/root/.cache/torch/hub/facebookresearch_dinov2_main/dinov2/models/vision_transformer.py", line 220, in prepare_tokens_with_masks x = x + self.interpolate_pos_encoding(x, w, h) File "/root/.cache/torch/hub/facebookresearch_dinov2_main/dinov2/models/vision_transformer.py", line 203, in interpolate_pos_encoding patch_pos_embed = nn.functional.interpolate( TypeError: interpolate() got an unexpected keyword argument 'antialias'

The torch version is: 1.10.2+cu113

heyoeyo commented 5 months ago

The antialias option seems like it was first added on torch version 1.11, so you'd need to upgrade your version to get rid of the error (or otherwise just comment out/remove the line that's giving the error).

That being said, the project requirements list torch version 2.0.0, so even with changing the interpolation function you may still run into problems (in which case upgrading pytorch should hopefully fix things).