exp-a
Laughing-q 10 months ago
parent 21219fe443
commit 26e33a43f0
  1. 16
      ultralytics/cfg/models/v8/yolov8-c2f2-2222.yaml
  2. 2
      ultralytics/nn/modules/__init__.py
  3. 4
      ultralytics/nn/modules/block.py
  4. 6
      ultralytics/nn/tasks.py

@ -16,31 +16,31 @@ backbone:
# [from, repeats, module, args]
- [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
- [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
- [-1, 2, C2fn, [128, True]]
- [-1, 2, C2f2, [128, True]]
- [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
- [-1, 2, C2fn, [256, True]]
- [-1, 2, C2f2, [256, True]]
- [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
- [-1, 2, C2fn, [512, True]]
- [-1, 2, C2f2, [512, True]]
- [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32
- [-1, 2, C2fn, [1024, True]]
- [-1, 2, C2f2, [1024, True]]
- [-1, 1, SPPF, [1024, 5]] # 9
# YOLOv8.0n head
head:
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
- [[-1, 6], 1, Concat, [1]] # cat backbone P4
- [-1, 2, C2fn, [512]] # 12
- [-1, 2, C2f2, [512]] # 12
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
- [-1, 2, C2fn, [256]] # 15 (P3/8-small)
- [-1, 2, C2f2, [256]] # 15 (P3/8-small)
- [-1, 1, Conv, [256, 3, 2]]
- [[-1, 12], 1, Concat, [1]] # cat head P4
- [-1, 2, C2fn, [512]] # 18 (P4/16-medium)
- [-1, 2, C2f2, [512]] # 18 (P4/16-medium)
- [-1, 1, Conv, [512, 3, 2]]
- [[-1, 9], 1, Concat, [1]] # cat head P5
- [-1, 2, C2fn, [1024]] # 21 (P5/32-large)
- [-1, 2, C2f2, [1024]] # 21 (P5/32-large)
- [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4, P5)

@ -46,7 +46,7 @@ from .block import (
CBFuse,
CBLinear,
Silence,
C2fn,
C2f2,
)
from .conv import (
CBAM,

@ -37,7 +37,7 @@ __all__ = (
"CBFuse",
"CBLinear",
"Silence",
"C2fn"
"C2f2"
)
@ -239,7 +239,7 @@ class C2f(nn.Module):
return self.cv2(torch.cat(y, 1))
class C2fn(nn.Module):
class C2f2(nn.Module):
"""Faster Implementation of CSP Bottleneck with 2 convolutions."""
def __init__(self, c1, c2, n=1, shortcut=False, g=1, e=0.5):

@ -19,7 +19,7 @@ from ultralytics.nn.modules import (
Bottleneck,
BottleneckCSP,
C2f,
C2fn,
C2f2,
C2fAttn,
ImagePoolingAttn,
C3Ghost,
@ -857,7 +857,7 @@ def parse_model(d, ch, verbose=True): # model_dict, input_channels(3)
C1,
C2,
C2f,
C2fn,
C2f2,
RepNCSPELAN4,
ADown,
SPPELAN,
@ -880,7 +880,7 @@ def parse_model(d, ch, verbose=True): # model_dict, input_channels(3)
) # num heads
args = [c1, c2, *args[1:]]
if m in (BottleneckCSP, C1, C2, C2f, C2fn, C2fAttn, C3, C3TR, C3Ghost, C3x, RepC3):
if m in (BottleneckCSP, C1, C2, C2f, C2f2, C2fAttn, C3, C3TR, C3Ghost, C3x, RepC3):
args.insert(2, n) # number of repeats
n = 1
elif m is AIFI:

Loading…
Cancel
Save