File size: 958 Bytes
b27cd24 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import os
gt_folder = "/vast/ds5725/linefinder/LineFinder/GT_json"
img_folder = "/scratch/ds5725/linefinder/LineFinder/Images"
output_txt = "images_without_gt.txt"
# 1️⃣ Collect GT names
gt_names = set()
for dirpath, _, filenames in os.walk(gt_folder):
for fname in filenames:
if fname.lower().endswith(".json"):
gt_names.add(os.path.splitext(fname)[0])
# 2️⃣ Collect image paths
img_paths = {}
for dirpath, _, filenames in os.walk(img_folder):
for fname in filenames:
if fname.lower().endswith((".jpg", ".jpeg", ".png", ".webp")):
key = os.path.splitext(fname)[0]
img_paths[key] = os.path.join(dirpath, fname)
# 3️⃣ Compute missing
missing_keys = sorted(set(img_paths.keys()) - gt_names)
# 4️⃣ Write full paths
with open(output_txt, "w") as f:
for key in missing_keys:
f.write(img_paths[key] + "\n")
print(f"Saved {len(missing_keys)} image paths to {output_txt}") |