Lornatang / Real_ESRGAN-PyTorch

PyTorch implements `Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data` paper.
Apache License 2.0
34 stars 5 forks source link

FileNotFoundError: No such file or directory: 'results/pretrained_models/niqe_model.mat' #2

Closed ghost closed 2 years ago

ghost commented 2 years ago

Hi Lorna,

It seems like the niqe_model can not be initialized for the first time without a default niqe_model.mat.

Traceback (most recent call last):
  File "/home/khoa/dev/Real-ESRGAN/train_realesrnet.py", line 475, in validate
    niqe = niqe_model(sr)
  ...
FileNotFoundError: [Errno 2] No such file or directory: 'results/pretrained_models/niqe_model.mat'

I have tried to add a default niqe_model.mat myself before training, then the issue seems to have been solved.

Best regards, Dante

Lornatang commented 2 years ago

Which command does this appear when executing?

ghost commented 2 years ago

Hi Lorna,

It's line 94 in train_realesrnet.py, for example. When initializing the NIQE model, it needs to be passed niqe_model_path.

# Create an IQA evaluation model
    niqe_model = NIQE(config.upscale_factor, config.niqe_model_path)

In the config file, the niqe_mode_path has been set as "results/pretrained_models/niqe_model.mat". In the original repo, this niqe_model.mat file does not exist, and then, throw the exception.

Traceback (most recent call last):
  File "/home/khoa/dev/ASRGAN/train_asrnet.py", line 508, in <module>
    main()
  File "/home/khoa/dev/ASRGAN/train_asrnet.py", line 109, in main
    _ = validate(
  File "/home/khoa/dev/ASRGAN/train_asrnet.py", line 475, in validate
    niqe = niqe_model(sr)
  File "/home/khoa/anaconda3/envs/asrgan/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/khoa/dev/ASRGAN/utils/image_metrics.py", line 1569, in forward
    niqe_metrics = _niqe_torch(
  File "/home/khoa/dev/ASRGAN/utils/image_metrics.py", line 1516, in _niqe_torch
    niqe_model = scipy.io.loadmat(niqe_model_path)
  File "/home/khoa/anaconda3/envs/asrgan/lib/python3.10/site-packages/scipy/io/matlab/_mio.py", line 224, in loadmat
    with _open_file_context(file_name, appendmat) as f:
  File "/home/khoa/anaconda3/envs/asrgan/lib/python3.10/contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "/home/khoa/anaconda3/envs/asrgan/lib/python3.10/site-packages/scipy/io/matlab/_mio.py", line 17, in _open_file_context
    f, opened = _open_file(file_like, appendmat, mode)
  File "/home/khoa/anaconda3/envs/asrgan/lib/python3.10/site-packages/scipy/io/matlab/_mio.py", line 45, in _open_file
    return open(file_like, mode), True
FileNotFoundError: [Errno 2] No such file or directory: 'results/pretrained_models/niqe_model.mat'
Lornatang commented 2 years ago

I don't seem to have encountered this error before, can you submit a pull request