IQA-PyTorch icon indicating copy to clipboard operation
IQA-PyTorch copied to clipboard

Questions about using trained models for image quality assessment

Open jau123 opened this issue 1 year ago • 4 comments

Hello, I have some questions regarding using the pre-trained models for image quality assessment from your Github repository. Specifically, I have two questions:

How can I use the pre-trained models to score images? I have two files with the suffix ".pth". Could you provide me with some guidance on how to use these files?

Is there any correlation between the training dataset and the pre-trained models? Are there any conflicts between the two? I am unsure if I can use a pre-trained model with a different training dataset.

Thank you for your time, and I look forward to your response.

jau123 avatar May 09 '23 11:05 jau123

Thanks for your interest. Here are brief answers:

  1. If you want to use your own trained .pth model, you may follow the following codes:
metric = pyiqa.create_metric('model_name')
metric.net.load_state_dict('your/model/path.pth')

For the default model used in our repo, the weights are automatically downloaded.

  1. Because there is no dominant dataset in IQA, please be careful about the dataset when you use the models. Because we keep consistent with original paper, you'd better refer to the corresponding paper to see details. In our repo, we suggest the following settings as described in README, and our retrained model would use this setting by default:
Metric Type Train Test Results
FR KADID-10k CSIQ, LIVE, TID2008, TID2013 FR benchmark results
NR KonIQ-10k LIVEC, KonIQ-10k (official split), TID2013 NR benchmark results
Aesthetic IQA AVA AVA (official split) IAA benchmark results

chaofengc avatar May 10 '23 07:05 chaofengc

请问应该如何给某一组图片进行打分😊

jau123 avatar Jun 13 '23 03:06 jau123

请参考示例代码inference_iqa.py,以及测试代码:

# example for FR metric with dirs
python inference_iqa.py -m [metric_name_in_lower_case] -i ./ResultsCalibra/dist_dir[dist_img] -r ./ResultsCalibra/ref_dir[ref_img]

# example for NR metric with single image
python inference_iqa.py -m [metric_name_in_lower_case] -i ./ResultsCalibra/dist_dir/I03.bmp

其中:

  • -m: metric name
  • -i: 输入图像或者文件夹路径
  • -r: 参考图像或者文件夹路径(注意如果有参考图像需要与对应输入图像同名)

chaofengc avatar Jun 13 '23 06:06 chaofengc

Hello, I have trained the DBCNN model on the LIVEC dataset and used the recommended Python code to load the model to a Jupyter Notebook and Python from the Linux terminal. When I try to load the trained DBCNN model state dictionary weights file, a state dictionary error is output to the screen from the Python interpreter. Can you advise how I can solve this error please?

Python Code:

metric = pyiqa.create_metric('dbcnn')

metric.net.load_state_dict('path_to_model_weights/net_best.pth')

Python Interpreter Error:

TypeError: Expected state_dict to be dict-like, got <class 'str'>.

The same error is output from the Linux terminal when the terminal is run from the IQA-Pytorch file directory. The DBCNN model is loading and the PyTorch state dictionary when the files are loaded individually to the Jupyter Notebook and the Python through the Linux terminal. The error is coming from when I am trying to combine the PyTorch state dictionary weights file with the DBCNN model in the following line of code:

metric.net.load_state_dict('path_to_model_weights/net_best.pth')

Thank you for your time, and I look forward to your response.

Stevieee83 avatar Jul 10 '23 17:07 Stevieee83