@@ -73,25 +73,25 @@ def parse_yolo_region(self, blob: 'np.ndarray', original_shape: list, params: di
73
73
for n in range (num ):
74
74
# -----entry index calcs------
75
75
obj_index = self .entry_index (params ['side' ], coords , classes , n * side_square + i , coords )
76
- # -----entry index calcs------
77
76
scale = predictions [obj_index ]
78
77
if scale < self .PROB_THRESHOLD :
79
78
continue
80
79
box_index = self .entry_index (params ['side' ], coords , classes , n * side_square + i , 0 )
81
80
82
81
# Network produces location predictions in absolute coordinates of feature maps.
83
82
# Scale it to relative coordinates.
84
- x = (col + predictions [box_index + 0 * side_square ]) / params ['side' ]
85
- y = (row + predictions [box_index + 1 * side_square ]) / params ['side' ]
83
+ x = (col + predictions [box_index + 0 * side_square ]) / params ['side' ] * 416
84
+ y = (row + predictions [box_index + 1 * side_square ]) / params ['side' ] * 416
86
85
# Value for exp is very big number in some cases so following construction is using here
87
86
try :
88
- w_exp = exp (predictions [box_index + 2 * side_square ])
89
87
h_exp = exp (predictions [box_index + 3 * side_square ])
88
+ w_exp = exp (predictions [box_index + 2 * side_square ])
90
89
except OverflowError :
91
90
continue
92
91
93
- w = w_exp * params ['anchors' ][2 * n ] / 416
94
- h = h_exp * params ['anchors' ][2 * n + 1 ] / 416
92
+ w = w_exp * params ['anchors' ][2 * n ]
93
+ h = h_exp * params ['anchors' ][2 * n + 1 ]
94
+
95
95
for j in range (classes ):
96
96
class_index = self .entry_index (params ['side' ], coords , classes , n * side_square + i ,
97
97
coords + 1 + j )
@@ -105,8 +105,8 @@ def parse_yolo_region(self, blob: 'np.ndarray', original_shape: list, params: di
105
105
w = w ,
106
106
class_id = j ,
107
107
confidence = confidence ,
108
- h_scale = orig_im_h ,
109
- w_scale = orig_im_w ))
108
+ h_scale = ( orig_im_h / 416 ) ,
109
+ w_scale = ( orig_im_w / 416 ) ))
110
110
111
111
112
112
for detection in detections :
@@ -115,12 +115,7 @@ def parse_yolo_region(self, blob: 'np.ndarray', original_shape: list, params: di
115
115
width = detection ['frame_width' ]
116
116
detection = detection ['detections' ]
117
117
118
- original_shape = (width , height )
119
-
120
- resized_width = width / 416
121
- resized_height = height / 416
122
-
123
- resized_shape = (resized_width , resized_height )
118
+ original_shape = (height , width )
124
119
125
120
# https://github.com/opencv/open_model_zoo/blob/master/demos/python_demos/object_detection_demo_yolov3_async/object_detection_demo_yolov3_async.py#L72
126
121
anchors = [10 ,13 ,16 ,30 ,33 ,23 ,30 ,61 ,62 ,45 ,59 ,119 ,116 ,90 ,156 ,198 ,373 ,326 ]
@@ -148,7 +143,6 @@ def parse_yolo_region(self, blob: 'np.ndarray', original_shape: list, params: di
148
143
parser .sort_objects ()
149
144
150
145
objects = []
151
-
152
146
for obj in parser .objects :
153
147
if obj ['confidence' ] >= parser .PROB_THRESHOLD :
154
148
label = obj ['class_id' ]
@@ -157,4 +151,4 @@ def parse_yolo_region(self, blob: 'np.ndarray', original_shape: list, params: di
157
151
ymin = obj ['ymin' ]
158
152
ymax = obj ['ymax' ]
159
153
160
- results .add_box (xmax , ymax , xmin , ymin , label , frame_number )
154
+ results .add_box (xmin , ymin , xmax , ymax , label , frame_number )
0 commit comments