NVlabs / eg3d

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Index mismatch hazard in dataset_preprocessing/ffhq/crop_images_in_the_wild.py

three-bee opened this issue · comments

There is no assertion for len(img_files)==len(lm_files). If unsatisfied ( len(lm_files)<len(img_files), i.e. the face reconstruction backbone could not find landmarks for all given images ) this will eventually cause a hazard in the loop beginning on line 36, causing a continuous mismatch between images and their landmark files:

lm_dir = os.path.join(args.indir, "detections")
img_files = sorted([x for x in os.listdir(args.indir) if x.lower().endswith(".png") or x.lower().endswith(".jpg")])
lm_files = sorted([x for x in os.listdir(lm_dir) if x.endswith(".txt")])
lm3d_std = load_lm3d("Deep3DFaceRecon_pytorch/BFM/")
out_dir = os.path.join(args.indir, "crop")
if not os.path.exists(out_dir):
os.makedirs(out_dir, exist_ok=True)
for img_file, lm_file in zip(img_files, lm_files):
img_path = os.path.join(args.indir, img_file)