-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtidy_imglbl.py
More file actions
33 lines (26 loc) · 847 Bytes
/
tidy_imglbl.py
File metadata and controls
33 lines (26 loc) · 847 Bytes
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
import os
import sys
import natsort
import shutil
import config
def cleanup(path):
img = natsort.os_sorted(os.listdir(os.path.join(path,"images")))
lbl = natsort.os_sorted(os.listdir(os.path.join(path,"labels")))
print(len(img),len(lbl))
for i in img:
txt = i.replace(".jpg",".txt")
# print(jpg)
if txt not in lbl:
# print(txt)
delete = os.path.join(os.path.join(path,"images"),i)
print(delete)
shutil.move(delete,path)
print(f"moved {delete}")
print("finished tidying images and labels")
if __name__ == "__main__":
# if len(sys.argv) != 2:
# print("Usage: python cleanup.py [Dir_path]")
path = "/home/marco/1/0003_images/"
clean(path)
# print(i)
# clean(path)