-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileHandlerTest.py
More file actions
57 lines (47 loc) · 1.48 KB
/
Copy pathfileHandlerTest.py
File metadata and controls
57 lines (47 loc) · 1.48 KB
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
53
54
55
56
57
import cv2
import numpy as np
import scipy
import scipy.spatial
from matplotlib.pyplot import imread
import _pickle as pickle
import random
from random import shuffle
import os
from shutil import copy
import matplotlib.pyplot as plt
import sys
path = './PINS'
if len(sys.argv) == 2:
path = sys.argv[1]
files = os.listdir(path)
for name in files:
images_path = os.path.abspath(__file__)
relative_path = name
images_path = os.path.dirname(images_path) + '/PINS/' + relative_path
filesTemp = [os.path.join(images_path, p) for p in sorted(os.listdir(images_path))]
sz = len(filesTemp)
cut = int(0.8 * sz)
shuffled_Temp = filesTemp
shuffle(shuffled_Temp)
Reference = shuffled_Temp[:cut]
Test = shuffled_Temp[cut:]
dirNameRef = '\\Data\\Referensi\\' + relative_path + 'Reference'
dirNameTest = '\\Data\\DataUji\\' + relative_path + 'Test'
base = os.path.abspath(__file__)
base = os.path.dirname(base)
try:
os.mkdir(base + dirNameRef)
print("Directory " , dirNameRef , " Created ")
except FileExistsError:
print("Directory " , dirNameRef , " already exists")
try:
os.mkdir(base + dirNameTest)
print("Directory " , dirNameTest , " Created ")
except FileExistsError:
print("Directory " , dirNameTest , " already exists")
for temp in Reference:
dst = base + dirNameRef
copy(temp, dst)
for temp in Test:
dst = base + dirNameTest
copy(temp, dst)