YangiD / DefenseIQA-NT

Official code for "Defense Against Adversarial Attacks on No-Reference Image Quality Models with Gradient Norm Regularization"
MIT License
14 stars 1 forks source link

Inference with custom image #1

Closed vijay-jaisankar closed 6 months ago

vijay-jaisankar commented 6 months ago

Hello,

Thank you for open-sourcing your work! While trying to run the model on a custom image, I'm facing an issue, can you please help out with the same?

In particular, the demo (to get the IQA scores) is working on the 123.bmp image, but not on a custom image. Presumably this is because the cropped patches are present for 123.bmp and not for our custom image. Can you please point out the code to save these cropped patches into the corresponding folder for the custom image?

Reproducibility: https://colab.research.google.com/drive/16EL2vuKyIDXjYOCtqxnLCKSKHzGtwN7C?usp=sharing

Thanks!

YangiD commented 6 months ago

Thanks for the advice! We now add a regenerate_crops option for custom images in quality_and_norm_demo.py
You can now use it with "python quality_and_norm_demo.py --regenerate_crops --img car.jpeg" for testing your image.

YogaLYJ commented 6 months ago

Thank you for following up on our work. This reply is a supplement to YangiD's reply. The code for cropping and saving images can be found on lines 33-47. For evaluating the quality of your own custom image, please first crop it into _patchnum patches, each measuring 224x224 pixels. Subsequently, save these cropped patches in the directory _./imagesfixedcrop.

We have successfully tested the code with your custom image and the result is as follows.

For car.png, the L_1 norm of output's gradint in term of the input image: HyperIQA:4080.3151 HyperIQA+NT:747.7407 For car.png, the predicted score of the image: HyperIQA:65.0545 HyperIQA+NT:60.2501

If you have any other questions, please feel free to contact us.

vijay-jaisankar commented 6 months ago

Hello, thanks a lot for the prompt fix! Yes, I am now able to use this new config option for custom images. Thanks again for open-sourcing your amazing work.