Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion models/backbones/build_backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def build_backbone(bb_name, pretrained=True, params_settings=''):
return bb

def load_weights(model, model_name):
save_model = torch.load(config.weights[model_name])
device = torch.device("mps" if torch.backends.mps.is_available() else "cuda" if torch.cuda.is_available() else "cpu")
save_model = torch.load(config.weights[model_name], map_location=device)
model_dict = model.state_dict()
state_dict = {k: v if v.size() == model_dict[k].size() else model_dict[k] for k, v in save_model.items() if k in model_dict.keys()}
# to ignore the weights with mismatched size when I modify the backbone itself.
Expand Down