1 2 /** 3 * @file IHaasML.h 4 * @author HaasAI Group 5 * @version V1.0.0 6 * @date 2021-01-10 7 * @license GNU General Public License (GPL) 8 * @brief 9 * @attention 10 * This file is part of HaasAI. \n 11 * This program is free software; you can redistribute it and/or modify \n 12 * it under the terms of the GNU General Public License version 3 as \n 13 * published by the Free Software Foundation. \n 14 * You should have received a copy of the GNU General Public License \n 15 * along with HaasAI. If not, see <http://www.gnu.org/licenses/>. \n 16 * Unless required by applicable law or agreed to in writing, software \n 17 * distributed under the License is distributed on an "AS IS" BASIS, \n 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \n 19 * See the License for the specific language governing permissions and \n 20 * limitations under the License. \n 21 * \n 22 * @htmlonly 23 * <span style="font-weight: bold">History</span> 24 * @endhtmlonly 25 * Version|Author|Date|Describe 26 * ------|----|------|-------- 27 * V1.0|HaasAI Group|2021-01-10|Create File 28 * <h2><center>©COPYRIGHT 2021 WELLCASA All Rights Reserved.</center></h2> 29 */ 30 #ifndef IHAAS_ML_H 31 #define IHAAS_ML_H 32 #include "base/include/base/HaasCommonImage.h" 33 #include "base/include/base/HaasMLDef.h" 34 35 /** 36 * @brief Machine Learning Control Class 37 * @author HaasAI Group 38 */ 39 class IHaasML 40 { 41 public: ~IHaasML()42 virtual ~IHaasML(){} 43 44 /** 45 * @brief config http info(for ucloud AI) 46 * @param[in] key : OSS Access Key 47 * @param[in] secret : OSS Access secret 48 * @param[in] endpoint : The region id 49 * @param[in] bucket : OSS endpoint 50 * @param[in] url : for facebody compare AI model 51 * @note. 52 * @return 53 * 0 successfully \n 54 * -1 failed \n 55 * @par Sample 56 * @code 57 * IHaasML * mIHaasML = NULL; 58 * mIHaasML = IHaasMLInstance(); 59 * res_ res = 0; 60 * res = mIHaasML->Config(NULL,NULL,NULL,NULL,NULL); 61 * @endcode 62 */ Config(char * key,char * secret,char * endpoint,char * bucket,char * url)63 virtual int Config(char *key, char *secret, char *endpoint, 64 char *bucket, char *url) {} 65 /** 66 * @brief set input data(come frome HaasDataInput) 67 * @param[in] dataPath : The path of DataSource 68 * @note Notice that the dataPath is the full path. 69 * @return 70 * 0 successfully \n 71 * -1 failed \n 72 * @par Sample 73 * @code 74 * IHaasML * mIHaasML = NULL; 75 * mIHaasML = IHaasMLInstance(); 76 * char* dataPath = "/data/HaasAI/xxx" 77 * res_ res = 0; 78 * res = mIHaasML->SetInputData(dataPath.c_str()); 79 * @endcode 80 */ 81 virtual int SetInputData(const char* dataPath) = 0; 82 /** 83 * @brief Load AI mode object 84 * @param[in] modePath : The path of AI Mode 85 * @note Notice that the modePath is the full path. 86 * @return 87 * 0 successfully \n 88 * -1 failed \n 89 * @par Sample 90 * @code 91 * IHaasML * mIHaasML = NULL; 92 * mIHaasML = IHaasMLInstance(); 93 * char* modePath = "/data/HaasAI/aimode" 94 * res_ res = 0; 95 * res = mIHaasML->LoadNet(modePath.c_str()); 96 * @endcode 97 */ 98 virtual int LoadNet(const char* modePath) = 0; 99 /** 100 * @brief Start AI Predict 101 * @note 102 * @return 103 * 0 successfully \n 104 * -1 failed \n 105 * @par Sample 106 * @code 107 * IHaasML * mIHaasML = NULL; 108 * mIHaasML = IHaasMLInstance(); 109 * res_ res = 0; 110 * res = mIHaasML->Predict(); 111 * @endcode 112 */ 113 virtual int Predict() = 0; 114 /** 115 * @brief Get AI Predict Result 116 * @param[out] outResult : The result of Predict 117 * @param[int] len : The len of readBuffer 118 * @note 119 * @return 120 * 0 successfully \n 121 * -1 failed \n 122 * @par Sample 123 * @code 124 * IHaasML * mIHaasML = NULL; 125 * mIHaasML = IHaasMLInstance(); 126 * int res = 0; 127 * res = mIHaasML->getTrainResponses(); 128 * @endcode 129 */ 130 virtual int GetPredictResponses(char* outResult, int len) = 0; 131 /** 132 * @brief un load AI Predict mode obj 133 * @note 134 * @return 135 * 0 successfully \n 136 * -1 failed \n 137 * @par Sample 138 * @code 139 * IHaasML * mIHaasML = NULL; 140 * mIHaasML = IHaasMLInstance(); 141 * res_ res = 0; 142 * res = mIHaasML->UnLoadNet(); 143 * @endcode 144 */ 145 virtual int UnLoadNet() = 0; 146 }; 147 148 extern "C" { 149 /** 150 * @brief Get HaasML Instance 151 * @note NULL 152 * @return 153 * !0 successfully \n 154 * NULL failed \n 155 * @par Sample 156 * @code 157 * IHaasML * mHaasML = NULL; 158 * mHaasML = IHaasMLInstance(); 159 * @endcode 160 */ 161 IHaasML* IHaasMLInstance(MLEngineType_t type); 162 } 163 164 #endif 165