Skip to content

Commit 43152fc

Browse files
committed
Cover detection
1 parent b39541e commit 43152fc

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/cpp/src/tasks/detection.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,19 @@
1212
#include "utils/tensor.h"
1313

1414
DetectionModel DetectionModel::load(const std::string& model_path, const ov::AnyMap& configuration) {
15-
auto core = ov::Core();
16-
std::shared_ptr<ov::Model> model = core.read_model(model_path);
15+
auto adapter = std::make_shared<OpenVINOInferenceAdapter>();
16+
adapter->loadModelFile(model_path, "", {}, false);
1717

18-
if (model->has_rt_info("model_info", "model_type")) {
19-
std::cout << "has model type in info: " << model->get_rt_info<std::string>("model_info", "model_type")
20-
<< std::endl;
21-
} else {
22-
throw std::runtime_error("Incorrect or unsupported model_type");
23-
}
18+
std::string model_type;
19+
model_type = utils::get_from_any_maps("model_type", adapter->getModelConfig(), {}, model_type);
20+
transform(model_type.begin(), model_type.end(), model_type.begin(), ::tolower);
2421

25-
if (utils::model_has_embedded_processing(model)) {
26-
std::cout << "model already was serialized" << std::endl;
27-
} else {
28-
SSD::serialize(model);
22+
if (model_type.empty() || model_type != "ssd") {
23+
throw std::runtime_error("Incorrect or unsupported model_type, expected: ssd");
2924
}
30-
auto adapter = std::make_shared<OpenVINOInferenceAdapter>();
31-
adapter->loadModel(model, core, "AUTO");
25+
adapter->applyModelTransform(SSD::serialize);
26+
adapter->compileModel("AUTO", {});
27+
3228
return DetectionModel(std::make_unique<SSD>(adapter), configuration);
3329
}
3430

src/cpp/src/tasks/detection/ssd.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ std::map<std::string, ov::Tensor> SSD::preprocess(cv::Mat image) {
6868
}
6969

7070
void SSD::serialize(std::shared_ptr<ov::Model> ov_model) {
71+
if (utils::model_has_embedded_processing(ov_model)) {
72+
std::cout << "model already was serialized" << std::endl;
73+
return;
74+
}
7175
auto output_mode = ov_model->outputs().size() > 1 ? SSDOutputMode::multi : SSDOutputMode::single;
7276

7377
auto input_tensor = ov_model->inputs()[0];

0 commit comments

Comments
 (0)