Using supervision with onnxruntime #1626
-
Search before asking
QuestionHi, def callback(frame: np.ndarray, _: int) -> np.ndarray:
onnx_model_path = "./yolo11n.onnx"
session = ort.InferenceSession(onnx_model_path, providers=['CPUExecutionProvider'])
input_tensor = preprocess(frame) # do something here?
outputs = session.run(None, {"images": input_tensor})
detections = postprocess(outputs) # do something here?
detections = tracker.update_with_detections(detections)
sv.process_video(source_path="people-walking.mp4", target_path="result.mp4", callback=callback) I couldn't use torch / ultralytics because I had to run inference on edge device and it was too heavy. Thanks! AdditionalNo response |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
@acode-x 👋 Hello, We don't have onnxruntime yet to be supported but for edge cases I understand you wanted to be minimal, I made a rather small collab for you to run onnxruntime with supervision I hope you enjoy https://colab.research.google.com/drive/1eDM_MFuMgvb3znAXq31GtwQHYHPcNaL6?usp=sharing PS : I used yolov11 but If you want to use yolov8 it should also work without any code. change as well. Good luck ! :) |
Beta Was this translation helpful? Give feedback.
-
Thank you so much @onuralpszr I also tried below object tracking tutorial using the same YOLO11 class you provided: https://supervision.roboflow.com/develop/notebooks/count-objects-crossing-the-line/#run-object-detection https://colab.research.google.com/drive/1hEfzobxNHGNsfP97Iz8_D3LHoD9hGpij?usp=sharing |
Beta Was this translation helpful? Give feedback.
-
Btw please select as answer for my first reply for your main question as well |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for your quick support! Object tracker is also working now. |
Beta Was this translation helpful? Give feedback.
-
Hello @onuralpszr, Just curious if I can reuse same implementation. |
Beta Was this translation helpful? Give feedback.
@acode-x 👋 Hello, We don't have onnxruntime yet to be supported but for edge cases I understand you wanted to be minimal, I made a rather small collab for you to run onnxruntime with supervision I hope you enjoy
https://colab.research.google.com/drive/1eDM_MFuMgvb3znAXq31GtwQHYHPcNaL6?usp=sharing
PS : I used yolov11 but If you want to use yolov8 it should also work without any code. change as well. Good luck ! :)