From fcc3ba94fd1ec75bf512654ad550434ebe3f48c4 Mon Sep 17 00:00:00 2001 From: Jamjamjon <51357717+jamjamjon@users.noreply.github.com> Date: Thu, 20 Feb 2025 16:49:25 +0800 Subject: [PATCH] Add YOLOv12 model --- README.md | 3 ++- src/models/yolo/config.rs | 4 ++++ src/models/yolo/impl.rs | 9 +++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2c21a6a..661deb7 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ **usls** is a Rust library integrated with **ONNXRuntime**, offering a suite of advanced models for **Computer Vision** and **Vision-Language** tasks, including: -- **YOLO Models**: [YOLOv5](https://github.com/ultralytics/yolov5), [YOLOv6](https://github.com/meituan/YOLOv6), [YOLOv7](https://github.com/WongKinYiu/yolov7), [YOLOv8](https://github.com/ultralytics/ultralytics), [YOLOv9](https://github.com/WongKinYiu/yolov9), [YOLOv10](https://github.com/THU-MIG/yolov10), [YOLO11](https://github.com/ultralytics/ultralytics) +- **YOLO Models**: [YOLOv5](https://github.com/ultralytics/yolov5), [YOLOv6](https://github.com/meituan/YOLOv6), [YOLOv7](https://github.com/WongKinYiu/yolov7), [YOLOv8](https://github.com/ultralytics/ultralytics), [YOLOv9](https://github.com/WongKinYiu/yolov9), [YOLOv10](https://github.com/THU-MIG/yolov10), [YOLO11](https://github.com/ultralytics/ultralytics), [YOLOv12](https://github.com/sunsmarterjie/yolov12) - **SAM Models**: [SAM](https://github.com/facebookresearch/segment-anything), [SAM2](https://github.com/facebookresearch/segment-anything-2), [MobileSAM](https://github.com/ChaoningZhang/MobileSAM), [EdgeSAM](https://github.com/chongzhou96/EdgeSAM), [SAM-HQ](https://github.com/SysCV/sam-hq), [FastSAM](https://github.com/CASIA-IVA-Lab/FastSAM) - **Vision Models**: [RT-DETR](https://arxiv.org/abs/2304.08069), [RTMO](https://github.com/open-mmlab/mmpose/tree/main/projects/rtmo), [Depth-Anything](https://github.com/LiheYoung/Depth-Anything), [DINOv2](https://github.com/facebookresearch/dinov2), [MODNet](https://github.com/ZHKKKe/MODNet), [Sapiens](https://arxiv.org/abs/2408.12569), [DepthPro](https://github.com/apple/ml-depth-pro), [FastViT](https://github.com/apple/ml-fastvit), [BEiT](https://github.com/microsoft/unilm/tree/master/beit), [MobileOne](https://github.com/apple/ml-mobileone) - **Vision-Language Models**: [CLIP](https://github.com/openai/CLIP), [jina-clip-v1](https://huggingface.co/jinaai/jina-clip-v1), [BLIP](https://arxiv.org/abs/2201.12086), [GroundingDINO](https://github.com/IDEA-Research/GroundingDINO), [YOLO-World](https://github.com/AILab-CVC/YOLO-World), [Florence2](https://arxiv.org/abs/2311.06242), [Moondream2](https://github.com/vikhyat/moondream/tree/main) @@ -57,6 +57,7 @@ | [YOLOv8
YOLO11](https://github.com/ultralytics/ultralytics) | Object Detection
Instance Segmentation
Image Classification
Oriented Object Detection
Keypoint Detection | [demo](examples/yolo) | ✅ | ✅ | ✅ | ✅ | ✅ | | [YOLOv9](https://github.com/WongKinYiu/yolov9) | Object Detection | [demo](examples/yolo) | ✅ | ✅ | ✅ | ✅ | ✅ | | [YOLOv10](https://github.com/THU-MIG/yolov10) | Object Detection | [demo](examples/yolo) | ✅ | ✅ | ✅ | ✅ | ✅ | +| [YOLOv12](https://github.com/sunsmarterjie/yolov12) | Object Detection | [demo](examples/yolo) | ✅ | ✅ | ✅ | ✅ | ✅ | | [RT-DETR](https://github.com/lyuwenyu/RT-DETR) | Object Detection | [demo](examples/rtdetr) | ✅ | ✅ | ✅ | | | | [PP-PicoDet](https://github.com/PaddlePaddle/PaddleDetection/tree/release/2.8/configs/picodet) | Object Detection | [demo](examples/picodet-layout) | ✅ | ✅ | ✅ | | | | [DocLayout-YOLO](https://github.com/opendatalab/DocLayout-YOLO) | Object Detection | [demo](examples/picodet-layout) | ✅ | ✅ | ✅ | | | diff --git a/src/models/yolo/config.rs b/src/models/yolo/config.rs index d50dcc4..af6cc72 100644 --- a/src/models/yolo/config.rs +++ b/src/models/yolo/config.rs @@ -134,6 +134,10 @@ impl Options { Self::yolo().with_model_version(11.0.into()) } + pub fn yolo_v12() -> Self { + Self::yolo().with_model_version(12.0.into()) + } + pub fn yolo_v8_n() -> Self { Self::yolo() .with_model_version(8.0.into()) diff --git a/src/models/yolo/impl.rs b/src/models/yolo/impl.rs index 45dfa62..31629c9 100644 --- a/src/models/yolo/impl.rs +++ b/src/models/yolo/impl.rs @@ -114,9 +114,10 @@ impl YOLO { (Task::ObjectDetection, Version(5, 0) | Version(6, 0) | Version(7, 0)) => { YOLOPredsFormat::n_a_cxcywh_confclss() } - (Task::ObjectDetection, Version(8, 0) | Version(9, 0) | Version(11, 0)) => { - YOLOPredsFormat::n_cxcywh_clss_a() - } + ( + Task::ObjectDetection, + Version(8, 0) | Version(9, 0) | Version(11, 0) | Version(12, 0), + ) => YOLOPredsFormat::n_cxcywh_clss_a(), (Task::ObjectDetection, Version(10, 0)) => { YOLOPredsFormat::n_a_xyxy_confcls().apply_nms(false) } @@ -143,7 +144,7 @@ impl YOLO { let layout = match version { // single task, no need to specified task Version(6, 0) | Version(7, 0) => YOLOPredsFormat::n_a_cxcywh_confclss(), - Version(9, 0) => YOLOPredsFormat::n_cxcywh_clss_a(), + Version(9, 0) | Version(12, 0) => YOLOPredsFormat::n_cxcywh_clss_a(), Version(10, 0) => YOLOPredsFormat::n_a_xyxy_confcls().apply_nms(false), _ => { anyhow::bail!(