Load pretrained MixVPR models
mainTo use MixVPR with pretrained weights, instantiate a VPRModel from the main module and load a state dictionary using torch.load.
Important Requirement: All input images must be resized to 320x320 pixels before being passed to the model.
Available ResNet50 backbones include output dimensions of 4096, 512, and 128. Ensure your agg_config matches the specific architecture of the weights you are loading.
from main import VPRModel
import torch
# Note that images must be resized to 320x320
model = VPRModel(backbone_arch='resnet50',
layers_to_crop=[4],
agg_arch='MixVPR',
agg_config={'in_channels' : 1024,
'in_h' : 20,
'in_w' : 20,
'out_channels' : 1024,
'mix_depth' : 4,
'mlp_ratio' : 1,
'out_rows' : 4},
)
state_dict = torch.load('./LOGS/resnet50_MixVPR_4096_channels(1024)_rows(4).ckpt')
model.load_state_dict(state_dict)
model.eval()