-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakePathRD.py
More file actions
34 lines (28 loc) · 777 Bytes
/
makePathRD.py
File metadata and controls
34 lines (28 loc) · 777 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
34
import os
import random
base = "./Drone"
train = os.path.join(base, "train")
test = os.path.join(base, "test")
valid = os.path.join(base, "valid")
check = False
if not os.path.exists(train):
print("no train folder")
check = True
if not os.path.exists(test):
print("no test folder")
check = True
if not os.path.exists(valid):
print("no valid folder")
check = True
if check:
exit()
for folder in [train, test, valid]:
# make absolute path
path = os.path.abspath(folder)
text = open(folder + ".txt", "w", encoding="UTF-8")
labels = [f for f in os.listdir(folder) if f.endswith(".jpg")]
random.shuffle(labels)
for f in labels:
text.write(os.path.join(path, f) + "\n")
text.close()
print(folder + " finish")