clean-fid icon indicating copy to clipboard operation
clean-fid copied to clipboard

Can KID be negative number

Open chandrakanth-gudavalli opened this issue 1 year ago • 3 comments

I am trying to compute KID, but it is generating negative values. Can KID be a negative number?

Here is the code that I used: ` from cleanfid import fid fdir1 = my_folder1_path fdir2 = my_folder2_path

kid_score = fid.compute_kid(fdir1, fdir2) `

Each folder has only 6 images. My kid_score is -0.0406.

Could someone please help me understand why the KID is less that zero?

Thank you, Chandrakanth

chandrakanth-gudavalli avatar Aug 27 '22 22:08 chandrakanth-gudavalli

Can you provide some more details about the setup?

-Gaurav

GaParmar avatar Oct 08 '22 16:10 GaParmar

Can you provide some more details about the setup?

-Gaurav

Hi Gaurav,

I'm also encountering similar problems. In my case, I have N images for the ground truth set and 5 * N images for the synthesized set (N ranging from hundreds to thousands). I computed FID, CLIP-FID, and KID using the following APIs:

device = 'cuda' if torch.cuda.is_available() else 'cpu'
configs = {
    "fdir1": args.path_to_real_renderings, 
    "fdir2": args.path_to_synthesized_renderings, 
    "device": device
}

if "fid" in args.metrics:
    score = fid.compute_fid(**configs)
    print(f"FID score: {score}")
if "clip_fid" in args.metrics:
    score = fid.compute_fid(mode="clean", model_name="clip_vit_b_32", **configs)
    print(f"Clip FID score: {score}")
if "kid" in args.metrics:
    score = fid.compute_kid(**configs)
    print(f"KID score: {score}")

Here are some examples of FID, clip FID and KID score triplets where KIDs are negative: (8.6600, 0.3283, -0.000026705) (6.3603, 0.1913, -0.000053080) ...

Seems to me that there're some numerical error going on when the difference is small (like when FID is small to a certain degree)?

Best, Jingyu

Jingyu6 avatar Jan 17 '23 23:01 Jingyu6

I got the same problem. Any intuitive explanation? Or could we just take the absolute values? Thanks.

chenguolin avatar Aug 29 '23 06:08 chenguolin