yolov8 object detection
This test program will infer the yolov8 model to achieve target detection, and the results are only output in the form of printing.
Download the precompiled cvimodel
git clone https://github.com/zwyzwm/YOLOv8-Object-Detection.git
PC-side cross-compilation YOLO program
Duo256M yolov8 code location: sample_yolov8.cpp
Compilation method
Refer to the method in the previous chapter Introduction to compile the sample program
After the compilation is completed, the sample_yolov8
program we need will be generated in the sample/cvi_yolo/
directory
Model compilation
Export yolov8.onnx model
- Download the yolov8 official warehouse code, the address is as follows: https://github.com/ultralytics
git clone https://github.com/ultralytics
- Download the corresponding yolov8 model file
Take yolov8n as an example
cd ultralytics
wget https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.pt
- Export the model of yolov8n.onnx
Download the latest version of anacanda, please refer to: https://docs.anaconda.com/miniconda/
Download Python version above 3.8, PyTorch version above 2.0.1, it is best to use the latest version
Activate (for example Python 3.8, torch2.0.1):
conda create -n py3.8 python==3.8.2
conda activate py3.8
python -m venv .venv
source .venv/bin/activate
pip3 install --upgrade pip
pip3 install torch==2.0.1
Copy the yolo_export/yolov8_export.py code to the yolov8 repository
python3 yolov8_export.py --weights ./yolov8n.pt --img-size 640 640
Tip: When running this command, if an error similar to ModuleNotFoundError: No module named 'x'
appears, just pip install x
Generate yolov8n.onnx in the current directory
Parameter explanation
--weights pytorch model path
--img-size image input size