@@ -83,6 +83,10 @@ std::vector<size_t> get_non_xai_output_indices(const std::vector<ov::Output<ov::
8383} // namespace
8484
8585void Classification::serialize (std::shared_ptr<ov::Model>& ov_model) {
86+ if (utils::model_has_embedded_processing (ov_model)) {
87+ std::cout << " model already was serialized" << std::endl;
88+ return ;
89+ }
8690 // --------------------------- Configure input & output -------------------------------------------------
8791 // --------------------------- Prepare input ------------------------------------------------------
8892 auto config = ov_model->has_rt_info (" model_info" ) ? ov_model->get_rt_info <ov::AnyMap>(" model_info" ) : ov::AnyMap{};
@@ -177,23 +181,18 @@ void Classification::serialize(std::shared_ptr<ov::Model>& ov_model) {
177181}
178182
179183Classification Classification::load (const std::string& model_path) {
180- auto core = ov::Core ();
181- std::shared_ptr<ov::Model> model = core. read_model (model_path );
184+ auto adapter = std::make_shared<OpenVINOInferenceAdapter> ();
185+ adapter-> loadModel (model_path, " " , {}, false );
182186
183- if (model->has_rt_info (" model_info" , " model_type" )) {
184- std::cout << " has model type in info: " << model->get_rt_info <std::string>(" model_info" , " model_type" )
185- << std::endl;
186- } else {
187- throw std::runtime_error (" Incorrect or unsupported model_type" );
188- }
187+ std::string model_type;
188+ model_type = utils::get_from_any_maps (" model_type" , adapter->getModelConfig (), {}, model_type);
189189
190- if (utils::model_has_embedded_processing (model)) {
191- std::cout << " model already was serialized" << std::endl;
192- } else {
193- Classification::serialize (model);
190+ if (model_type.empty () || model_type != " Classification" ) {
191+ throw std::runtime_error (" Incorrect or unsupported model_type, expected: Classification" );
194192 }
195- auto adapter = std::make_shared<OpenVINOInferenceAdapter>();
196- adapter->loadModel (model, core, " AUTO" );
193+ adapter->applyModelTransform (Classification::serialize);
194+ adapter->compileModel (" AUTO" , {});
195+
197196 return Classification (adapter);
198197}
199198
0 commit comments