From b70277e9408939b66544429411f716dd905716dc Mon Sep 17 00:00:00 2001 From: wa22 Date: Sat, 1 Jun 2024 18:57:08 +0800 Subject: [PATCH 1/4] update README --- README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fe1b5bd7..8f2149fd 100644 --- a/README.md +++ b/README.md @@ -23,16 +23,16 @@ Over the past years, YOLOs have emerged as the predominant paradigm in the field ## Notes - 2024/05/31: Please use the [exported format](https://github.com/THU-MIG/yolov10?tab=readme-ov-file#export) for benchmark. In the non-exported format, e.g., pytorch, the speed of YOLOv10 is biased because the unnecessary `cv2` and `cv3` operations in the `v10Detect` are executed during inference. - 2024/05/30: We provide [some clarifications and suggestions](https://github.com/THU-MIG/yolov10/issues/136) for detecting smaller objects or objects in the distance with YOLOv10. Thanks to [SkalskiP](https://github.com/SkalskiP)! - +- 2024/05/27: We have updated the [checkpoints](https://github.com/THU-MIG/yolov10/releases/tag/v1.1) with other attributes, like class names and training args, for ease of use. ## UPDATES 🔥 +- 2024/06/01: Thanks to [NielsRogge](https://github.com/NielsRogge) and [AK](https://x.com/_akhaliq) for hosting the models on the HuggingFace Hub! - 2024/05/31: Build [yolov10-jetson](https://github.com/Seeed-Projects/jetson-examples/blob/main/reComputer/scripts/yolov10/README.md) docker image by [youjiang](https://github.com/yuyoujiang)! - 2024/05/31: Thanks to [mohamedsamirx](https://github.com/mohamedsamirx) for the integration with [BoTSORT, DeepOCSORT, OCSORT, HybridSORT, ByteTrack, StrongSORT using BoxMOT library](https://colab.research.google.com/drive/1-QV2TNfqaMsh14w5VxieEyanugVBG14V?usp=sharing)! - 2024/05/31: Thanks to [kaylorchen](https://github.com/kaylorchen) for the integration with [rk3588](https://github.com/kaylorchen/rk3588-yolo-demo)! - 2024/05/30: Thanks to [eaidova](https://github.com/eaidova) for the integration with [OpenVINO™](https://github.com/openvinotoolkit/openvino_notebooks/blob/0ba3c0211bcd49aa860369feddffdf7273a73c64/notebooks/yolov10-optimization/yolov10-optimization.ipynb)! - 2024/05/29: Add the gradio demo for running the models locally. Thanks to [AK](https://x.com/_akhaliq)! - 2024/05/27: Thanks to [sujanshresstha](sujanshresstha) for the integration with [DeepSORT](https://github.com/sujanshresstha/YOLOv10_DeepSORT.git)! -- 2024/05/27: We have updated the [checkpoints](https://github.com/THU-MIG/yolov10/releases/tag/v1.1) with other attributes, like class names, for ease of use. - 2024/05/26: Thanks to [CVHub520](https://github.com/CVHub520) for the integration into [X-AnyLabeling](https://github.com/CVHub520/X-AnyLabeling)! - 2024/05/26: Thanks to [DanielSarmiento04](https://github.com/DanielSarmiento04) for integrate in [c++ | ONNX | OPENCV](https://github.com/DanielSarmiento04/yolov10cpp)! - 2024/05/25: Add [Transformers.js demo](https://huggingface.co/spaces/Xenova/yolov10-web) and onnx weights(yolov10[n](https://huggingface.co/onnx-community/yolov10n)/[s](https://huggingface.co/onnx-community/yolov10s)/[m](https://huggingface.co/onnx-community/yolov10m)/[b](https://huggingface.co/onnx-community/yolov10b)/[l](https://huggingface.co/onnx-community/yolov10l)/[x](https://huggingface.co/onnx-community/yolov10x)). Thanks to [xenova](https://github.com/xenova)! @@ -71,17 +71,56 @@ python app.py yolo val model=yolov10n/s/m/b/l/x.pt data=coco.yaml batch=256 ``` +Or +```python +from ultralytics import YOLOv10 + +model = YOLOv10('yolov10{n/s/m/b/l/x}.pt') +# or +model = YOLOv10.from_pretrained('jameslahm/yolov10{n/s/m/b/l/x}.pt') + +model.val(data='coco.yaml', batch=256) +``` + + ## Training ``` 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 +```python +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('yolov10{n/s/m/b/l/x}.pt') +# Or +# model = YOLOv10.from_pretrained('jameslahm/yolov10{n/s/m/b/l/x}.pt') + +model.train(data='coco.yaml', epochs=500, batch=256, imgsz=640) +# Note that you can upload your trained model to HuggingFace Hub like below +# model.push_to_hub("reponame") +``` + ## Prediction Note that a smaller confidence threshold can be set to detect smaller objects or objects in the distance. Please refer to [here](https://github.com/THU-MIG/yolov10/issues/136) for details. ``` yolo predict model=yolov10n/s/m/b/l/x.pt ``` +Or +```python +from ultralytics import YOLOv10 + +model = YOLOv10('yolov10{n/s/m/b/l/x}.pt') +# or +model = YOLOv10.from_pretrained('jameslahm/yolov10{n/s/m/b/l/x}.pt') + +model.predict() +``` + ## Export ``` # End-to-End ONNX @@ -97,6 +136,17 @@ trtexec --onnx=yolov10n/s/m/b/l/x.onnx --saveEngine=yolov10n/s/m/b/l/x.engine -- yolo predict model=yolov10n/s/m/b/l/x.engine ``` +Or +```python +from ultralytics import YOLOv10 + +model = YOLOv10('yolov10{n/s/m/b/l/x}.pt') +# or +model = YOLOv10.from_pretrained('jameslahm/yolov10{n/s/m/b/l/x}.pt') + +model.export(...) +``` + ## Acknowledgement The code base is built with [ultralytics](https://github.com/ultralytics/ultralytics) and [RT-DETR](https://github.com/lyuwenyu/RT-DETR). From 989cdb812dc3392a3cf37e7a5153998a7601498c Mon Sep 17 00:00:00 2001 From: NielsRogge <48327001+NielsRogge@users.noreply.github.com> Date: Sat, 1 Jun 2024 13:05:46 +0200 Subject: [PATCH 2/4] Add mixin (#168) --- ultralytics/engine/model.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ultralytics/engine/model.py b/ultralytics/engine/model.py index ef5c93c0..4339dbd5 100644 --- a/ultralytics/engine/model.py +++ b/ultralytics/engine/model.py @@ -13,8 +13,10 @@ from ultralytics.hub.utils import HUB_WEB_ROOT from ultralytics.nn.tasks import attempt_load_one_weight, guess_model_task, nn, yaml_model_load from ultralytics.utils import ASSETS, DEFAULT_CFG_DICT, LOGGER, RANK, SETTINGS, callbacks, checks, emojis, yaml_load +from huggingface_hub import PyTorchModelHubMixin -class Model(nn.Module): + +class Model(nn.Module, PyTorchModelHubMixin): """ A base class for implementing YOLO models, unifying APIs across different model types. From 43c4a760435ba3d3ccac3802dfb3b03c9a39e71e Mon Sep 17 00:00:00 2001 From: wa22 Date: Sat, 1 Jun 2024 19:11:00 +0800 Subject: [PATCH 3/4] update requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index ad9c3927..121aa420 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,4 @@ gradio==4.31.5 opencv-python==4.9.0.80 psutil==5.9.8 py-cpuinfo==9.0.0 +huggingface-hub==0.23.2 \ No newline at end of file From 8d0e567e58759eecce8881751e036d97e18efa9e Mon Sep 17 00:00:00 2001 From: wa22 Date: Sat, 1 Jun 2024 20:18:30 +0800 Subject: [PATCH 4/4] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f2149fd..9e26f384 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Official PyTorch implementation of **YOLOv10**. [YOLOv10: Real-Time End-to-End Object Detection](https://arxiv.org/abs/2405.14458).\ Ao Wang, Hui Chen, Lihao Liu, Kai Chen, Zijia Lin, Jungong Han, and Guiguang Ding\ -[![arXiv](https://img.shields.io/badge/arXiv-2405.14458-b31b1b.svg)](https://arxiv.org/abs/2405.14458) Open In Colab [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/kadirnar/Yolov10) [![Transformers.js Demo](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Transformers.js-blue)](https://huggingface.co/spaces/Xenova/yolov10-web) +[![arXiv](https://img.shields.io/badge/arXiv-2405.14458-b31b1b.svg)](https://arxiv.org/abs/2405.14458) Open In Colab [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Models-blue)](https://huggingface.co/collections/jameslahm/yolov10-665b0d90b0b5bb85129460c2) [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/kadirnar/Yolov10) [![Transformers.js Demo](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Transformers.js-blue)](https://huggingface.co/spaces/Xenova/yolov10-web)