Official PyTorch implementation of YOLOv10. NeurIPS 2024.
Comparisons with others in terms of latency-accuracy (left) and size-accuracy (right) trade-offs.
YOLOv10: Real-Time End-to-End Object Detection.\ Ao Wang, Hui Chen, Lihao Liu, Kai Chen, Zijia Lin, Jungong Han, and Guiguang Ding\
cv2
and cv3
operations in the v10Detect
are executed during inference.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 |
conda
virtual environment is recommended.
conda create -n yolov10 python=3.9
conda activate yolov10
pip install -r requirements.txt
pip install -e .
python app.py
# Please visit http://127.0.0.1:7860
yolov10n
yolov10s
yolov10m
yolov10b
yolov10l
yolov10x
yolo val model=jameslahm/yolov10{n/s/m/b/l/x} data=coco.yaml batch=256
Or
from ultralytics import YOLOv10
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.val(data='coco.yaml', batch=256)
yolo detect train data=coco.yaml model=yolov10n/s/m/b/l/x.yaml epochs=500 batch=256 imgsz=640 device=0,1,2,3,4,5,6,7
Or
from ultralytics import YOLOv10
model = 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='coco.yaml', epochs=500, batch=256, imgsz=640)
Optionally, you can push your fine-tuned model to the Hugging Face hub as a public or private model:
# let's say you have fine-tuned a model for crop detection
model.push_to_hub("<your-hf-username-or-organization/yolov10-finetuned-crop-detection")
# you can also pass `private=True` if you don't want everyone to see your model
model.push_to_hub("<your-hf-username-or-organization/yolov10-finetuned-crop-detection", private=True)
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 YOLOv10
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.predict()
# 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 YOLOv10
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.export(...)
The code base is built with ultralytics and RT-DETR.
Thanks for the great implementations!
If our code or models help your work, please cite our paper:
@article{wang2024yolov10,
title={YOLOv10: Real-Time End-to-End Object Detection},
author={Wang, Ao and Chen, Hui and Liu, Lihao and Chen, Kai and Lin, Zijia and Han, Jungong and Ding, Guiguang},
journal={arXiv preprint arXiv:2405.14458},
year={2024}
}