Skip to content

Commit 72bae64

Browse files
authored
demos: yolo fixes (#3533)
1. swap W and H for python yolo 2. fix hqResize choice for cpp 3. align padding for resize for cpp and py Ticket: 89481
1 parent d6fbc33 commit 72bae64

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

demos/common/cpp/utils/src/image_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cv::Mat resizeImageExt(const cv::Mat& mat, int width, int height, RESIZE_MODE re
2222
}
2323

2424
cv::Mat dst;
25-
int interpMode = hqResize ? cv::INTER_LINEAR : cv::INTER_CUBIC;
25+
int interpMode = hqResize ? cv::INTER_CUBIC : cv::INTER_LINEAR;
2626

2727
switch (resizeMode) {
2828
case RESIZE_FILL:

demos/common/python/openvino/model_zoo/model_api/models/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def resize_image_letterbox(image, size, interpolation=cv2.INTER_LINEAR):
137137
dx = (w - nw) // 2
138138
dy = (h - nh) // 2
139139
resized_image = np.pad(image, ((dy, dy + (h - nh) % 2), (dx, dx + (w - nw) % 2), (0, 0)),
140-
mode='constant', constant_values=128)
140+
mode='constant', constant_values=0)
141141
return resized_image
142142

143143

demos/common/python/openvino/model_zoo/model_api/models/yolo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def _parse_yolo_region(self, predictions, input_size, params):
140140
class_idx = keep_idxs % params.classes
141141

142142
for ind, obj_ind in enumerate(obj_indx):
143-
row, col, n = self._get_location(obj_ind, params.sides[0], params.num)
143+
row, col, n = self._get_location(obj_ind, params.sides[1], params.num)
144144

145145
# Process raw value to get absolute coordinates of boxes
146146
raw_box = self._get_raw_box(prediction, obj_ind)
@@ -180,8 +180,8 @@ def _get_raw_box(prediction, obj_ind):
180180
def _get_absolute_det_box(box, row, col, anchors, coord_normalizer, size_normalizer):
181181
x = (col + box.x) / coord_normalizer[1]
182182
y = (row + box.y) / coord_normalizer[0]
183-
width = np.exp(box.w) * anchors[0] / size_normalizer[0]
184-
height = np.exp(box.h) * anchors[1] / size_normalizer[1]
183+
width = np.exp(box.w) * anchors[0] / size_normalizer[1]
184+
height = np.exp(box.h) * anchors[1] / size_normalizer[0]
185185

186186
return DetectionBox(x, y, width, height)
187187

0 commit comments

Comments
 (0)