From 904bc688ca83b6e07da981d9fa3724c93b4872c1 Mon Sep 17 00:00:00 2001 From: Alex Bezdieniezhnykh Date: Wed, 11 Jun 2025 07:23:14 +0300 Subject: [PATCH] fix inference bug in loading model --- Azaion.Inference/azaion-inference.spec | 2 +- Azaion.Inference/inference.pyx | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Azaion.Inference/azaion-inference.spec b/Azaion.Inference/azaion-inference.spec index dc49315..c10262e 100644 --- a/Azaion.Inference/azaion-inference.spec +++ b/Azaion.Inference/azaion-inference.spec @@ -4,7 +4,7 @@ from PyInstaller.utils.hooks import collect_all datas = [('venv\\Lib\\site-packages\\cv2', 'cv2')] binaries = [] -hiddenimports = ['constants', 'file_data', 'loader_client', 'remote_command', 'remote_command_handler', 'annotation', 'loader_client', 'ai_config', 'tensorrt_engine', 'onnx_engine', 'inference_engine', 'inference', 'main-inf'] +hiddenimports = ['constants', 'file_data', 'remote_command', 'remote_command_handler', 'annotation', 'loader_client', 'ai_config', 'tensorrt_engine', 'onnx_engine', 'inference_engine', 'inference', 'main-inf'] hiddenimports += collect_submodules('cv2') tmp_ret = collect_all('psutil') datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2] diff --git a/Azaion.Inference/inference.pyx b/Azaion.Inference/inference.pyx index 2908c75..a781642 100644 --- a/Azaion.Inference/inference.pyx +++ b/Azaion.Inference/inference.pyx @@ -102,11 +102,15 @@ cdef class Inference: time.sleep(1) engine_filename = TensorRTEngine.get_engine_filename(0) - model_bytes = self.loader_client.load_big_small_resource(engine_filename, models_dir) - self.engine = TensorRTEngine(model_bytes) + res = self.loader_client.load_big_small_resource(engine_filename, models_dir) + if res.err is not None: + raise Exception(res.err) + self.engine = TensorRTEngine(res.data) else: - model_bytes = self.loader_client.load_big_small_resource(constants.AI_ONNX_MODEL_FILE, models_dir) - self.engine = OnnxEngine(model_bytes) + res = self.loader_client.load_big_small_resource(constants.AI_ONNX_MODEL_FILE, models_dir) + if res.err is not None: + raise Exception(res.err) + self.engine = OnnxEngine(res.data) self.model_height, self.model_width = self.engine.get_input_shape()