Skip to content

Commit

Permalink
ultralytics 8.2.35 add YOLOv9t/s/m models (ultralytics#13504)
Browse files Browse the repository at this point in the history
Co-authored-by: UltralyticsAssistant <[email protected]>
Co-authored-by: Glenn Jocher <[email protected]>
  • Loading branch information
3 people authored Jun 17, 2024
1 parent 605e7f4 commit 8ea945c
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 8 deletions.
14 changes: 7 additions & 7 deletions docs/en/models/yolov9.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ The performance of YOLOv9 on the [COCO dataset](../datasets/detect/coco.md) exem

| Model | size<br><sup>(pixels) | mAP<sup>val<br>50-95 | mAP<sup>val<br>50 | params<br><sup>(M) | FLOPs<br><sup>(B) |
|---------------------------------------------------------------------------------------|-----------------------|----------------------|-------------------|--------------------|-------------------|
| YOLOv9t | 640 | 38.3 | 53.1 | 2.0 | 7.7 |
| YOLOv9s | 640 | 46.8 | 63.4 | 7.2 | 26.7 |
| YOLOv9m | 640 | 51.4 | 68.1 | 20.1 | 76.8 |
| [YOLOv9t](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov9t.pt) | 640 | 38.3 | 53.1 | 2.0 | 7.7 |
| [YOLOv9s](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov9s.pt) | 640 | 46.8 | 63.4 | 7.2 | 26.7 |
| [YOLOv9m](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov9m.pt) | 640 | 51.4 | 68.1 | 20.1 | 76.8 |
| [YOLOv9c](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov9c.pt) | 640 | 53.0 | 70.2 | 25.5 | 102.8 |
| [YOLOv9e](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov9e.pt) | 640 | 55.6 | 72.8 | 58.1 | 192.5 |

Expand Down Expand Up @@ -152,10 +152,10 @@ This example provides simple YOLOv9 training and inference examples. For full do

The YOLOv9 series offers a range of models, each optimized for high-performance [Object Detection](../tasks/detect.md). These models cater to varying computational needs and accuracy requirements, making them versatile for a wide array of applications.

| Model | Filenames | Tasks | Inference | Validation | Training | Export |
| ---------- | --------------------------------- | -------------------------------------------- | --------- | ---------- | -------- | ------ |
| YOLOv9 | `yolov9c.pt` `yolov9e.pt` | [Object Detection](../tasks/detect.md) |||||
| YOLOv9-seg | `yolov9c-seg.pt` `yolov9e-seg.pt` | [Instance Segmentation](../tasks/segment.md) |||||
| Model | Filenames | Tasks | Inference | Validation | Training | Export |
|------------|---------------------------------------------------------|----------------------------------------------|-----------|------------|----------|--------|
| YOLOv9 | `yolov9t` `yolov9s` `yolov9m` `yolov9c.pt` `yolov9e.pt` | [Object Detection](../tasks/detect.md) |||||
| YOLOv9-seg | `yolov9c-seg.pt` `yolov9e-seg.pt` | [Instance Segmentation](../tasks/segment.md) |||||

This table provides a detailed overview of the YOLOv9 model variants, highlighting their capabilities in object detection tasks and their compatibility with various operational modes such as [Inference](../modes/predict.md), [Validation](../modes/val.md), [Training](../modes/train.md), and [Export](../modes/export.md). This comprehensive support ensures that users can fully leverage the capabilities of YOLOv9 models in a broad range of object detection scenarios.

Expand Down
8 changes: 8 additions & 0 deletions docs/en/reference/nn/modules/block.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ keywords: Ultralytics, YOLO, neural networks, block modules, DFL, Proto, HGStem,

<br><br>

## ::: ultralytics.nn.modules.block.ELAN1

<br><br>

## ::: ultralytics.nn.modules.block.AConv

<br><br>

## ::: ultralytics.nn.modules.block.ADown

<br><br>
Expand Down
1 change: 1 addition & 0 deletions tests/test_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def test_checks():


@pytest.mark.slow
@pytest.mark.skipif(True, reason="CUDA export tests disabled pending additional Ultralytics GPU server availability")
@pytest.mark.skipif(not CUDA_IS_AVAILABLE, reason="CUDA is not available")
@pytest.mark.parametrize(
"task, dynamic, int8, half, batch",
Expand Down
2 changes: 1 addition & 1 deletion ultralytics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license

__version__ = "8.2.34"
__version__ = "8.2.35"

import os

Expand Down
38 changes: 38 additions & 0 deletions ultralytics/cfg/models/v9/yolov9m.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
# YOLOv9t
# 603 layers, 20216160 parameters, 77.9 GFLOPs

# parameters
nc: 80 # number of classes

# gelan backbone
backbone:
- [-1, 1, Conv, [32, 3, 2]] # 0-P1/2
- [-1, 1, Conv, [64, 3, 2]] # 1-P2/4
- [-1, 1, RepNCSPELAN4, [128, 128, 64, 1]] # 2
- [-1, 1, AConv, [240]] # 3-P3/8
- [-1, 1, RepNCSPELAN4, [240, 240, 120, 1]] # 4
- [-1, 1, AConv, [360]] # 5-P4/16
- [-1, 1, RepNCSPELAN4, [360, 360, 180, 1]] # 6
- [-1, 1, AConv, [480]] # 7-P5/32
- [-1, 1, RepNCSPELAN4, [480, 480, 240, 1]] # 8
- [-1, 1, SPPELAN, [480, 240]] # 9

head:
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
- [[-1, 6], 1, Concat, [1]] # cat backbone P4
- [-1, 1, RepNCSPELAN4, [360, 360, 180, 1]] # 12

- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
- [-1, 1, RepNCSPELAN4, [240, 240, 120, 1]] # 15

- [-1, 1, AConv, [180]]
- [[-1, 12], 1, Concat, [1]] # cat head P4
- [-1, 1, RepNCSPELAN4, [360, 360, 180, 1]] # 18 (P4/16-medium)

- [-1, 1, AConv, [240]]
- [[-1, 9], 1, Concat, [1]] # cat head P5
- [-1, 1, RepNCSPELAN4, [480, 480, 240, 1]] # 21 (P5/32-large)

- [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4, P5)
38 changes: 38 additions & 0 deletions ultralytics/cfg/models/v9/yolov9s.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
# YOLOv9s
# 917 layers, 7318368 parameters, 27.6 GFLOPs

# parameters
nc: 80 # number of classes

# gelan backbone
backbone:
- [-1, 1, Conv, [32, 3, 2]] # 0-P1/2
- [-1, 1, Conv, [64, 3, 2]] # 1-P2/4
- [-1, 1, ELAN1, [64, 64, 32]] # 2
- [-1, 1, AConv, [128]] # 3-P3/8
- [-1, 1, RepNCSPELAN4, [128, 128, 64, 3]] # 4
- [-1, 1, AConv, [192]] # 5-P4/16
- [-1, 1, RepNCSPELAN4, [192, 192, 96, 3]] # 6
- [-1, 1, AConv, [256]] # 7-P5/32
- [-1, 1, RepNCSPELAN4, [256, 256, 128, 3]] # 8
- [-1, 1, SPPELAN, [256, 128]] # 9

head:
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
- [[-1, 6], 1, Concat, [1]] # cat backbone P4
- [-1, 1, RepNCSPELAN4, [192, 192, 96, 3]] # 12

- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
- [-1, 1, RepNCSPELAN4, [128, 128, 64, 3]] # 15

- [-1, 1, AConv, [96]]
- [[-1, 12], 1, Concat, [1]] # cat head P4
- [-1, 1, RepNCSPELAN4, [192, 192, 96, 3]] # 18 (P4/16-medium)

- [-1, 1, AConv, [128]]
- [[-1, 9], 1, Concat, [1]] # cat head P5
- [-1, 1, RepNCSPELAN4, [256, 256, 128, 3]] # 21 (P5/32-large)

- [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4 P5)
38 changes: 38 additions & 0 deletions ultralytics/cfg/models/v9/yolov9t.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
# YOLOv9t
# 917 layers, 2128720 parameters, 8.5 GFLOPs

# parameters
nc: 80 # number of classes

# gelan backbone
backbone:
- [-1, 1, Conv, [16, 3, 2]] # 0-P1/2
- [-1, 1, Conv, [32, 3, 2]] # 1-P2/4
- [-1, 1, ELAN1, [32, 32, 16]] # 2
- [-1, 1, AConv, [64]] # 3-P3/8
- [-1, 1, RepNCSPELAN4, [64, 64, 32, 3]] # 4
- [-1, 1, AConv, [96]] # 5-P4/16
- [-1, 1, RepNCSPELAN4, [96, 96, 48, 3]] # 6
- [-1, 1, AConv, [128]] # 7-P5/32
- [-1, 1, RepNCSPELAN4, [128, 128, 64, 3]] # 8
- [-1, 1, SPPELAN, [128, 64]] # 9

head:
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
- [[-1, 6], 1, Concat, [1]] # cat backbone P4
- [-1, 1, RepNCSPELAN4, [96, 96, 48, 3]] # 12

- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
- [-1, 1, RepNCSPELAN4, [64, 64, 32, 3]] # 15

- [-1, 1, AConv, [48]]
- [[-1, 12], 1, Concat, [1]] # cat head P4
- [-1, 1, RepNCSPELAN4, [96, 96, 48, 3]] # 18 (P4/16-medium)

- [-1, 1, AConv, [64]]
- [[-1, 9], 1, Concat, [1]] # cat head P5
- [-1, 1, RepNCSPELAN4, [128, 128, 64, 3]] # 21 (P5/32-large)

- [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4, P5)
4 changes: 4 additions & 0 deletions ultralytics/nn/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
C3,
C3TR,
DFL,
ELAN1,
SPP,
SPPELAN,
SPPF,
AConv,
ADown,
BNContrastiveHead,
Bottleneck,
Expand Down Expand Up @@ -133,4 +135,6 @@
"SPPELAN",
"CBFuse",
"CBLinear",
"AConv",
"ELAN1",
)
29 changes: 29 additions & 0 deletions ultralytics/nn/modules/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
"RepC3",
"ResNetLayer",
"RepNCSPELAN4",
"ELAN1",
"ADown",
"AConv",
"SPPELAN",
"CBFuse",
"CBLinear",
Expand Down Expand Up @@ -603,6 +605,33 @@ def forward_split(self, x):
return self.cv4(torch.cat(y, 1))


class ELAN1(RepNCSPELAN4):
"""ELAN1 module with 4 convolutions."""

def __init__(self, c1, c2, c3, c4):
"""Initializes ELAN1 layer with specified channel sizes."""
super().__init__(c1, c2, c3, c4)
self.c = c3 // 2
self.cv1 = Conv(c1, c3, 1, 1)
self.cv2 = Conv(c3 // 2, c4, 3, 1)
self.cv3 = Conv(c4, c4, 3, 1)
self.cv4 = Conv(c3 + (2 * c4), c2, 1, 1)


class AConv(nn.Module):
"""AConv."""

def __init__(self, c1, c2):
"""Initializes AConv module with convolution layers."""
super().__init__()
self.cv1 = Conv(c1, c2, 3, 2, 1)

def forward(self, x):
"""Forward pass through AConv layer."""
x = torch.nn.functional.avg_pool2d(x, 2, 1, 0, False, True)
return self.cv1(x)


class ADown(nn.Module):
"""ADown."""

Expand Down
4 changes: 4 additions & 0 deletions ultralytics/nn/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
C2,
C3,
C3TR,
ELAN1,
OBB,
SPP,
SPPELAN,
SPPF,
AConv,
ADown,
Bottleneck,
BottleneckCSP,
Expand Down Expand Up @@ -878,7 +880,9 @@ def parse_model(d, ch, verbose=True): # model_dict, input_channels(3)
C2,
C2f,
RepNCSPELAN4,
ELAN1,
ADown,
AConv,
SPPELAN,
C2fAttn,
C3,
Expand Down

0 comments on commit 8ea945c

Please sign in to comment.