openai / improved-diffusion

Release for Improved Denoising Diffusion Probabilistic Models

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About FID fraction calculation

ILLLLUSION opened this issue · comments

For the npz file generated after sampling, how to calculate the FID score of the npz file and the cifar10 data set used ? Cifar is a picture in PNG format, and the npz file is an array with only arr _ 0 list. How should I do FID calculation

For the npz file generated after sampling, how to calculate the FID score of the npz file and the cifar10 data set used ? Cifar is a picture in PNG format, and the npz file is an array with only arr _ 0 list. How should I do FID calculation

Have you solved this problem yet?

you can read in npz file as numpy array and save it as png. This way you have both sets in the same format and can calculate FID

For the npz file generated after sampling, how to calculate the FID score of the npz file and the cifar10 data set used ? Cifar is a picture in PNG format, and the npz file is an array with only arr _ 0 list. How should I do FID calculation

Have you solved this problem yet?

Maybe you kan use this https://github.com/openai/guided-diffusion/tree/main/evaluations.

For the npz file generated after sampling, how to calculate the FID score of the npz file and the cifar10 data set used ? Cifar is a picture in PNG format, and the npz file is an array with only arr _ 0 list. How should I do FID calculation

Have you solved this problem yet?

Maybe you kan use this https://github.com/openai/guided-diffusion/tree/main/evaluations.

Thanks.Have you using the cifar10 pretrained model provided in the readme?I got very high FID when I used cifar10_uncond_50M_500K.pt.I don't know what's wrong。

you can read in npz file as numpy array and save it as png. This way you have both sets in the same format and can calculate FID

Code for this:

import os
import numpy as np
from PIL import Image

def main():
    npz_path = "/path/to/npz_file"
    output_path = "/path/to/output_dir"

    if not os.path.exists(output_path):
        os.makedirs(output_path)

    with np.load(npz_path) as f:
        arr = f["arr_0"]

    print(f"num samples: {arr.shape[0]}")
    print(f"dims: {arr.shape[1]}x{arr.shape[2]}x{arr.shape[3]}")

    for i in range(arr.shape[0]):
        im = Image.fromarray(arr[i])
        im.save(os.path.join(output_path, f"sample_{i}.png"))

if __name__ == "__main__":
    main()