-
Notifications
You must be signed in to change notification settings - Fork 7
/
check_images_have_annotations.py
28 lines (22 loc) · 1.17 KB
/
check_images_have_annotations.py
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
import glob
import os
name = "Task09_Spleen_RGB_2D_512"
tr_root_img_folder = f"data/MSD/{name}/images/training"
val_root_img_folder = f"data/MSD/{name}/images/validation"
tr_root_annot_folder = f"data/MSD/{name}/annotations/training"
val_root_annot_folder = f"data/MSD/{name}/annotations/validation"
for ind, image_path in enumerate(glob.glob(f"{tr_root_img_folder}/*.png")):
if not os.path.exists(image_path.replace('images', 'annotations')):
print(image_path, "does not have annotations")
for ind, image_path in enumerate(glob.glob(f"{val_root_img_folder}/*.png")):
if not os.path.exists(image_path.replace('images', 'annotations')):
print(image_path, "does not have annotations")
os.remove(image_path)
for ind, image_path in enumerate(glob.glob(f"{tr_root_annot_folder}/*.png")):
if not os.path.exists(image_path.replace('annotations', 'images')):
print(image_path, "does not have image")
os.remove(image_path)
for ind, image_path in enumerate(glob.glob(f"{val_root_annot_folder}/*.png")):
if not os.path.exists(image_path.replace('annotations', 'images')):
print(image_path, "does not have image")
os.remove(image_path)