99#include < memory>
1010#include < string>
1111
12+ #include " adapters/inference_adapter.h"
1213#include " models/input_data.h"
13- #include " models/model_base.h"
14+ #include " models/results.h"
15+ #include " utils/args_helper.hpp"
1416#include " utils/image_utils.h"
17+ #include " utils/ocv_common.hpp"
1518
1619namespace ov {
1720class InferRequest ;
@@ -20,22 +23,37 @@ struct InputData;
2023struct InternalModelData ;
2124
2225// ImageModel implements preprocess(), ImageModel's direct or indirect children are expected to implement prostprocess()
23- class ImageModel : public ModelBase {
26+ class BaseModel {
2427public:
2528 // / Constructor
2629 // / @param modelFile name of model to load
2730 // / @param useAutoResize - if true, image is resized by openvino
2831 // / @param layout - model input layout
29- ImageModel (const std::string& modelFile,
30- const std::string& resize_type,
31- bool useAutoResize,
32- const std::string& layout = " " );
32+ BaseModel (const std::string& modelFile,
33+ const std::string& resize_type,
34+ bool useAutoResize,
35+ const std::string& layout = " " );
3336
34- ImageModel (std::shared_ptr<ov::Model>& model, const ov::AnyMap& configuration);
35- ImageModel (std::shared_ptr<InferenceAdapter>& adapter, const ov::AnyMap& configuration = {});
36- using ModelBase::ModelBase;
37+ BaseModel (std::shared_ptr<ov::Model>& model, const ov::AnyMap& configuration);
38+ BaseModel (std::shared_ptr<InferenceAdapter>& adapter, const ov::AnyMap& configuration = {});
39+
40+ virtual std::shared_ptr<InternalModelData> preprocess (const InputData& inputData, InferenceInput& input);
41+ virtual std::unique_ptr<ResultBase> postprocess (InferenceResult& infResult) = 0;
42+
43+ void load (ov::Core& core, const std::string& device, size_t num_infer_requests = 1 );
44+
45+ std::shared_ptr<ov::Model> prepare ();
46+
47+ virtual size_t getNumAsyncExecutors () const ;
48+ virtual bool isReady ();
49+ virtual void awaitAll ();
50+ virtual void awaitAny ();
51+ virtual void setCallback (
52+ std::function<void (std::unique_ptr<ResultBase>, const ov::AnyMap& callback_args)> callback);
53+
54+ std::shared_ptr<ov::Model> getModel ();
55+ std::shared_ptr<InferenceAdapter> getInferenceAdapter ();
3756
38- std::shared_ptr<InternalModelData> preprocess (const InputData& inputData, InferenceInput& input) override ;
3957 static std::vector<std::string> loadLabels (const std::string& labelFilename);
4058 std::shared_ptr<ov::Model> embedProcessing (std::shared_ptr<ov::Model>& model,
4159 const std::string& inputName,
@@ -54,7 +72,7 @@ class ImageModel : public ModelBase {
5472
5573protected:
5674 RESIZE_MODE selectResizeMode (const std::string& resize_type);
57- void updateModelInfo () override ;
75+ virtual void updateModelInfo ();
5876 void init_from_config (const ov::AnyMap& top_priority, const ov::AnyMap& mid_priority);
5977
6078 std::string getLabelName (size_t labelID) {
@@ -73,4 +91,18 @@ class ImageModel : public ModelBase {
7391 bool reverse_input_channels = false ;
7492 std::vector<float > scale_values;
7593 std::vector<float > mean_values;
94+
95+ protected:
96+ virtual void prepareInputsOutputs (std::shared_ptr<ov::Model>& model) = 0;
97+
98+ InputTransform inputTransform = InputTransform();
99+
100+ std::shared_ptr<ov::Model> model;
101+ std::vector<std::string> inputNames;
102+ std::vector<std::string> outputNames;
103+ std::string modelFile;
104+ std::shared_ptr<InferenceAdapter> inferenceAdapter;
105+ std::map<std::string, ov::Layout> inputsLayouts;
106+ ov::Layout getInputLayout (const ov::Output<ov::Node>& input);
107+ std::function<void (std::unique_ptr<ResultBase>, const ov::AnyMap&)> lastCallback;
76108};
0 commit comments