【项目】基于YOLOv10的目标检测项目
- (一)模型性能
- (二)安装与使用
- (1)环境安装
- (2)快速使用
- (3)模型评估Validation
- (4)模型训练Training
- (5)模型预测Prediction
- (6)模型转换Export
(一)模型性能
YOLOv10模型库-COCO
Model | Test Size | Params | FLOPs | APval | Latency |
---|---|---|---|---|---|
YOLOv10-N | 640 | 2.3M | 6.7G | 38.5% | 1.84ms |
YOLOv10-S | 640 | 7.2M | 21.6G | 46.3% | 2.49ms |
YOLOv10-M | 640 | 15.4M | 59.1G | 51.1% | 4.74ms |
YOLOv10-B | 640 | 19.1M | 92.0G | 52.5% | 5.74ms |
YOLOv10-L | 640 | 24.4M | 120.3G | 53.2% | 7.28ms |
YOLOv10-X | 640 | 29.5M | 160.4G | 54.4% | 10.70ms |
(二)安装与使用
(1)环境安装
git clone https://github.com/THU-MIG/yolov10.git
conda
virtual environment is recommended.
conda create -n yolov10 python=3.9
conda activate yolov10
pip install -r requirements.txt
(2)快速使用
python app.py
# Please visit http://127.0.0.1:7860
(3)模型评估Validation
yolov10n
yolov10s
yolov10m
yolov10b
yolov10l
yolov10x
yolo val model=jameslahm/yolov10{n/s/m/b/l/x} data=coco128.yaml batch=16
Or
from ultralytics import YOLOv10model = YOLOv10.from_pretrained('jameslahm/yolov10{n/s/m/b/l/x}')
# or
# wget https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10{n/s/m/b/l/x}.pt
model = YOLOv10('yolov10{n/s/m/b/l/x}.pt')model.val(data='coco128.yaml', batch=16)
(4)模型训练Training
yolo detect train data=coco128.yaml model=yolov10n/s/m/b/l/x.yaml epochs=500 batch=16 imgsz=640 device=0,1,2,3,4,5,6,7
Or
from ultralytics import YOLOv10model = YOLOv10()
# If you want to finetune the model with pretrained weights, you could load the
# pretrained weights like below
# model = YOLOv10.from_pretrained('jameslahm/yolov10{n/s/m/b/l/x}')
# or
# wget https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10{n/s/m/b/l/x}.pt
# model = YOLOv10('yolov10{n/s/m/b/l/x}.pt')model.train(data='coco128.yaml', epochs=500, batch=16, imgsz=640)
(5)模型预测Prediction
Note that a smaller confidence threshold can be set to detect smaller objects or objects in the distance. Please refer to here for details.
yolo predict model=jameslahm/yolov10{n/s/m/b/l/x}
Or
from ultralytics import YOLOv10model = YOLOv10.from_pretrained('jameslahm/yolov10{n/s/m/b/l/x}')
# or
# wget https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10{n/s/m/b/l/x}.pt
model = YOLOv10('yolov10{n/s/m/b/l/x}.pt')model.predict()
(6)模型转换Export
# End-to-End ONNX
yolo export model=jameslahm/yolov10{n/s/m/b/l/x} format=onnx opset=13 simplify
# Predict with ONNX
yolo predict model=yolov10n/s/m/b/l/x.onnx# End-to-End TensorRT
yolo export model=jameslahm/yolov10{n/s/m/b/l/x} format=engine half=True simplify opset=13 workspace=16
# or
trtexec --onnx=yolov10n/s/m/b/l/x.onnx --saveEngine=yolov10n/s/m/b/l/x.engine --fp16
# Predict with TensorRT
yolo predict model=yolov10n/s/m/b/l/x.engine
Or
from ultralytics import YOLOv10model = YOLOv10.from_pretrained('jameslahm/yolov10{n/s/m/b/l/x}')
# or
# wget https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10{n/s/m/b/l/x}.pt
model = YOLOv10('yolov10{n/s/m/b/l/x}.pt')model.export(...)