-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreprocessing.py
67 lines (53 loc) · 1.52 KB
/
preprocessing.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os, shutil
from numpy import load
import numpy as np, random, os
colors=os.listdir()
#Split data into train (80%) and test(20%)
#train
i=0
for c in colors:
i=0
files=os.listdir(c)
print (len([name for name in files]))
# if not os.path.exists('train/'+c):
# os.makedirs('train/'+c)
#if not os.path.exists('test/'+c):
# os.makedirs('test/'+c)
for f in files:
if (i<16):
print(c+'/'+f)
shutil.move(c+'/'+f, 'train/'+c)
i+=1
if (i>16):
print('test', c+'/'+f)
shutil.move(c+'/'+f, 'test/'+c)
i+=1
#convert npz to np
from numpy import load
import numpy as np, random, os
colors=os.listdir()
for c in colors:
files=os.listdir(c)
for f in files:
if (f!='train' and f!='test'):
path=c+'/'+f
data = load(path)
lst = data.files
print(f)
#store right hand key points only (for now)
newkr=[]
newkr.append(data['arr_1'])
newkr=np.array(newkr)
name=c+'/'+f.split('.')[0]
np.save(name, newkr)
#delete npz
#HERE
colors=os.listdir()
for c in colors:
files=os.listdir(c)
for f in files:
if (f!='train' and f!='test'):
path=c+'/'+f
if (f.find('.npz')>-1):
print(f)
os.remove(path)