-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathload_images.py
32 lines (25 loc) · 907 Bytes
/
load_images.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
import cv2
import os
from keras.preprocessing.image import img_to_array
class load:
def __init__(self, width, height, channels, paths):
self.width = width
self.height = height
self.channels = channels
self.paths = paths
self.data = []
self.labels = []
def imgload(self):
i = -1
for folder in self.paths:
i = i+1
path = str(folder[0])
folder = os.listdir(path)
for file in folder:
# print(file+" "+str(i))
img = cv2.imread(path+'/'+file, -1)
img = cv2.resize(img, (self.width, self.height))
img = img_to_array(img)
self.data.append(img)
self.labels.append(i)
return self.data, self.labels