GaParmar / clean-fid

PyTorch - FID calculation with proper image resizing and quantization steps [CVPR 2022]
https://www.cs.cmu.edu/~clean-fid/
MIT License
903 stars 69 forks source link

Feature request for centercrop #12

Closed hadaev8 closed 2 years ago

hadaev8 commented 2 years ago

My dataset has nonsquare samples, so on training, I'm doing random crop and for validation, I'm calculating fid with center cropped copy of dataset. Would be cool to have some option for passing my own transform, for example.

GaParmar commented 2 years ago

Thank you for pointing out this use case, I will add this flag in the next version of the library.

GaParmar commented 2 years ago

this feature is available in the current clean-fid version 0.1.17 Any transforms can be passed in through the flag custom_image_tranform You can pass in a function that takes an image as an numpy array as input and returns the transformed image. For instance, the function below can be used to apply a crop to the images when computing the FID score.

    def fn_crop(x):
        return x[60:-60, 60:-60, :]

This option is only applied when the FID is computed between two folders.

GaParmar commented 2 years ago

Feel free to re-open this issue if you run into any issues with this.