From 8f0984817da455e4dd14c2281d669e04fdafee7d Mon Sep 17 00:00:00 2001 From: wa22 Date: Thu, 30 May 2024 15:46:06 +0800 Subject: [PATCH 01/23] fix val with half --- ultralytics/utils/metrics.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ultralytics/utils/metrics.py b/ultralytics/utils/metrics.py index 235db567..b5988110 100644 --- a/ultralytics/utils/metrics.py +++ b/ultralytics/utils/metrics.py @@ -64,6 +64,9 @@ def box_iou(box1, box2, eps=1e-7): (torch.Tensor): An NxM tensor containing the pairwise IoU values for every element in box1 and box2. """ + # NOTE: need float32 to get accurate iou values + box1 = torch.as_tensor(box1, dtype=torch.float32) + box2 = torch.as_tensor(box2, dtype=torch.float32) # inter(N,M) = (rb(N,M,2) - lt(N,M,2)).clamp(0).prod(2) (a1, a2), (b1, b2) = box1.unsqueeze(1).chunk(2, 2), box2.unsqueeze(0).chunk(2, 2) inter = (torch.min(a2, b2) - torch.max(a1, b1)).clamp_(0).prod(2) From 842e8ababe6444fab9901fc102435a1fd4fa1dc2 Mon Sep 17 00:00:00 2001 From: wa22 Date: Thu, 30 May 2024 09:43:13 +0000 Subject: [PATCH 02/23] update README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3bf3fd3d..ede0e552 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ Over the past years, YOLOs have emerged as the predominant paradigm in the field **UPDATES** 🔥 +- 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/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. From 2b24dab60fa3ad43b2249fcbd7b49405c42f2c6e Mon Sep 17 00:00:00 2001 From: wa22 Date: Thu, 30 May 2024 09:49:11 +0000 Subject: [PATCH 03/23] update README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ede0e552..d9d0e3ed 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,8 @@ yolo detect train data=coco.yaml model=yolov10n/s/m/b/l/x.yaml epochs=500 batch= ## 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 ``` From dadcda9c703cc3fbfd5ed6e505a2257738876ee2 Mon Sep 17 00:00:00 2001 From: wa22 Date: Thu, 30 May 2024 09:50:02 +0000 Subject: [PATCH 04/23] update README --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index d9d0e3ed..b3b33758 100644 --- a/README.md +++ b/README.md @@ -69,9 +69,8 @@ yolo detect train data=coco.yaml model=yolov10n/s/m/b/l/x.yaml epochs=500 batch= ``` ## 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. ``` -# 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 ``` From bbcad68d77d689820379b066ca4a5232cd654613 Mon Sep 17 00:00:00 2001 From: wa22 Date: Fri, 31 May 2024 09:25:17 +0800 Subject: [PATCH 05/23] update README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b3b33758..a08e969f 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Over the past years, YOLOs have emerged as the predominant paradigm in the field **UPDATES** 🔥 +- 2024/05/31: Please use the exported format 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/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)! From 27a889edbd214f56c53952ecf917716702842436 Mon Sep 17 00:00:00 2001 From: wa22 Date: Fri, 31 May 2024 09:26:52 +0800 Subject: [PATCH 06/23] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a08e969f..3951fab5 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Over the past years, YOLOs have emerged as the predominant paradigm in the field **UPDATES** 🔥 -- 2024/05/31: Please use the exported format 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/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/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)! From 634ceee53724e6c510f77ee893e588e4f90d68e8 Mon Sep 17 00:00:00 2001 From: Veeja Liu Date: Fri, 31 May 2024 10:27:26 +0800 Subject: [PATCH 07/23] Change the format of README.md (#137) Co-authored-by: weijialiu --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3951fab5..730dd533 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Over the past years, YOLOs have emerged as the predominant paradigm in the field ## Performance COCO + | Model | Test Size | #Params | FLOPs | APval | Latency | |:---------------|:----:|:---:|:--:|:--:|:--:| | [YOLOv10-N](https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10n.pt) | 640 | 2.3M | 6.7G | 38.5% | 1.84ms | From 1788e9d4e85c9a67bc40d72f97e04353f270e2b1 Mon Sep 17 00:00:00 2001 From: wa22 Date: Fri, 31 May 2024 10:55:07 +0800 Subject: [PATCH 08/23] update README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3951fab5..275a7073 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Over the past years, YOLOs have emerged as the predominant paradigm in the field **UPDATES** 🔥 +- 2024/05/31: Thanks to [kaylorchen](https://github.com/kaylorchen) for the integration with [rk3588](https://github.com/kaylorchen/rk3588-yolo-demo)! - 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/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)! From c82935096919119c7c0e8680d95d6ba44c1e3dbe Mon Sep 17 00:00:00 2001 From: mohamedsamirx <94049545+mohamedsamirx@users.noreply.github.com> Date: Fri, 31 May 2024 07:57:49 +0300 Subject: [PATCH 09/23] Update README.md (#152) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b41a80d2..98eb236a 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Over the past years, YOLOs have emerged as the predominant paradigm in the field **UPDATES** 🔥 +- 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/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)! From 393091b63ec810264e155461fb7126298b8e6c5e Mon Sep 17 00:00:00 2001 From: yuyoujiang <76863444+yuyoujiang@users.noreply.github.com> Date: Fri, 31 May 2024 17:02:14 +0800 Subject: [PATCH 10/23] update README (#157) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 98eb236a..79cb157b 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Over the past years, YOLOs have emerged as the predominant paradigm in the field **UPDATES** 🔥 +- 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/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. From 359435324913b4abeda7697142ae5cbf3c3b5e72 Mon Sep 17 00:00:00 2001 From: wa22 Date: Fri, 31 May 2024 18:33:16 +0800 Subject: [PATCH 11/23] update README --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 79cb157b..a2ca9519 100644 --- a/README.md +++ b/README.md @@ -104,12 +104,10 @@ Thanks for the great implementations! If our code or models help your work, please cite our paper: ```BibTeX -@misc{wang2024yolov10, - title={YOLOv10: Real-Time End-to-End Object Detection}, - author={Ao Wang and Hui Chen and Lihao Liu and Kai Chen and Zijia Lin and Jungong Han and Guiguang Ding}, - year={2024}, - eprint={2405.14458}, - archivePrefix={arXiv}, - primaryClass={cs.CV} +@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} } ``` From 22aa8412a702a969222921efa85559f6e51d9ea3 Mon Sep 17 00:00:00 2001 From: wa22 Date: Sat, 1 Jun 2024 10:53:02 +0800 Subject: [PATCH 12/23] update README --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a2ca9519..fe1b5bd7 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,15 @@ Ao Wang, Hui Chen, Lihao Liu, Kai Chen, Zijia Lin, Jungong Han, and Guiguang Din Over the past years, YOLOs have emerged as the predominant paradigm in the field of real-time object detection owing to their effective balance between computational cost and detection performance. Researchers have explored the architectural designs, optimization objectives, data augmentation strategies, and others for YOLOs, achieving notable progress. However, the reliance on the non-maximum suppression (NMS) for post-processing hampers the end-to-end deployment of YOLOs and adversely impacts the inference latency. Besides, the design of various components in YOLOs lacks the comprehensive and thorough inspection, resulting in noticeable computational redundancy and limiting the model's capability. It renders the suboptimal efficiency, along with considerable potential for performance improvements. In this work, we aim to further advance the performance-efficiency boundary of YOLOs from both the post-processing and the model architecture. To this end, we first present the consistent dual assignments for NMS-free training of YOLOs, which brings the competitive performance and low inference latency simultaneously. Moreover, we introduce the holistic efficiency-accuracy driven model design strategy for YOLOs. We comprehensively optimize various components of YOLOs from both the efficiency and accuracy perspectives, which greatly reduces the computational overhead and enhances the capability. The outcome of our effort is a new generation of YOLO series for real-time end-to-end object detection, dubbed YOLOv10. Extensive experiments show that YOLOv10 achieves the state-of-the-art performance and efficiency across various model scales. For example, our YOLOv10-S is 1.8$\times$ faster than RT-DETR-R18 under the similar AP on COCO, meanwhile enjoying 2.8$\times$ smaller number of parameters and FLOPs. Compared with YOLOv9-C, YOLOv10-B has 46\% less latency and 25\% fewer parameters for the same performance. -**UPDATES** 🔥 +## 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)! + + +## UPDATES 🔥 - 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/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/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)! From b70277e9408939b66544429411f716dd905716dc Mon Sep 17 00:00:00 2001 From: wa22 Date: Sat, 1 Jun 2024 18:57:08 +0800 Subject: [PATCH 13/23] 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 14/23] 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 15/23] 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 16/23] 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)
From 16676546f12428258e0881deeb21e8f85b119c2b Mon Sep 17 00:00:00 2001 From: wa22 Date: Sat, 1 Jun 2024 21:32:27 +0800 Subject: [PATCH 17/23] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e26f384..20101103 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ model = YOLOv10() 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") +# model.push_to_hub("reponame", config={"model": "yolov10n/s/m/b/l/x.yaml"}) ``` ## Prediction From 22f49e1249dec6b4b2a05b31a4a74118ecebdafa Mon Sep 17 00:00:00 2001 From: wa22 Date: Sat, 1 Jun 2024 21:32:44 +0800 Subject: [PATCH 18/23] update requirements.txt --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 121aa420..0464ed55 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,5 @@ 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 +huggingface-hub==0.23.2 +safetensors==0.4.3 \ No newline at end of file From 0efdd2f0c4a806c787df840ffba4ab2556a083c2 Mon Sep 17 00:00:00 2001 From: Erlangga Yudi Pradana Date: Sat, 1 Jun 2024 21:48:36 +0700 Subject: [PATCH 19/23] docs: update README.md (#174) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 20101103..4c84bf72 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Over the past years, YOLOs have emerged as the predominant paradigm in the field - 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 [ErlanggaYudiPradana](https://github.com/rlggyp) for the integration with [C++ | OpenVINO | OpenCV](https://github.com/rlggyp/YOLOv10-OpenVINO-CPP-Inference) - 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)! From 7a0cce17b64133c03ee276f250168622c062f8be Mon Sep 17 00:00:00 2001 From: wa22 Date: Mon, 3 Jun 2024 10:21:43 +0800 Subject: [PATCH 20/23] add names when pushing to huggingface hub --- ultralytics/models/yolov10/model.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ultralytics/models/yolov10/model.py b/ultralytics/models/yolov10/model.py index a8881395..33fbd845 100644 --- a/ultralytics/models/yolov10/model.py +++ b/ultralytics/models/yolov10/model.py @@ -6,8 +6,19 @@ from .train import YOLOv10DetectionTrainer class YOLOv10(Model): - def __init__(self, model="yolov10n.pt", task=None, verbose=False): + def __init__(self, model="yolov10n.pt", task=None, verbose=False, + names=None): super().__init__(model=model, task=task, verbose=verbose) + if names is not None: + setattr(self.model, 'names', names) + + def push_to_hub(self, repo_name, **kwargs): + config = kwargs.get('config', {}) + config['names'] = self.names + config['model'] = self.model.yaml['yaml_file'] + config['task'] = self.task + kwargs['config'] = config + super().push_to_hub(repo_name, **kwargs) @property def task_map(self): From a6e064d33122bc9683fd3c0aac1043618f05795a Mon Sep 17 00:00:00 2001 From: NielsRogge <48327001+NielsRogge@users.noreply.github.com> Date: Mon, 3 Jun 2024 04:23:37 +0200 Subject: [PATCH 21/23] Track downloads (#172) Track downloads from the HuggingFace hub --- README.md | 36 +++++++++++++++++++---------- app.py | 4 ++-- ultralytics/engine/model.py | 4 +--- ultralytics/models/yolov10/model.py | 4 +++- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 4c84bf72..013a7dc7 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ 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. +- 2024/05/27: We have updated the [checkpoints](https://huggingface.co/collections/jameslahm/yolov10-665b0d90b0b5bb85129460c2) with other attributes, like class names and training args, for ease of use. ## UPDATES 🔥 - 2024/06/01: Thanks to [ErlanggaYudiPradana](https://github.com/rlggyp) for the integration with [C++ | OpenVINO | OpenCV](https://github.com/rlggyp/YOLOv10-OpenVINO-CPP-Inference) @@ -44,12 +44,12 @@ COCO | Model | Test Size | #Params | FLOPs | APval | Latency | |:---------------|:----:|:---:|:--:|:--:|:--:| -| [YOLOv10-N](https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10n.pt) | 640 | 2.3M | 6.7G | 38.5% | 1.84ms | -| [YOLOv10-S](https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10s.pt) | 640 | 7.2M | 21.6G | 46.3% | 2.49ms | -| [YOLOv10-M](https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10m.pt) | 640 | 15.4M | 59.1G | 51.1% | 4.74ms | -| [YOLOv10-B](https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10b.pt) | 640 | 19.1M | 92.0G | 52.5% | 5.74ms | -| [YOLOv10-L](https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10l.pt) | 640 | 24.4M | 120.3G | 53.2% | 7.28ms | -| [YOLOv10-X](https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10x.pt) | 640 | 29.5M | 160.4G | 54.4% | 10.70ms | +| [YOLOv10-N](https://huggingface.co/jameslahm/yolov10n) | 640 | 2.3M | 6.7G | 38.5% | 1.84ms | +| [YOLOv10-S](https://huggingface.co/jameslahm/yolov10s) | 640 | 7.2M | 21.6G | 46.3% | 2.49ms | +| [YOLOv10-M](https://huggingface.co/jameslahm/yolov10m) | 640 | 15.4M | 59.1G | 51.1% | 4.74ms | +| [YOLOv10-B](https://huggingface.co/jameslahm/yolov10b) | 640 | 19.1M | 92.0G | 52.5% | 5.74ms | +| [YOLOv10-L](https://huggingface.co/jameslahm/yolov10l) | 640 | 24.4M | 120.3G | 53.2% | 7.28ms | +| [YOLOv10-X](https://huggingface.co/jameslahm/yolov10x) | 640 | 29.5M | 160.4G | 54.4% | 10.70ms | ## Installation `conda` virtual environment is recommended. @@ -61,14 +61,14 @@ pip install -e . ``` ## Demo ``` -wget https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10s.pt python app.py # Please visit http://127.0.0.1:7860 ``` ## Validation -[`yolov10n.pt`](https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10n.pt) [`yolov10s.pt`](https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10s.pt) [`yolov10m.pt`](https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10m.pt) [`yolov10b.pt`](https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10b.pt) [`yolov10l.pt`](https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10l.pt) [`yolov10x.pt`](https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10x.pt) +[`yolov10n`](https://huggingface.co/jameslahm/yolov10n) [`yolov10s`](https://huggingface.co/jameslahm/yolov10s) [`yolov10m`](https://huggingface.co/jameslahm/yolov10m) [`yolov10b`](https://huggingface.co/jameslahm/yolov10b) [`yolov10l`](https://huggingface.co/jameslahm/yolov10l) [`yolov10x`](https://huggingface.co/jameslahm/yolov10x) ``` +wget https://github.com/THU-MIG/yolov10/releases/download/v1.1/yolov10s.pt yolo val model=yolov10n/s/m/b/l/x.pt data=coco.yaml batch=256 ``` @@ -78,7 +78,7 @@ 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 = YOLOv10.from_pretrained('jameslahm/yolov10{n/s/m/b/l/x}') model.val(data='coco.yaml', batch=256) ``` @@ -98,13 +98,25 @@ model = YOLOv10() # 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 = YOLOv10.from_pretrained('jameslahm/yolov10{n/s/m/b/l/x}') 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", config={"model": "yolov10n/s/m/b/l/x.yaml"}) ``` +## Push to hub to 🤗 + +Optionally, you can push your fine-tuned model to the [Hugging Face hub](https://huggingface.co/) as a public or private model: + +```python +# let's say you have fine-tuned a model for crop detection +model.push_to_hub(" Date: Mon, 3 Jun 2024 10:50:08 +0800 Subject: [PATCH 22/23] update app.py --- README.md | 10 ++++----- app.py | 66 +++++++++++++++++++++++++++++++++---------------------- 2 files changed, 44 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 013a7dc7..9729982c 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-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) +[![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/jameslahm/YOLOv10) [![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)
@@ -23,7 +23,7 @@ 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://huggingface.co/collections/jameslahm/yolov10-665b0d90b0b5bb85129460c2) with other attributes, like class names and training args, for ease of use. +- 2024/05/27: We have updated the [checkpoints](https://huggingface.co/collections/jameslahm/yolov10-665b0d90b0b5bb85129460c2) with class names, for ease of use. ## UPDATES 🔥 - 2024/06/01: Thanks to [ErlanggaYudiPradana](https://github.com/rlggyp) for the integration with [C++ | OpenVINO | OpenCV](https://github.com/rlggyp/YOLOv10-OpenVINO-CPP-Inference) @@ -97,12 +97,10 @@ 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 +# or # model = YOLOv10.from_pretrained('jameslahm/yolov10{n/s/m/b/l/x}') 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", config={"model": "yolov10n/s/m/b/l/x.yaml"}) ``` ## Push to hub to 🤗 @@ -143,7 +141,7 @@ yolo predict model=yolov10n/s/m/b/l/x.onnx # End-to-End TensorRT yolo export model=yolov10n/s/m/b/l/x.pt format=engine half=True simplify opset=13 workspace=16 -# Or +# 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 diff --git a/app.py b/app.py index e40cc846..5598af6d 100644 --- a/app.py +++ b/app.py @@ -1,15 +1,23 @@ -# Ackownledgement: https://huggingface.co/spaces/kadirnar/Yolov10/blob/main/app.py -# Thanks to @kadirnar - +import PIL.Image as Image import gradio as gr -from ultralytics import YOLOv10 -def yolov10_inference(image, image_size, conf_threshold): - model = YOLOv10.from_pretrained("jameslahm/yolov10n") - - model.predict(source=image, imgsz=image_size, conf=conf_threshold, save=True) - - return model.predictor.plotted_img[:, :, ::-1] +from ultralytics import YOLOv10 + +def predict_image(img, model_id, image_size, conf_threshold): + model = YOLOv10.from_pretrained(f'jameslahm/{model_id}') + results = model.predict( + source=img, + conf=conf_threshold, + show_labels=True, + show_conf=True, + imgsz=image_size, + ) + + for r in results: + im_array = r.plot() + im = Image.fromarray(im_array[..., ::-1]) + + return im def app(): with gr.Blocks(): @@ -20,14 +28,14 @@ def app(): model_id = gr.Dropdown( label="Model", choices=[ - "yolov10n.pt", - "yolov10s.pt", - "yolov10m.pt", - "yolov10b.pt", - "yolov10l.pt", - "yolov10x.pt", + "yolov10n", + "yolov10s", + "yolov10m", + "yolov10b", + "yolov10l", + "yolov10x", ], - value="yolov10s.pt", + value="yolov10m", ) image_size = gr.Slider( label="Image Size", @@ -40,16 +48,16 @@ def app(): label="Confidence Threshold", minimum=0.0, maximum=1.0, - step=0.1, + step=0.05, value=0.25, ) yolov10_infer = gr.Button(value="Detect Objects") with gr.Column(): - output_image = gr.Image(type="numpy", label="Annotated Image") + output_image = gr.Image(type="pil", label="Annotated Image") yolov10_infer.click( - fn=yolov10_inference, + fn=predict_image, inputs=[ image, model_id, @@ -63,18 +71,18 @@ def app(): examples=[ [ "ultralytics/assets/bus.jpg", - "yolov10s.pt", + "yolov10s", 640, 0.25, ], [ "ultralytics/assets/zidane.jpg", - "yolov10s.pt", + "yolov10s", 640, 0.25, ], ], - fn=yolov10_inference, + fn=predict_image, inputs=[ image, model_id, @@ -82,7 +90,7 @@ def app(): conf_threshold, ], outputs=[output_image], - cache_examples=True, + cache_examples='lazy', ) gradio_app = gr.Blocks() @@ -93,8 +101,14 @@ with gradio_app: YOLOv10: Real-Time End-to-End Object Detection """) + gr.HTML( + """ +

+ arXiv | github +

+ """) with gr.Row(): with gr.Column(): app() - -gradio_app.launch(debug=True) \ No newline at end of file +if __name__ == '__main__': + gradio_app.launch() \ No newline at end of file From 1539b5a678b388d2b678184a3e1431c91d5f10c7 Mon Sep 17 00:00:00 2001 From: wa22 Date: Mon, 3 Jun 2024 11:21:49 +0800 Subject: [PATCH 23/23] add calculation for flops --- flops.py | 8 ++++++++ ultralytics/nn/modules/head.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 flops.py diff --git a/flops.py b/flops.py new file mode 100644 index 00000000..baa052bf --- /dev/null +++ b/flops.py @@ -0,0 +1,8 @@ +from ultralytics import YOLOv10 + +model = YOLOv10('yolov10n.yaml') +model.model.model[-1].export = True +model.model.model[-1].format = 'onnx' +del model.model.model[-1].cv2 +del model.model.model[-1].cv3 +model.fuse() \ No newline at end of file diff --git a/ultralytics/nn/modules/head.py b/ultralytics/nn/modules/head.py index 5bc7c068..b55942c2 100644 --- a/ultralytics/nn/modules/head.py +++ b/ultralytics/nn/modules/head.py @@ -496,7 +496,7 @@ class RTDETRDecoder(nn.Module): class v10Detect(Detect): - max_det = -1 + max_det = 300 def __init__(self, nc=80, ch=()): super().__init__(nc, ch)