Skip to content

Commit c6cb323

Browse files
committed
Add a test for MRCNN resize_letterbox
1 parent 6bb8327 commit c6cb323

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

src/cpp/include/tasks/instance_segmentation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class InstanceSegmentation {
3434
utils::get_from_any_maps("confidence_threshold", user_config, model_config, confidence_threshold);
3535
input_shape.width = utils::get_from_any_maps("orig_width", user_config, model_config, input_shape.width);
3636
input_shape.height = utils::get_from_any_maps("orig_height", user_config, model_config, input_shape.width);
37+
resize_mode = utils::get_from_any_maps("resize_type", user_config, model_config, resize_mode);
3738
}
3839

3940
static void serialize(std::shared_ptr<ov::Model>& ov_model);
@@ -61,4 +62,5 @@ class InstanceSegmentation {
6162

6263
cv::Size input_shape;
6364
float confidence_threshold = 0.5f;
65+
utils::RESIZE_MODE resize_mode = utils::RESIZE_MODE::RESIZE_FILL;
6466
};

src/cpp/include/utils/config.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ inline bool get_from_any_maps(const std::string& key,
4242
return low_priority;
4343
}
4444

45-
enum class RESIZE_MODE {
45+
enum class RESIZE_MODE {
4646
RESIZE_FILL,
4747
RESIZE_KEEP_ASPECT,
4848
RESIZE_KEEP_ASPECT_LETTERBOX,
@@ -72,7 +72,6 @@ inline RESIZE_MODE get_from_any_maps(const std::string& key,
7272
return resize;
7373
}
7474

75-
7675
ov::AnyMap get_config_from_onnx(const std::string& model_path);
7776

7877
void add_ov_model_info(std::shared_ptr<ov::Model> model, const ov::AnyMap& config);

src/cpp/src/tasks/detection/ssd.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ DetectionResult SSD::postprocessMultipleOutputs(InferenceResult& infResult) {
208208
float invertedScaleX = floatInputImgWidth / input_shape.width,
209209
invertedScaleY = floatInputImgHeight / input_shape.height;
210210
int padLeft = 0, padTop = 0;
211-
if (utils::RESIZE_MODE::RESIZE_KEEP_ASPECT == resize_mode || utils::RESIZE_MODE::RESIZE_KEEP_ASPECT_LETTERBOX == resize_mode) {
211+
if (utils::RESIZE_MODE::RESIZE_KEEP_ASPECT == resize_mode ||
212+
utils::RESIZE_MODE::RESIZE_KEEP_ASPECT_LETTERBOX == resize_mode) {
212213
invertedScaleX = invertedScaleY = std::max(invertedScaleX, invertedScaleY);
213214
if (utils::RESIZE_MODE::RESIZE_KEEP_ASPECT_LETTERBOX == resize_mode) {
214215
padLeft = (input_shape.width - int(std::round(floatInputImgWidth / invertedScaleX))) / 2;

src/cpp/src/tasks/instance_segmentation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,10 @@ InstanceSegmentationResult InstanceSegmentation::postprocess(InferenceResult& in
234234
float invertedScaleX = floatInputImgWidth / input_shape.width,
235235
invertedScaleY = floatInputImgHeight / input_shape.height;
236236
int padLeft = 0, padTop = 0;
237-
auto resizeMode = utils::RESIZE_MODE::RESIZE_FILL;
238-
if (utils::RESIZE_MODE::RESIZE_KEEP_ASPECT == resizeMode || utils::RESIZE_MODE::RESIZE_KEEP_ASPECT_LETTERBOX == resizeMode) {
237+
if (utils::RESIZE_MODE::RESIZE_KEEP_ASPECT == resize_mode ||
238+
utils::RESIZE_MODE::RESIZE_KEEP_ASPECT_LETTERBOX == resize_mode) {
239239
invertedScaleX = invertedScaleY = std::max(invertedScaleX, invertedScaleY);
240-
if (utils::RESIZE_MODE::RESIZE_KEEP_ASPECT_LETTERBOX == resizeMode) {
240+
if (utils::RESIZE_MODE::RESIZE_KEEP_ASPECT_LETTERBOX == resize_mode) {
241241
padLeft = (input_shape.width - int(std::round(floatInputImgWidth / invertedScaleX))) / 2;
242242
padTop = (input_shape.height - int(std::round(floatInputImgHeight / invertedScaleY))) / 2;
243243
}

tests/python/accuracy/public_scope.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,5 +243,17 @@
243243
]
244244
}
245245
]
246+
},
247+
{
248+
"name": "otx_models/maskrcnn_xai_tiling.xml",
249+
"type": "MaskRCNNModel",
250+
"test_data": [
251+
{
252+
"image": "coco128/images/train2017/000000000074.jpg",
253+
"reference": [
254+
"281, 71, 303, 84, 2 (ellipse): 0.553, 224, RotatedRect: 291.500 77.000 12.000 19.000 90.000; 496, 7, 523, 38, 1 (rectangle): 0.497, 775, RotatedRect: 509.000 23.000 30.000 26.000 90.000; 2; [1,1280,1,1]; "
255+
]
256+
}
257+
]
246258
}
247259
]

0 commit comments

Comments
 (0)