Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Troubles with load_weights #181

Open
egoravv opened this issue Aug 27, 2024 · 1 comment
Open

Troubles with load_weights #181

egoravv opened this issue Aug 27, 2024 · 1 comment

Comments

@egoravv
Copy link

egoravv commented Aug 27, 2024

I try to train TOPIQ by your functionality on slightly updated Koniq10k (i added some distortions and recalculate labels):

  • yml was updated with new paths to dataset
  • train was completed, net_best.pth weights 180~Mb

After all i try to test my model:
iqa_metric = pyiqa.create_metric('topiq_nr', device=device) iqa_metric.load_weights('path/to/net_best.pth', weight_keys='params') ... score = iqa_metric(image_tensor)

But i get Error: 'NoneType' object is not callable
When i try to print my iqa_metric, this returns: InferenceModel((net): None)

What i do wrong?

@chaofengc
Copy link
Owner

Sorry that there is a bug in the load_weights function. I have fixed it in the latest commit. You may also manually load the weight with the following example, instead of using the load_weights function:

iqa_metric.net.load_state_dict(torch.load(path/to/weight)['params'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants