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(
|
||||
|
||||
Reference in New Issue
Block a user