dinov2
dinov2 copied to clipboard
Loading local model
How to load a model locally, like in the following example
dinov2_vitb14 = torch.hub.load('facebookresearch/dinov2', 'dinov2_vitb14')
same here, I want to load dino base like https://github.com/facebookresearch/dinov2/issues/91#issuecomment-1544368423 but I get error of size mismatch.
You can load the model locally using the following methods, but I have noticed that there are some differences between this approach and loading the model from the network. I haven't yet identified the reason for these differences
from dinov2.models.vision_transformer import vit_base
dinov2_vitb14 = vit_base(patch_size=14, img_size=518)
state_dict_vitb14 = torch.load("dinov2_vitb14_pretrain.pth")
dinov2_vitb14.load_state_dict(state_dict_vitb14, strict=False)
Yes I get the same results, it's run but looks like don't load properly, if someone could help it will be great (:
@AriesChen-UPC What differences do you observe?
looks like don't load properly,
@AmitIsraeli Could you elaborate?
您观察到哪些差异?
I use torch.hub.load model and vit_large( patch_size=14, img_size=518, init_values=1.0, block_chunks=0 ) model to inference the same input tensor. then use torch.euqal() api to euqal output tensors, it show 'False'. I haven't yet identified the reason for these differences