mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:26:31 +00:00
make start faster
This commit is contained in:
@@ -11,13 +11,22 @@ from annotation cimport Detection, Annotation
|
||||
from ai_config cimport AIRecognitionConfig
|
||||
|
||||
cdef class Inference:
|
||||
def __init__(self, model_bytes, on_annotation):
|
||||
def __init__(self, api_client, on_annotation):
|
||||
self.api_client = api_client
|
||||
self.on_annotation = on_annotation
|
||||
self.stop_signal = False
|
||||
self.session = None
|
||||
self.model_input = None
|
||||
self.model_width = 0
|
||||
self.model_height = 0
|
||||
self.class_names = None
|
||||
self.ai_config = AIRecognitionConfig(4, 2, 0.25, 0.15, 15, 0.8, b'')
|
||||
|
||||
def init_ai(self):
|
||||
model_bytes = self.api_client.load_ai_model()
|
||||
self.session = onnx.InferenceSession(
|
||||
model_bytes, providers=["CUDAExecutionProvider", "CPUExecutionProvider"]
|
||||
)
|
||||
self.on_annotation = on_annotation
|
||||
self.ai_config = AIRecognitionConfig(4, 2, 0.25, 0.15, 15, 0.8, b'')
|
||||
model_inputs = self.session.get_inputs()
|
||||
self.model_input = model_inputs[0].name
|
||||
input_shape = model_inputs[0].shape
|
||||
@@ -38,7 +47,6 @@ cdef class Inference:
|
||||
for frame in frames]
|
||||
return np.vstack(blobs)
|
||||
|
||||
|
||||
cdef postprocess(self, output):
|
||||
cdef list[Detection] detections = []
|
||||
cdef int ann_index
|
||||
@@ -112,6 +120,8 @@ cdef class Inference:
|
||||
|
||||
self.ai_config = AIRecognitionConfig.from_msgpack(cmd.data)
|
||||
self.stop_signal = False
|
||||
if self.session is None:
|
||||
self.init_ai()
|
||||
|
||||
for m in medias:
|
||||
if self.is_video(m):
|
||||
|
||||
Reference in New Issue
Block a user