fix: graceful error when onnxruntime missing for .onnx models

This commit is contained in:
jetson committed 2026-09-18 10:40:30 +07:00
1 parent 1bc5e0634c
commit 06b013a778
1 file changed
+11
+11
View File
@@ -92,6 +92,17 @@ def run_pipeline(
effective_filter = class_filter or (
model_config.known_classes if model_config.known_classes else None
)
# Check onnxruntime for .onnx models
if model_config.path.endswith(".onnx"):
try:
import onnxruntime # noqa: F401
except ImportError:
raise RuntimeError(
f"onnxruntime is not installed. Cannot load .onnx model '{model_config.filename}'. "
f"Either install it (pip install onnxruntime) or use the .engine version of this model."
)
shared_model = YOLO(model_config.path)
detector = BaseDetector(
shared_model, conf=sack_conf, class_filter=effective_filter