-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage_label_check.py
executable file
·52 lines (47 loc) · 1.35 KB
/
image_label_check.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import shutil
def check(image_path,label_path):
'''
for ours labels
'''
image_list=os.listdir(image_path)
for image in image_list:
coord_label=image+".txt"
absolute_path=os.path.join(label_path,coord_label)
if os.path.exists(absolute_path):
continue
else:
os.system("rm "+os.path.join(image_path,image))
label_list=os.listdir(label_path)
for label in label_list:
coord_image=os.path.splitext(label)[0]
absolute_path=os.path.join(image_path,coord_image)
if os.path.exists(absolute_path):
continue
else:
os.system("rm "+os.path.join(label_path,label))
def check_version(image_path,label_path):
'''
for yolo labels
'''
image_list=os.listdir(image_path)
for image in image_list:
coord_label=os.path.splitext(image)[0]+".txt"
absolute_path=os.path.join(label_path,coord_label)
if os.path.exists(absolute_path):
continue
else:
print absolute_path
os.system("rm "+os.path.join(image_path,image))
label_list=os.listdir(label_path)
for label in label_list:
coord_image=os.path.splitext(label)[0]+".jpg"
absolute_path=os.path.join(image_path,coord_image)
if os.path.exists(absolute_path):
continue
else:
os.system("rm "+os.path.join(label_path,label))
print absolute_path
if __name__=="__main__":
check("/opt/jl/datasets/new_attribute/train/images",
"/opt/jl/datasets/new_attribute/train/labels")