Support ai-edge-litert as TFLite runtime
tflite-runtime has no wheels for Python 3.12+. Google replaced it with ai-edge-litert (same API). detector.py now tries ai-edge-litert first, falls back to tflite-runtime for older Python versions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -54,13 +54,18 @@ class ObjectDetector:
|
||||
|
||||
def _load_model(self):
|
||||
"""Load TFLite model and label map"""
|
||||
# Try ai-edge-litert (modern), then tflite-runtime (legacy)
|
||||
try:
|
||||
import tflite_runtime.interpreter as tflite
|
||||
from ai_edge_litert import interpreter as tflite
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"tflite-runtime not installed. "
|
||||
"Install with: pip install tflite-runtime"
|
||||
)
|
||||
try:
|
||||
import tflite_runtime.interpreter as tflite
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"No TFLite runtime found. Install one of:\n"
|
||||
" pip install ai-edge-litert (Python 3.12+)\n"
|
||||
" pip install tflite-runtime (Python 3.9-3.11)"
|
||||
)
|
||||
|
||||
if not self.model_path.exists():
|
||||
raise FileNotFoundError(
|
||||
|
||||
@@ -14,4 +14,5 @@ python-dotenv>=1.0.0
|
||||
httpx>=0.24.0
|
||||
|
||||
# Object detection (installed separately by setup.sh)
|
||||
# tflite-runtime>=2.14.0
|
||||
# pip install ai-edge-litert (Python 3.12+)
|
||||
# pip install tflite-runtime (Python 3.9-3.11)
|
||||
|
||||
@@ -92,7 +92,9 @@ pip install -r requirements.txt
|
||||
|
||||
# Install TFLite runtime for object detection
|
||||
echo_info "Installing TFLite runtime for object detection..."
|
||||
pip install tflite-runtime 2>/dev/null || echo_warn "tflite-runtime not available for this platform (object detection will be disabled)"
|
||||
pip install ai-edge-litert 2>/dev/null || \
|
||||
pip install tflite-runtime 2>/dev/null || \
|
||||
echo_warn "No TFLite runtime available for this platform (object detection will be disabled)"
|
||||
|
||||
# Generate SSL certificates if not present
|
||||
if [ ! -f ssl/cert.pem ]; then
|
||||
|
||||
Reference in New Issue
Block a user