-
Notifications
You must be signed in to change notification settings - Fork 294
/
test_model.py
42 lines (34 loc) · 1.11 KB
/
test_model.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
#-*-coding:utf8-*-
__author__ = '万壑'
from read_data import read_name_list,read_file
from train_model import Model
import cv2
def test_onePicture(path):
model= Model()
model.load()
img = cv2.imread(path)
img = cv2.resize(img, (64, 64))
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
picType,prob = model.predict(img)
if picType != -1:
name_list = read_name_list('D:\myProject\pictures\dataset')
print name_list[picType],prob
else:
print " Don't know this person"
#读取文件夹下子文件夹中所有图片进行识别
def test_onBatch(path):
model= Model()
model.load()
index = 0
img_list, label_lsit, counter = read_file(path)
for img in img_list:
picType,prob = model.predict(img)
if picType != -1:
index += 1
name_list = read_name_list('D:\myProject\pictures\dataset')
print name_list[picType]
else:
print " Don't know this person"
return index
if __name__ == '__main__':
test_onePicture('D:\myProject\pictures\pic.jpg')