DaoAI World C++ SDK
Loading...
Searching...
No Matches
model.h
1#pragma once
2#include "API_EXPORT.h"
3#include <string>
4#include "common.h"
5#include "prediction.h"
6
7namespace DaoAI
8{
9
10 namespace DeepLearning
11 {
12 enum class ModelType
13 {
14 Object_Detection, Classification, Anomaly_Detection, OCR, Semantic_Segmentation
15 };
16
17 enum DetectionTask
18 {
19 Unknown = 0, Bounding_Box = 1, Instance_Segmentation = 2, Keypoint = 4, Rotated_Box = 8
20 };
21
22 class BaseModel;
23
24 // Initialize DaoAI Deep Learning SDK
25 DAOAI_API void initialize();
26
33 DAOAI_API bool checkDaoAIModelValidity(const std::string& model_config_path, const std::string& model_weights_path);
34
40 DAOAI_API bool checkDaoAIModelValidity(const std::string& model_path);
41
46 DAOAI_API int getNumCUDADevices();
47
49 {
50 public:
51 ModelType model_type;
52 Device_Type device;
53 std::vector<std::string> class_labels;
54 std::vector<int> num_keypoints;
55 DetectionTask tasks;
56 };
57
58 class Model
59 {
60 public:
64 DAOAI_API Model();
65 DAOAI_API ~Model();
66
73 DAOAI_API void load(const std::string& model_config_path, const std::string& model_weights_path, const DaoAI::DeepLearning::Device_Type& device = Device_Type::GPU, const int& device_idx = -1);
74
81 DAOAI_API void load(const std::string& model_directory, const DaoAI::DeepLearning::Device_Type& device = Device_Type::GPU, const int& device_idx = -1);
82
89 DAOAI_API void loadZip(const std::string& model_zip_path, const DaoAI::DeepLearning::Device_Type& device = Device_Type::GPU, const int& device_idx = -1);
90
97 DAOAI_API void loadNestedZip(const std::string& model_zip_path, const DaoAI::DeepLearning::Device_Type& device = Device_Type::GPU, const int& device_idx = -1);
98
102 DAOAI_API void unload();
103
109 DAOAI_API Prediction inference(const Image& input_image);
110
116 DAOAI_API std::string inferenceJSON(const Image& input_image);
117
118 DAOAI_API ModelInfo getModelInfo();
119
120
121 private:
122 std::string model_root_path_ = "";
123 std::string model_config_path_ = "";
124 std::string model_weights_path_ = "";
125 Device_Type device_ = Device_Type::GPU;
126 int gpu_index_ = -1;
127 int instance_index_;
128 std::unique_ptr<BaseModel> model_ptr_ = nullptr;
129 };
130 }
131}
Definition common.h:133
Definition model.h:59
DAOAI_API std::string inferenceJSON(const Image &input_image)
DAOAI_API Prediction inference(const Image &input_image)
DAOAI_API void load(const std::string &model_config_path, const std::string &model_weights_path, const DaoAI::DeepLearning::Device_Type &device=Device_Type::GPU, const int &device_idx=-1)
DAOAI_API void load(const std::string &model_directory, const DaoAI::DeepLearning::Device_Type &device=Device_Type::GPU, const int &device_idx=-1)
DAOAI_API void unload()
DAOAI_API void loadNestedZip(const std::string &model_zip_path, const DaoAI::DeepLearning::Device_Type &device=Device_Type::GPU, const int &device_idx=-1)
Load the nested zip model onto the designated device.
DAOAI_API void loadZip(const std::string &model_zip_path, const DaoAI::DeepLearning::Device_Type &device=Device_Type::GPU, const int &device_idx=-1)
Load the zip model onto the designated device.
Definition model.h:49
Definition prediction.h:27