Files
HSAP/algorithms/dms_yolo/code.embedded.bak/examples/YOLOv8-OpenCV-ONNX-Python/README.md
Chengfang Lu e72bc061c5 feat: HSAP platform v2 — modular navigation, quality review, audit log, world model simulation
Major changes:
- New frontend (platform/web/): Vite + React 18 + TypeScript + Tailwind
- 4-module navigation: 数据送标 / 模型管理 / 车队管理 / 系统管理
- Data catalog with charts (DMS/ADAS/Lane 3-tab view)
- Quality review workflow (标注质检): Good/Fine/Bad scoring with auto-advance
- Audit enhancements: batch operations, rejection categories, Feishu notifications
- Operation audit log (操作日志)
- World model simulation studio (仿真工坊)
- Dataset version management with snapshots and diff
- ADAS 7-class dataset integration (138K images organized + compressed)
- User management with Feishu integration and pagination
- CRUD/search/filter on all pages, card layout redesign
- PIL-optimized image overlay rendering
- Auto-snapshot on build, in_review workflow stage
- Removed embedded algorithm code (now in workspace)
2026-06-03 11:40:21 +08:00

2.4 KiB

Ultralytics YOLOv8 Object Detection with OpenCV and ONNX

This example demonstrates how to implement Ultralytics YOLOv8 object detection using OpenCV in Python, leveraging the ONNX (Open Neural Network Exchange) model format for efficient inference.

🚀 Getting Started

Follow these simple steps to get the example running on your local machine.

  1. Clone the Repository: If you haven't already, clone the Ultralytics repository to access the example code:

    git clone https://github.com/ultralytics/ultralytics.git
    cd ultralytics/examples/YOLOv8-OpenCV-ONNX-Python/
    
  2. Install Requirements: Install the necessary Python packages listed in the requirements.txt file. We recommend using a virtual environment.

    pip install -r requirements.txt
    
  3. Run the Detection Script: Execute the main Python script, specifying the ONNX model path and the input image.

    python main.py --model yolov8n.onnx --img image.jpg
    

    The script will perform object detection on image.jpg using the yolov8n.onnx model and display the results.

🛠️ Exporting Your Model

If you want to use a different Ultralytics YOLOv8 model or one you've trained yourself, you need to export it to the ONNX format first.

  1. Install Ultralytics: If you don't have it installed, get the latest ultralytics package:

    pip install ultralytics
    
  2. Export the Model: Use the yolo export command to convert your desired model (e.g., yolov8n.pt) to ONNX. Ensure you specify opset=12 or higher for compatibility with OpenCV's DNN module. You can find more details in the Ultralytics Export documentation.

    yolo export model=yolov8n.pt imgsz=640 format=onnx opset=12
    

    This command will generate a yolov8n.onnx file (or the corresponding name for your model) in your working directory. You can then use this .onnx file with the main.py script.

🤝 Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, please feel free to open an issue or submit a pull request to the main Ultralytics repository. Thank you for helping us make Ultralytics YOLO even better!