Skip to content

Classifier inference #4

@Eurususu

Description

@Eurususu

Hi!
It is very exciting work!

But there are same issues happen:

I want to test the performance of classification of events. So I use MatchVision_Classifier and then load the classifier checkpoint,modify the names of key. But in the end the output shape is not correct.

from model.MatchVision_classifier import MatchVision_Classifier
import torch

classifier = MatchVision_Classifier()
checkpoint = torch.load("weights/pretrained_classification.pth",map_location='cpu')
new_static_dict = {key.replace("module.", ""): value for key, value in checkpoint['state_dict'].items()}
classifier.load_state_dict(new_static_dict,strict=False)

run error as shown:

RuntimeError: Error(s) in loading state_dict for MatchVision_Classifier:
	size mismatch for classifier.weight: copying a param with shape torch.Size([23, 768]) from checkpoint, the shape in current model is torch.Size([24, 768]).
	size mismatch for classifier.bias: copying a param with shape torch.Size([23]) from checkpoint, the shape in current model is torch.Size([24]).

how to infer the classifier model?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions