-
Notifications
You must be signed in to change notification settings - Fork 0
/
testModel.py
48 lines (38 loc) · 1.06 KB
/
testModel.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
from __future__ import print_function
import math
import os
import shutil
import stat
import subprocess
import sys
import cv2
import numpy as np
import caffe
from google.protobuf import text_format
weights_file = "models/fresh/VGG_VOC0712_SSD_300x300_iter_120000.caffemodel"
deploy_file = "models/deploy_backup.prototxt"
caffe.set_mode_gpu()
caffe.set_device(0)
image = cv2.imread("testImage.jpg", flags=cv2.IMREAD_COLOR)
image = cv2.resize(image, (300,300))
image = np.array(image)
# image = np.transpose(image, (2,0,1))
print (image.shape)
print(image[:,:,0])
print(image[:,:,1])
print(image[:,:,2])
image = image[np.newaxis, :,:,:]
mean = np.array([ 123, 117, 104])
image = image - mean
image = np.transpose(image, (0,3,1,2))
print (image.shape)
net = caffe.Net( deploy_file, weights_file, caffe.TEST)
print (image.shape)
net.blobs['data'].data[...] = image
net.forward(end='detection_out')
myData = net.blobs['detection_out'].data
print ("mbox_conf_reshape shape is: ", myData.shape)
for i in range(200):
print (myData[:,:,i,:])
# print (myData)
# print (myData[0,:42])