4
4
plt .rcParams ['image.interpolation' ] = 'nearest'
5
5
plt .rcParams ['image.cmap' ] = 'gray'
6
6
7
- import os
8
- curdir = os .getcwd ()
9
- import sys
10
- sys .path .insert (0 ,'../../python' )
11
-
7
+ import os ,platform ,sys
8
+ if platform .system ()== "Windows" :
9
+ caffe_root = "D:/CNN/ssd" #2
10
+ else :
11
+ caffe_root = "/home/yanyu/Detection/ssd"
12
+ sys .path .insert (0 ,caffe_root + '/python' )
12
13
import caffe
13
14
caffe .set_device (0 )
14
15
caffe .set_mode_gpu ()
15
16
from google .protobuf import text_format
16
17
from caffe .proto import caffe_pb2
17
18
datasetname = "Face2017"
18
19
# load PASCAL VOC labels
19
- labelmap_file = curdir + '/ labelmap_face.prototxt'
20
+ labelmap_file = ' labelmap_face.prototxt'
20
21
file = open (labelmap_file , 'r' )
21
22
labelmap = caffe_pb2 .LabelMap ()
22
23
text_format .Merge (str (file .read ()), labelmap )
@@ -28,7 +29,7 @@ def get_labelname(labelmap, labels):
28
29
labels = [labels ]
29
30
for label in labels :
30
31
found = False
31
- for i in xrange (0 , num_labels ):
32
+ for i in range (0 , num_labels ):
32
33
if label == labelmap .item [i ].label :
33
34
found = True
34
35
labelnames .append (labelmap .item [i ].display_name )
@@ -38,8 +39,8 @@ def get_labelname(labelmap, labels):
38
39
#model_def =curdir+"/cpp/models/face_deploy.prototxt"
39
40
#model_weights=curdir+"/cpp/models/VGG_Face2017_SSD_300x300_iter_120000.caffemodel"
40
41
#image_resize = 300
41
- model_def = curdir + "/ cpp/models/faceboxes_deploy.prototxt"
42
- model_weights = curdir + "/ cpp/models/FaceBoxes_1024x1024.caffemodel"
42
+ model_def = " cpp/models/faceboxes_deploy.prototxt"
43
+ model_weights = " cpp/models/FaceBoxes_1024x1024.caffemodel"
43
44
image_resize = 1024
44
45
net = caffe .Net (model_def , # defines the structure of the model
45
46
model_weights , # contains the trained weights
@@ -85,13 +86,13 @@ def get_labelname(labelmap, labels):
85
86
plt .imshow (image )
86
87
currentAxis = plt .gca ()
87
88
88
- for i in xrange (top_conf .shape [0 ]):
89
+ for i in range (top_conf .shape [0 ]):
89
90
xmin = int (round (top_xmin [i ] * image .shape [1 ]))
90
91
ymin = int (round (top_ymin [i ] * image .shape [0 ]))
91
92
xmax = int (round (top_xmax [i ] * image .shape [1 ]))
92
93
ymax = int (round (top_ymax [i ] * image .shape [0 ]))
93
94
score = top_conf [i ]
94
- print xmin ,ymin ,xmax ,ymax ,score
95
+ print ( xmin ,ymin ,xmax ,ymax ,score )
95
96
label = int (top_label_indices [i ])
96
97
label_name = top_labels [i ]
97
98
display_txt = '%s: %.2f' % (label_name , score )
0 commit comments