7AisDeployCVersion=
"v0.3.3b"
11 AisDeployC python接口类 AisDeployC
15 """! The AisDeployC class initializer.
19 lib_path = "./cmake-build-release/AisDeployC.dll"
20 deploy_obj = AisDeployC(lib_path)
22 @param lib_pth AisDeployC library path.
23 @return An instance of the AisDeployC class initialized.
26 if "macOS" in platform.platform():
27 self.
lib = ctypes.cdll.LoadLibrary(lib_pth)
28 elif "Windows" in platform.platform():
29 self.
lib = ctypes.windll.LoadLibrary(lib_pth)
30 elif "Linux" in platform.platform():
31 self.
lib = ctypes.cdll.LoadLibrary(lib_pth)
35 """! The AisDeployC class delete function.
38 self.
lib.release.argtypes = [ctypes.c_void_p]
42 """! The AisDeployC class model initializer.
46 path_str = "tests/assets/models/det_setting_oen.aism"
48 ret = deploy_obj.model_initialize(path_str, gpu_id)
50 @param path_str model file path.
51 @param gpu_id gpu id for model initialize
52 @return model_initialize result, 0 for success, 1 for failure.
55 self.
lib.initialize.restype = ctypes.c_void_p
56 ret = ctypes.c_int(-1)
57 gpu_id = ctypes.c_int(gpu_id)
59 path_char = ctypes.c_char_p(path_str.encode(
'utf-8'))
62 self.
lib.update_license.argtypes = [ctypes.c_void_p, ctypes.c_char_p]
63 self.
lib.generate_license.argtypes = [ctypes.c_void_p]
64 self.
lib.py_process_json_str.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_int]
65 self.
lib.py_get_json_str_results.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_char_p), ctypes.POINTER(ctypes.c_int)]
66 self.
lib.py_free_result.argtypes = [ctypes.c_char_p]
67 self.
lib.release.argtypes = [ctypes.c_void_p]
68 self.
lib.py_load_keys_embeddings.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_int]
69 self.
lib.py_load_keys_embeddings.restype = ctypes.c_int
70 self.
lib.py_compare_with_ground_embeddings.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_int, ctypes.POINTER(ctypes.c_char_p), ctypes.POINTER(ctypes.c_int)]
71 self.
lib.py_process_decoder.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_int, ctypes.POINTER(ctypes.c_char_p), ctypes.POINTER(ctypes.c_int)]
76 """! The AisDeployC class license generate function.
80 ret = deploy_obj.generate_license()
82 @return generate_license result, 0 for success, 1 for failure.
87 """! The AisDeployC class license update function.
91 license_path = "tests/assets/licenses/registed/windows_registed_info.aisl"
92 ret = deploy_obj.update_license(license_path)
95 @param path_str license file path.
96 @return update_license result, 0 for success, 1 for failure.
98 path_char = ctypes.c_char_p(path_str.encode(
'utf-8'))
102 """! The AisDeployC class process function.
109 imgPth = "tests/assets/images/1.jpg"
110 f= open(imgPth, 'rb')
111 qrcode = base64.b64encode(f.read()).decode()
113 file_json = {"type": "base64", "data": qrcode, "ch":3}
114 input_json = {"data_list": [file_json]}
116 ret_val = deploy_obj.process(input_json)
124 imgPth = "tests/assets/images/1.jpg"
125 f= open(imgPth, 'rb')
126 qrcode = base64.b64encode(f.read()).decode()
128 file_json = {"type": "base64", "data": qrcode, "ch":3}
129 input_json = {"data_list": [file_json]}
131 imgPth = "tests/assets/images/63_1024.jpg"
132 f= open(imgPth, 'rb')
133 qrcode = base64.b64encode(f.read()).decode()
135 file_json = {"type": "base64", "data": qrcode, "ch":3}
136 input_json["data_list"].append(file_json)
138 ret_val = deploy_obj.process(input_json)
141 @param input_json input json like dict.
142 @return process result, output_json output json like dict. for success, None for failure.
145 print(
"[ERROR] Check handle failed in AisDeployC.process. maybe lack initialization.")
147 data_str = json.dumps(input_json)
148 data_char = ctypes.c_char_p(data_str.encode(
'utf-8'))
151 print(
"[ERROR] py_process_json_str failed in AisDeployC. maybe check input of process.")
153 ret_char_c = ctypes.c_char_p()
156 print(
"[ERROR] py_get_json_str_results failed in AisDeployC. maybe lack py_process_json_str.")
158 ret_str = ret_char_c.value.decode(
"utf-8")
159 ret_value = json.loads(ret_str)
165 print(
"[ERROR] Check handle failed in AisDeployC.process_decoder. maybe lack initialization.")
167 data_str = json.dumps(input_json)
168 data_char = ctypes.c_char_p(data_str.encode(
'utf-8'))
169 ret_char_c = ctypes.c_char_p()
172 print(
"[ERROR] py_process_decoder failed in AisDeployC. maybe check input of process_decoder.")
174 ret_str = ret_char_c.value.decode(
"utf-8")
175 ret_value = json.loads(ret_str)
180 """! The AisDeployC class load_keys_embeddings function.
187 file_json = {"key": key, "embedding_vector":value}
188 input_json = {"data_list": [file_json]}
190 ret_val = deploy_obj.load_keys_embeddings(input_json)
193 @param input_json input json like dict.
194 @return process result, 0 for success, 1 for failure.
197 print(
"[ERROR] Check handle failed in AisDeployC.process. maybe lack initialization.")
200 data_str = json.dumps(input_json)
201 data_char = ctypes.c_char_p(data_str.encode(
'utf-8'))
203 ret = self.
lib.py_load_keys_embeddings(self.
handle, data_char, len(data_str))
205 print(
"[ERROR] load_keys_embeddings failed in AisDeployC. maybe check input of process.")
210 """! The AisDeployC class compare_with_ground_embeddings function.
216 file_json = {"embedding_vector":value}
217 input_json = {"data_list": [file_json]}
219 ret_val = deploy_obj.process(input_json)
222 @param input_json input json like dict.
223 @return process result, output_json output json like dict. for success, None for failure.
226 print(
"[ERROR] Check handle failed in AisDeployC.process. maybe lack initialization.")
228 data_str = json.dumps(input_json)
229 data_char = ctypes.c_char_p(data_str.encode(
'utf-8'))
230 ret_char_c = ctypes.c_char_p()
233 print(
"[ERROR] compare_with_ground_embeddings failed in AisDeployC. maybe check input of process.")
235 ret_str = ret_char_c.value.decode(
"utf-8")
236 ret_value = json.loads(ret_str)
process(self, dict input_json)
The AisDeployC class process function.
update_license(self, str path_str)
The AisDeployC class license update function.
__init__(self, str lib_pth)
The AisDeployC class initializer.
load_keys_embeddings(self, dict input_json)
The AisDeployC class load_keys_embeddings function.
compare_with_ground_embeddings(self, dict input_json)
The AisDeployC class compare_with_ground_embeddings function.
process_decoder(self, dict input_json)
__del__(self)
The AisDeployC class delete function.
generate_license(self)
The AisDeployC class license generate function.
model_initialize(self, str path_str, int gpu_id)
The AisDeployC class model initializer.
AisDeployC_API int py_get_json_str_results(void *base, char **output, int *output_size)
python使用的获取json string输出格式的接口
AisDeployC_API int release(void *base)
释放实例
AisDeployC_API int py_free_result(char *output)
python使用的释放返回结果的接口
AisDeployC_API int py_compare_with_ground_embeddings(void *base, const char *input, int input_size, char **output, int *output_size)
python使用的批量 字段 和 特征嵌入 对,与底库中特征嵌入做比对,json string输入格式的接口,json string输出格式的接口
AisDeployC_API int py_process_json_str(void *base, const char *input, int input_size)
python使用的处理json string输入格式的接口
AisDeployC_API void * initialize(const char *model_path, int gpu_id, int *state)
模型初始化
AisDeployC_API int py_process_decoder(void *base, const char *input, int input_size, char **output, int *output_size)
python使用的解码器处理接口,输入特征嵌入和提示prompt,json string输入格式的接口,json string输出格式的接口