Skip to content

Commit f0f770a

Browse files
committed
Make cpp keep_ratio preprocessing graph identical to python
1 parent 7043036 commit f0f770a

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/cpp/include/utils/preprocessing.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ ov::Output<ov::Node> fitToWindowLetterBoxGraph(const ov::Output<ov::Node>& input
4040
const cv::InterpolationFlags interpolationMode,
4141
uint8_t pad_value);
4242

43-
ov::Output<ov::Node> fitToWindowLetterBoxGraph(const ov::Output<ov::Node>& input,
44-
const ov::Shape& size,
45-
const cv::InterpolationFlags interpolationMode,
46-
uint8_t pad_value);
47-
4843
ov::Output<ov::Node> cropResizeGraph(const ov::Output<ov::Node>& input,
4944
const ov::Shape& size,
5045
const cv::InterpolationFlags interpolationMode);

src/cpp/src/tasks/keypoint_detection.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ KeypointDetectionResult decode_simcc(const cv::Mat& simcc_x,
5252
float decode_beta = 150.0f,
5353
float sigma = 6.0f) {
5454
cv::Mat x_locs, max_val_x;
55-
std::cout << cv::sum(simcc_x) << "\n";
56-
std::cout << cv::sum(simcc_y) << "\n";
5755
colArgMax(simcc_x, x_locs, max_val_x, false);
5856

5957
cv::Mat y_locs, max_val_y;
@@ -161,6 +159,7 @@ void KeypointDetection::serialize(std::shared_ptr<ov::Model>& ov_model) {
161159
ov_model->set_rt_info(true, "model_info", "embedded_processing");
162160
ov_model->set_rt_info(input_shape.width, "model_info", "orig_width");
163161
ov_model->set_rt_info(input_shape.height, "model_info", "orig_height");
162+
ov::save_model(ov_model, "kp_tmp_model.xml");
164163
}
165164

166165
std::map<std::string, ov::Tensor> KeypointDetection::preprocess(cv::Mat image) {

src/cpp/src/utils/preprocessing.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,15 @@ Output<Node> resizeImageGraph(const ov::Output<ov::Node>& input,
150150
auto w_ratio = std::make_shared<opset10::Divide>(opset10::Constant::create(element::f32, Shape{1}, {float(w)}), iw);
151151
auto h_ratio = std::make_shared<opset10::Divide>(opset10::Constant::create(element::f32, Shape{1}, {float(h)}), ih);
152152
auto scale = std::make_shared<opset10::Minimum>(w_ratio, h_ratio);
153-
auto nw = std::make_shared<opset10::Convert>(std::make_shared<opset10::Multiply>(iw, scale), element::i32);
154-
auto nh = std::make_shared<opset10::Convert>(std::make_shared<opset10::Multiply>(ih, scale), element::i32);
153+
auto nw = std::make_shared<opset10::Convert>(
154+
std::make_shared<opset10::Round>(std::make_shared<opset10::Multiply>(iw, scale),
155+
opset10::Round::RoundMode::HALF_TO_EVEN),
156+
element::i32);
157+
auto nh = std::make_shared<opset10::Convert>(
158+
std::make_shared<opset10::Round>(std::make_shared<opset10::Multiply>(ih, scale),
159+
opset10::Round::RoundMode::HALF_TO_EVEN),
160+
element::i32);
161+
155162
auto new_size = std::make_shared<opset10::Concat>(OutputVector{nh, nw}, 0);
156163

157164
auto scales = opset10::Constant::create(element::f32, Shape{2}, {0.0f, 0.0f});

0 commit comments

Comments
 (0)