Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
40 changes: 40 additions & 0 deletions src/client/python/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,46 @@ def compute_model_hash():
return _cached_model_hash


def set_model_config(tflite_subdir=None, input_size=None):
"""Override the model directory and/or input resolution before startup.

Used by the benchmark client variants to sweep models/resolutions from the
command line. When a TFLite subdirectory is given, the submodel prefix and
last offloading layer are auto-detected from its ``*.tflite`` files. Any
cache derived from the previous model/resolution is invalidated so that the
next call rebuilds it.
"""
global TFLITE_DIR, SUBMODEL_PREFIX, LAST_OFFLOADING_LAYER
global INPUT_HEIGHT, INPUT_WIDTH
global _interpreter_cache, _cached_model_hash, _cached_image_rgb
global _cached_rgb565_buffer, _send_image_buffer

if tflite_subdir is not None:
TFLITE_DIR = SCRIPT_DIR / tflite_subdir
tflite_files = sorted(TFLITE_DIR.glob("*.tflite"))
if tflite_files:
SUBMODEL_PREFIX = tflite_files[0].stem.rsplit("_", 1)[0]
LAST_OFFLOADING_LAYER = len(tflite_files) - 1
print(f"🔍 Detected submodel prefix: {SUBMODEL_PREFIX}")
print(
f"📊 Detected layers: {len(tflite_files)} "
f"(last offloading layer: {LAST_OFFLOADING_LAYER})"
)
else:
print(f"❌ WARNING: TFLite folder is empty: {TFLITE_DIR}")

if input_size is not None:
INPUT_HEIGHT = input_size
INPUT_WIDTH = input_size

# Invalidate caches derived from the previous model/resolution.
_interpreter_cache = {}
_cached_model_hash = None
_cached_image_rgb = None
_cached_rgb565_buffer = None
_send_image_buffer = None


# -----
# MAIN
# -----
Expand Down
Loading
Loading