mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:36:30 +00:00
add loader and versioning
This commit is contained in:
@@ -58,28 +58,39 @@ cdef class Inference:
|
||||
self.is_building_engine = False
|
||||
|
||||
cdef build_tensor_engine(self, object updater_callback):
|
||||
if not tensor_gpu_index == -1:
|
||||
if tensor_gpu_index == -1:
|
||||
return
|
||||
|
||||
engine_filename = TensorRTEngine.get_engine_filename(0)
|
||||
models_dir = constants.MODELS_FOLDER
|
||||
try:
|
||||
engine_filename = TensorRTEngine.get_engine_filename(0)
|
||||
models_dir = constants.MODELS_FOLDER
|
||||
|
||||
self.is_building_engine = True
|
||||
updater_callback('downloading')
|
||||
self.is_building_engine = True
|
||||
updater_callback('downloading')
|
||||
|
||||
if self.loader_client.load_big_small_resource(engine_filename, models_dir):
|
||||
print('tensor rt engine is here, no need to build')
|
||||
res = self.loader_client.load_big_small_resource(engine_filename, models_dir)
|
||||
if res.err is None:
|
||||
print('tensor rt engine is here, no need to build')
|
||||
self.is_building_engine = False
|
||||
return
|
||||
|
||||
print(res.err)
|
||||
# time.sleep(8) # prevent simultaneously loading dll and models
|
||||
updater_callback('converting')
|
||||
print('try to load onnx')
|
||||
res = self.loader_client.load_big_small_resource(constants.AI_ONNX_MODEL_FILE, models_dir)
|
||||
if res.err is not None:
|
||||
updater_callback(f'Error. {res.err}')
|
||||
model_bytes = TensorRTEngine.convert_from_onnx(res.data)
|
||||
updater_callback('uploading')
|
||||
res = self.loader_client.upload_big_small_resource(model_bytes, <str> engine_filename, models_dir)
|
||||
if res.err is not None:
|
||||
updater_callback(f'Error. {res.err}')
|
||||
print(f'uploaded {engine_filename} to CDN and API')
|
||||
self.is_building_engine = False
|
||||
return
|
||||
|
||||
# time.sleep(8) # prevent simultaneously loading dll and models
|
||||
updater_callback('converting')
|
||||
onnx_model = self.loader_client.load_big_small_resource(constants.AI_ONNX_MODEL_FILE, models_dir)
|
||||
model_bytes = TensorRTEngine.convert_from_onnx(onnx_model)
|
||||
updater_callback('uploading')
|
||||
self.loader_client.upload_big_small_resource(model_bytes, <str> engine_filename, models_dir)
|
||||
print(f'uploaded {engine_filename} to CDN and API')
|
||||
self.is_building_engine = False
|
||||
updater_callback('enabled')
|
||||
except Exception as e:
|
||||
updater_callback(f'Error. {str(e)}')
|
||||
|
||||
cdef init_ai(self):
|
||||
if self.engine is not None:
|
||||
|
||||
Reference in New Issue
Block a user