Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can KID be negative number #36

Open
chandrakanth-gudavalli opened this issue Aug 27, 2022 · 4 comments
Open

Can KID be negative number #36

chandrakanth-gudavalli opened this issue Aug 27, 2022 · 4 comments

Comments

@chandrakanth-gudavalli
Copy link

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

@GaParmar
Copy link
Owner

GaParmar commented Oct 8, 2022

Can you provide some more details about the setup?

-Gaurav

@Jingyu6
Copy link

Jingyu6 commented Jan 17, 2023

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

@chenguolin
Copy link

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

@hummat
Copy link

hummat commented Nov 6, 2024

Same here. Getting negative KID scores.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants