Refactor inference and AI configuration handling

- Updated the `Inference` class to replace the `get_onnx_engine_bytes` method with `download_model`, allowing for dynamic model loading based on a specified filename.
- Modified the `convert_and_upload_model` method to accept `source_bytes` instead of `onnx_engine_bytes`, enhancing flexibility in model conversion.
- Introduced a new property `engine_name` to the `Inference` class for better access to engine details.
- Adjusted the `AIRecognitionConfig` structure to include a new method pointer `from_dict`, improving configuration handling.
- Updated various test cases to reflect changes in model paths and timeout settings, ensuring consistency and reliability in testing.
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-03-30 00:22:56 +03:00
parent 6269a7485c
commit 27f4aceb52
25 changed files with 40974 additions and 6172 deletions
+31 -27
View File
@@ -1,5 +1,7 @@
import io
import json
import os
import struct
from pathlib import Path
import pytest
@@ -10,34 +12,36 @@ _EPS = 1e-6
_WEATHER_CLASS_STRIDE = 20
def _jpeg_width_height(data):
if len(data) < 2 or data[0:2] != b"\xff\xd8":
return None
i = 2
while i + 1 < len(data):
if data[i] != 0xFF:
def _image_width_height(data):
if len(data) >= 24 and data[:8] == b"\x89PNG\r\n\x1a\n":
w, h = struct.unpack(">II", data[16:24])
return w, h
if len(data) >= 2 and data[:2] == b"\xff\xd8":
i = 2
while i + 1 < len(data):
if data[i] != 0xFF:
i += 1
continue
i += 1
continue
i += 1
while i < len(data) and data[i] == 0xFF:
while i < len(data) and data[i] == 0xFF:
i += 1
if i >= len(data):
break
m = data[i]
i += 1
if i >= len(data):
break
m = data[i]
i += 1
if m in (0xD8, 0xD9):
continue
if i + 3 > len(data):
break
seg_len = (data[i] << 8) | data[i + 1]
i += 2
if m in (0xC0, 0xC1, 0xC2, 0xC3, 0xC5, 0xC6, 0xC7):
if i + 5 > len(data):
return None
h = (data[i + 1] << 8) | data[i + 2]
w = (data[i + 3] << 8) | data[i + 4]
return w, h
i += max(0, seg_len - 2)
if m in (0xD8, 0xD9):
continue
if i + 3 > len(data):
break
seg_len = (data[i] << 8) | data[i + 1]
i += 2
if m in (0xC0, 0xC1, 0xC2, 0xC3, 0xC5, 0xC6, 0xC7):
if i + 5 > len(data):
return None
h = (data[i + 1] << 8) | data[i + 2]
w = (data[i + 3] << 8) | data[i + 4]
return w, h
i += max(0, seg_len - 2)
return None
@@ -161,7 +165,7 @@ def test_ft_p_06_overlap_deduplication_ac3(http_client, image_dense, warm_engine
@pytest.mark.slow
def test_ft_p_07_physical_size_filtering_ac4(http_client, image_small, warm_engine):
by_id, _ = _load_classes_media()
wh = _jpeg_width_height(image_small)
wh = _image_width_height(image_small)
assert wh is not None
image_width_px, _ = wh
altitude = 400.0