Skip to content

Commit f9ac4f4

Browse files
committed
Cover anomaly
1 parent 43152fc commit f9ac4f4

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/cpp/src/tasks/anomaly.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
#include "utils/tensor.h"
66

77
void Anomaly::serialize(std::shared_ptr<ov::Model>& ov_model) {
8+
if (utils::model_has_embedded_processing(ov_model)) {
9+
std::cout << "model already was serialized" << std::endl;
10+
return;
11+
}
12+
813
auto input = ov_model->inputs().front();
914

1015
auto layout = ov::layout::get_layout(input);
@@ -47,23 +52,21 @@ void Anomaly::serialize(std::shared_ptr<ov::Model>& ov_model) {
4752
}
4853

4954
Anomaly Anomaly::load(const std::string& model_path) {
50-
auto core = ov::Core();
51-
std::shared_ptr<ov::Model> model = core.read_model(model_path);
55+
auto adapter = std::make_shared<OpenVINOInferenceAdapter>();
56+
adapter->loadModelFile(model_path, "", {}, false);
57+
58+
std::string model_type;
59+
model_type = utils::get_from_any_maps("model_type", adapter->getModelConfig(), {}, model_type);
5260

53-
if (model->has_rt_info("model_info", "model_type")) {
54-
std::cout << "has model type in info: " << model->get_rt_info<std::string>("model_info", "model_type")
55-
<< std::endl;
61+
if (!model_type.empty()) {
62+
std::cout << "has model type in info: " << model_type << std::endl;
5663
} else {
5764
throw std::runtime_error("Incorrect or unsupported model_type");
5865
}
5966

60-
if (utils::model_has_embedded_processing(model)) {
61-
std::cout << "model already was serialized" << std::endl;
62-
} else {
63-
serialize(model);
64-
}
65-
auto adapter = std::make_shared<OpenVINOInferenceAdapter>();
66-
adapter->loadModel(model, core, "AUTO");
67+
adapter->applyModelTransform(Anomaly::serialize);
68+
adapter->compileModel("AUTO", {});
69+
6770
return Anomaly(adapter);
6871
}
6972

0 commit comments

Comments
 (0)