IceClear/CLIP-IQA

L1DIS metric support problem

XianchaoZhang opened this issue · 3 comments

Hi IceClear,
I just try to train CLIP-IQA+ on KonIQ-10k as your instruct:

python tools/train.py configs/clipiqa/clipiqa_coop_koniq.py

But encounter the following error, it seems only PSNR/SSIM supported.
Did this mean I have to change the config option L1DIS to PSNR/SSIM?

[                                                  ] 0/2015, elapsed: 0s, ETA:Traceback (most recent call last):
  File "tools/train.py", line 146, in <module>
    main()
  File "tools/train.py", line 135, in main
    train_model(
  File "d:\code\clip-iqa\mmedit\apis\train.py", line 106, in train_model
    _non_dist_train(
  File "d:\code\clip-iqa\mmedit\apis\train.py", line 362, in _non_dist_train
    runner.run(data_loaders, cfg.workflow, cfg.total_iters)
  File "C:\Users\A\.conda\envs\clipiqa\lib\site-packages\mmcv\runner\iter_based_runner.py", line 134, in run
    iter_runner(iter_loaders[i], **kwargs)
  File "C:\Users\A\.conda\envs\clipiqa\lib\site-packages\mmcv\runner\iter_based_runner.py", line 67, in train
    self.call_hook('after_train_iter')
  File "C:\Users\A\.conda\envs\clipiqa\lib\site-packages\mmcv\runner\base_runner.py", line 309, in call_hook
    getattr(hook, fn_name)(self)
  File "d:\code\clip-iqa\mmedit\core\evaluation\eval_hooks.py", line 42, in after_train_iter
    results = single_gpu_test(
  File "d:\code\clip-iqa\mmedit\apis\test.py", line 43, in single_gpu_test
    result = model(
  File "C:\Users\A\.conda\envs\clipiqa\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\A\.conda\envs\clipiqa\lib\site-packages\mmcv\parallel\data_parallel.py", line 50, in forward
    return super().forward(*inputs, **kwargs)
  File "C:\Users\A\.conda\envs\clipiqa\lib\site-packages\torch\nn\parallel\data_parallel.py", line 166, in forward
    return self.module(*inputs[0], **kwargs[0])
  File "C:\Users\A\.conda\envs\clipiqa\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\A\.conda\envs\clipiqa\lib\site-packages\mmcv\runner\fp16_utils.py", line 110, in new_func
    return old_func(*args, **kwargs)
  File "d:\code\clip-iqa\mmedit\models\restorers\basic_restorer.py", line 79, in forward
    return self.forward_test(lq, gt, **kwargs)
  File "d:\code\clip-iqa\mmedit\models\restorers\clipiqa.py", line 190, in forward_test
    results = dict(eval_result=self.evaluate(output, gt))
  File "d:\code\clip-iqa\mmedit\models\restorers\clipiqa.py", line 156, in evaluate
    value = self.allowed_metrics[metric](output_img, gt_img)
KeyError: 'L1DIS'

I too face this problem. Any idea how to fix this?

It seems the env is not correct. You may try reinstall the env or switch to another implementation. See #13

A simple fix that worked for me in the current version of code.
Replace this line with
allowed_metrics = {'PSNR': psnr, 'SSIM': ssim, 'L1DIS': l1dis}
and import l1dis here