-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdataset.py
43 lines (35 loc) · 964 Bytes
/
dataset.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
import numpy as np
from glob import glob
from tqdm import tqdm
import cv2
# create dataset
Y_train = []
X_train = []
dos = glob('car_dataset\\*')
i=0
for path in tqdm(dos):
img = cv2.imread(path)
if img.shape[0]*img.shape[1]>=30000:
img = cv2.resize(img,(150,100))
x = cv2.blur(img,(2,2)) #if you want blured image as X
X_train.append(x/255)
Y_train.append(img/255)
if len(X_train)>= 2000:
X_train = np.array(X_train)
Y_train = np.array(Y_train)
i+=1
np.save('dataset\\'+str(i)+'_blurX_train.npy', X_train)
np.save('dataset\\'+str(i)+'_blurY_train.npy', Y_train)
print('saved X_train', i)
print('saved Y_train', i)
X_train = []
Y_train = []
X_train = np.array(X_train)
Y_train = np.array(Y_train)
i+=1
np.save('dataset\\'+str(i)+'_X_train.npy', X_train)
np.save('dataset\\'+str(i)+'_Y_train.npy', Y_train)
print('saved X_train', i)
print('saved Y_train', i)
X_train = []
Y_train = []