#pragma once #include #include #include #include /* * This interface must provide only required arguments to load any onnx model regarding specific info - * - i.e. modelPath will always be required, provider like "cpu" or "cuda" the same, since these are parameters you need * to set up `sessionOptions` or `session` objects properly, but image size is not needed for pure onnx graph to be loaded so do NOT include it here */ class OnnxModelBase { public: OnnxModelBase(const char* modelPath, const char* logid, const char* provider); //OnnxModelBase(); // no default constructor should be there //virtual ~OnnxModelBase(); virtual const std::vector& getInputNames(); // = 0 virtual const std::vector& getOutputNames(); virtual const std::vector getOutputNamesCStr(); virtual const std::vector getInputNamesCStr(); virtual const Ort::ModelMetadata& getModelMetadata(); virtual const std::unordered_map& getMetadata(); virtual const char* getModelPath(); virtual const Ort::Session& getSession(); //virtual std::vector forward(std::vector inputTensors); virtual std::vector forward(std::vector& inputTensors); Ort::Session session{ nullptr }; protected: const char* modelPath_; Ort::Env env{ nullptr }; std::vector inputNodeNames; std::vector outputNodeNames; Ort::ModelMetadata model_metadata{ nullptr }; std::unordered_map metadata; std::vector outputNamesCStr; std::vector inputNamesCStr; };