-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdataset.py
44 lines (34 loc) · 1019 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
44
import numpy as np
import cv2
import glob
neg_path = 'negative/'
pos_path = 'positive/'
test_path = 'test/'
class dataset:
def __init__(self, name):
print 'dataset:', name
self.base_path = name
self.image_path = ""
def image_path(self):
return self.image_path
def load_images(self, names, resize=False):
result = []
for im in names:
img = cv2.imread(im, 0)
if resize:
img = cv2.resize(img, (64,128))
result.append(img)
return result
def get_pos_images(self, N):
self.image_path = self.base_path +'/'+ pos_path
print self.image_path
images = glob.glob(self.image_path + '*.png')
return self.load_images(images[:N], resize=True)
def get_neg_images(self, N):
self.image_path = self.base_path +'/'+ neg_path
images = glob.glob(self.image_path + '*.png')
return self.load_images(images[:N], resize=True)
def get_test_images(self):
self.image_path = self.base_path +'/'+ test_path
images = glob.glob(self.image_path + '*.png')
return self.load_images(images)