@@ -122,6 +122,10 @@ cv::Mat segm_postprocess(const SegmentedObject& box, const cv::Mat& unpadded, in
122122}
123123
124124void InstanceSegmentation::serialize (std::shared_ptr<ov::Model>& ov_model) {
125+ if (utils::model_has_embedded_processing (ov_model)) {
126+ std::cout << " model already was serialized" << std::endl;
127+ return ;
128+ }
125129 if (ov_model->inputs ().size () != 1 ) {
126130 throw std::logic_error (" MaskRCNNModel model wrapper supports topologies with only 1 input" );
127131 }
@@ -188,23 +192,18 @@ void InstanceSegmentation::serialize(std::shared_ptr<ov::Model>& ov_model) {
188192}
189193
190194InstanceSegmentation InstanceSegmentation::load (const std::string& model_path, const ov::AnyMap& configuration) {
191- auto core = ov::Core ();
192- std::shared_ptr<ov::Model> model = core.read_model (model_path);
193-
194- if (model->has_rt_info (" model_info" , " model_type" )) {
195- std::cout << " has model type in info: " << model->get_rt_info <std::string>(" model_info" , " model_type" )
196- << std::endl;
197- } else {
198- throw std::runtime_error (" Incorrect or unsupported model_type" );
199- }
195+ auto adapter = std::make_shared<OpenVINOInferenceAdapter>();
196+ adapter->loadModel (model_path, " " , {}, false );
200197
201- if (utils::model_has_embedded_processing (model)) {
202- std::cout << " model already was serialized" << std::endl;
203- } else {
204- serialize (model);
198+ std::string model_type;
199+ model_type = utils::get_from_any_maps (" model_type" , adapter->getModelConfig (), {}, model_type);
200+
201+ if (model_type.empty () || model_type != " MaskRCNN" ) {
202+ throw std::runtime_error (" Incorrect or unsupported model_type, expected: MaskRCNN" );
205203 }
206- auto adapter = std::make_shared<OpenVINOInferenceAdapter>();
207- adapter->loadModel (model, core, " AUTO" );
204+ adapter->applyModelTransform (InstanceSegmentation::serialize);
205+ adapter->compileModel (" AUTO" , {});
206+
208207 return InstanceSegmentation (adapter, configuration);
209208}
210209
@@ -228,11 +227,8 @@ InstanceSegmentationResult InstanceSegmentation::postprocess(InferenceResult& in
228227 float invertedScaleX = floatInputImgWidth / input_shape.width ,
229228 invertedScaleY = floatInputImgHeight / input_shape.height ;
230229
231- std::cout << " got an inf result with image: " << infResult.inputImageSize << std::endl;
232- std::cout << " resize mode: " << resize_mode << std::endl;
233230 int padLeft = 0 , padTop = 0 ;
234231 if (utils::RESIZE_KEEP_ASPECT == resize_mode || utils::RESIZE_KEEP_ASPECT_LETTERBOX == resize_mode) {
235- std::cout << " using some other resize mode..." << std::endl;
236232 invertedScaleX = invertedScaleY = std::max (invertedScaleX, invertedScaleY);
237233 if (utils::RESIZE_KEEP_ASPECT_LETTERBOX == resize_mode) {
238234 padLeft = (input_shape.width - int (std::round (floatInputImgWidth / invertedScaleX))) / 2 ;
0 commit comments