-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsplitSets.py
31 lines (23 loc) · 973 Bytes
/
splitSets.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
import os
import os.path as osp
import glob
import cv2
import random
if __name__ == "__main__":
inPath = "/Users/martonszemenyei/Projects/ROBO/data/YOLO/sydney/"
oPathTrain = "/Users/martonszemenyei/Projects/ROBO/data/YOLO/Finetune/train/"
oPathTest = "/Users/martonszemenyei/Projects/ROBO/data/YOLO/Finetune/test/"
names = sorted(glob.glob1(inPath,"syd*.png"))
labNames = sorted(glob.glob1(inPath,"*.txt"))
for img,lab in zip(names,labNames):
r = random.random()
if r > 0.8:
os.rename(osp.join(inPath,img),osp.join(oPathTest,img))
os.rename(osp.join(inPath,lab),osp.join(oPathTest,lab))
else:
os.rename(osp.join(inPath,img),osp.join(oPathTrain,img))
os.rename(osp.join(inPath,lab),osp.join(oPathTrain,lab))
'''for name in names:
img = cv2.imread(oPathTrain+name)
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
cv2.imwrite(oPathTrain+name,img)'''