@@ -31,19 +31,17 @@ SemanticSegmentation SemanticSegmentation::load(const std::string& model_path) {
3131 throw std::runtime_error (" Incorrect or unsupported model_type" );
3232 }
3333
34- cv::Size origin_input_shape;
3534 if (utils::model_has_embedded_processing (model)) {
3635 std::cout << " model already was serialized" << std::endl;
37- origin_input_shape = utils::get_input_shape_from_model_info (model);
3836 } else {
39- origin_input_shape = SemanticSegmentation::serialize (model);
37+ SemanticSegmentation::serialize (model);
4038 }
4139 auto adapter = std::make_shared<OpenVINOInferenceAdapter>();
4240 adapter->loadModel (model, core, " AUTO" );
4341 return SemanticSegmentation (adapter);
4442}
4543
46- cv::Size SemanticSegmentation::serialize (std::shared_ptr<ov::Model>& ov_model) {
44+ void SemanticSegmentation::serialize (std::shared_ptr<ov::Model>& ov_model) {
4745 if (ov_model->inputs ().size () != 1 ) {
4846 throw std::logic_error (" Segmentation model wrapper supports topologies with only 1 input" );
4947 }
@@ -90,14 +88,13 @@ cv::Size SemanticSegmentation::serialize(std::shared_ptr<ov::Model>& ov_model) {
9088 scale_values = utils::get_from_any_maps (" scale_values" , config, ov::AnyMap{}, scale_values);
9189 mean_values = utils::get_from_any_maps (" mean_values" , config, ov::AnyMap{}, mean_values);
9290
93- auto input_shape = ov::Shape{shape[ov::layout::width_idx (layout)], shape[ov::layout::height_idx (layout)]};
9491
9592 ov_model = utils::embedProcessing (ov_model,
9693 input.get_any_name (),
9794 layout,
9895 resize_mode,
9996 interpolation_mode,
100- input_shape ,
97+ ov::Shape{shape[ ov::layout::width_idx (layout)], shape[ ov::layout::height_idx (layout)]} ,
10198 pad_value,
10299 reverse_input_channels,
103100 mean_values,
@@ -115,7 +112,10 @@ cv::Size SemanticSegmentation::serialize(std::shared_ptr<ov::Model>& ov_model) {
115112 }
116113 ov_model = ppp.build ();
117114
118- return cv::Size (input_shape[0 ], input_shape[1 ]);
115+ cv::Size input_shape (shape[ov::layout::width_idx (layout)],
116+ shape[ov::layout::height_idx (layout)]);
117+ ov_model->set_rt_info (input_shape.width , " model_info" , " orig_width" );
118+ ov_model->set_rt_info (input_shape.height , " model_info" , " orig_height" );
119119}
120120
121121std::map<std::string, ov::Tensor> SemanticSegmentation::preprocess (cv::Mat image) {
@@ -162,7 +162,6 @@ SemanticSegmentationResult SemanticSegmentation::postprocess(InferenceResult& in
162162 SemanticSegmentationResult result;
163163 result.resultImage = hard_prediction;
164164 if (return_soft_prediction) {
165- std::cout << " got a soft prediction..." << std::endl;
166165 cv::resize (soft_prediction, soft_prediction, infResult.inputImageSize , 0.0 , 0.0 , cv::INTER_NEAREST);
167166 result.soft_prediction = soft_prediction;
168167 auto iter = infResult.data .find (feature_vector_name);
@@ -227,7 +226,6 @@ cv::Mat SemanticSegmentation::create_hard_prediction_from_soft_prediction(cv::Ma
227226
228227 bool applyBlurAndSoftThreshold = (blur_strength > -1 && soft_threshold < std::numeric_limits<float >::infinity ());
229228 if (applyBlurAndSoftThreshold) {
230- std::cout << " applying blur and soft threshold: " << blur_strength << std::endl;
231229 cv::blur (soft_prediction_blurred, soft_prediction_blurred, cv::Size{blur_strength, blur_strength});
232230 }
233231
0 commit comments