MaybeRichard's picture
snapshot: full fm generation pipeline
32da3e8 verified
Raw
History Blame Contribute Delete
725 Bytes
import numpy as np, torch
from PIL import Image
import sys
RAE_OLD="/mnt/tidal-alsh-share2/dataset/qinshengqian/research/c3/Code/RAE"
sys.path.insert(0, RAE_OLD+"/src")
from eval.fid import calculate_rfid
ref = np.load(RAE_OLD+"/data/isic2019_imagefolder/val_224.npz")["arr_0"]
print("ref", ref.shape, "std=%.0f"%ref.std(), flush=True)
for a in ["dinov3l-k1","dinov3l-k23","sdvae","indomainvae"]:
g = np.load(f"results/stage2/eval/gen_{a}.npz")["arr_0"]
g224 = np.stack([np.asarray(Image.fromarray(x).resize((224,224),Image.BICUBIC)) for x in g]).astype(np.uint8)
fid = calculate_rfid(ref, g224, 128, "cuda")
print(f"FID {a}: {fid:.2f} (gen std=%.0f)"%g.std(), flush=True)
print("FID_ALL_DONE", flush=True)