From fec13ec7736f93335fa23c63fce600c383b4f94b Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 30 Dec 2022 13:32:08 +0100 Subject: [PATCH] Add YOLO8x6 and YAML syntax improvements (#120) --- tests/check_flops.py | 16 +++--- ultralytics/yolo/engine/model.py | 5 +- .../yolo/v8/models/seg/yolov8l-seg.yaml | 54 +++++++++---------- .../yolo/v8/models/seg/yolov8m-seg.yaml | 54 +++++++++---------- .../yolo/v8/models/seg/yolov8n-seg.yaml | 54 +++++++++---------- .../yolo/v8/models/seg/yolov8s-seg.yaml | 54 +++++++++---------- .../yolo/v8/models/seg/yolov8x-seg.yaml | 54 +++++++++---------- ultralytics/yolo/v8/models/yolov8l.yaml | 54 +++++++++---------- ultralytics/yolo/v8/models/yolov8m.yaml | 54 +++++++++---------- ultralytics/yolo/v8/models/yolov8n.yaml | 54 +++++++++---------- ultralytics/yolo/v8/models/yolov8s.yaml | 54 +++++++++---------- ultralytics/yolo/v8/models/yolov8x.yaml | 54 +++++++++---------- ultralytics/yolo/v8/models/yolov8x6.yaml | 50 +++++++++++++++++ 13 files changed, 319 insertions(+), 292 deletions(-) create mode 100644 ultralytics/yolo/v8/models/yolov8x6.yaml diff --git a/tests/check_flops.py b/tests/check_flops.py index 031d19d..5ddebec 100644 --- a/tests/check_flops.py +++ b/tests/check_flops.py @@ -1,16 +1,12 @@ from ultralytics import YOLO +from ultralytics.yolo.utils import ROOT if __name__ == "__main__": - YOLO.new("yolov8n.yaml") - YOLO.new("yolov8n-seg.yaml") - YOLO.new("yolov8s.yaml") - YOLO.new("yolov8s-seg.yaml") - YOLO.new("yolov8m.yaml") - YOLO.new("yolov8m-seg.yaml") - YOLO.new("yolov8l.yaml") - YOLO.new("yolov8l-seg.yaml") - YOLO.new("yolov8x.yaml") - YOLO.new("yolov8x-seg.yaml") + for m in list((ROOT / 'yolo/v8/models').rglob('*.yaml')): + try: + YOLO.new(m.name, verbose=True) + except Exception as e: + print(f'ERROR for {m}: {e}') # n vs n-seg: 8.9GFLOPs vs 12.8GFLOPs, 3.16M vs 3.6M. ch[0] // 4 (11.9GFLOPs, 3.39M) # s vs s-seg: 28.8GFLOPs vs 44.4GFLOPs, 11.1M vs 12.9M. ch[0] // 4 (39.5GFLOPs, 11.7M) diff --git a/ultralytics/yolo/engine/model.py b/ultralytics/yolo/engine/model.py index 025fef6..da1c98a 100644 --- a/ultralytics/yolo/engine/model.py +++ b/ultralytics/yolo/engine/model.py @@ -52,19 +52,20 @@ class YOLO: self.init_disabled = False @classmethod - def new(cls, cfg: str): + def new(cls, cfg: str, verbose=True): """ Initializes a new model and infers the task type from the model definitions Args: cfg (str): model configuration file + verbsoe (bool): display model info on load """ cfg = check_yaml(cfg) # check YAML cfg_dict = yaml_load(cfg) # model dict obj = cls(init_key=cls.__init_key) obj.task = obj._guess_task_from_head(cfg_dict["head"][-1][-2]) obj.ModelClass, obj.TrainerClass, obj.ValidatorClass, obj.PredictorClass = obj._guess_ops_from_task(obj.task) - obj.model = obj.ModelClass(cfg_dict) # initialize + obj.model = obj.ModelClass(cfg_dict, verbose=verbose) # initialize obj.cfg = cfg return obj diff --git a/ultralytics/yolo/v8/models/seg/yolov8l-seg.yaml b/ultralytics/yolo/v8/models/seg/yolov8l-seg.yaml index b35838f..e3bb777 100644 --- a/ultralytics/yolo/v8/models/seg/yolov8l-seg.yaml +++ b/ultralytics/yolo/v8/models/seg/yolov8l-seg.yaml @@ -2,41 +2,39 @@ # Parameters nc: 80 # number of classes -depth_multiple: 1.00 # model depth multiple -width_multiple: 1.00 # layer channel multiple +depth_multiple: 1.00 # scales module repeats +width_multiple: 1.00 # scales convolution channels # YOLOv8.0l backbone backbone: - # [from, number, module, args] - [[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 3, C2f, [128, True]], - [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 6, C2f, [256, True]], - [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 6, C2f, [512, True]], - [-1, 1, Conv, [512, 3, 2]], # 7-P5/32 - [-1, 3, C2f, [512, True]], - [-1, 1, SPPF, [512, 5]], # 9 - ] + # [from, repeats, module, args] + - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 + - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 + - [-1, 3, C2f, [128, True]] + - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 + - [-1, 6, C2f, [256, True]] + - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 + - [-1, 6, C2f, [512, True]] + - [-1, 1, Conv, [512, 3, 2]] # 7-P5/32 + - [-1, 3, C2f, [512, True]] + - [-1, 1, SPPF, [512, 5]] # 9 # YOLOv8.0l head head: - [[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 6], 1, Concat, [1]], # cat backbone P4 - [-1, 3, C2f, [512]], # 13 + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 6], 1, Concat, [1]] # cat backbone P4 + - [-1, 3, C2f, [512]] # 13 - [-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 4], 1, Concat, [1]], # cat backbone P3 - [-1, 3, C2f, [256]], # 17 (P3/8-small) + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 4], 1, Concat, [1]] # cat backbone P3 + - [-1, 3, C2f, [256]] # 17 (P3/8-small) - [-1, 1, Conv, [256, 3, 2]], - [[-1, 12], 1, Concat, [1]], # cat head P4 - [-1, 3, C2f, [512]], # 20 (P4/16-medium) + - [-1, 1, Conv, [256, 3, 2]] + - [[-1, 12], 1, Concat, [1]] # cat head P4 + - [-1, 3, C2f, [512]] # 20 (P4/16-medium) - [-1, 1, Conv, [512, 3, 2]], - [[-1, 9], 1, Concat, [1]], # cat head P5 - [-1, 3, C2f, [512]], # 23 (P5/32-large) + - [-1, 1, Conv, [512, 3, 2]] + - [[-1, 9], 1, Concat, [1]] # cat head P5 + - [-1, 3, C2f, [512]] # 23 (P5/32-large) - [[15, 18, 21], 1, Segment, [nc, 32, 256]], # Detect(P3, P4, P5) - ] + - [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Detect(P3, P4, P5) diff --git a/ultralytics/yolo/v8/models/seg/yolov8m-seg.yaml b/ultralytics/yolo/v8/models/seg/yolov8m-seg.yaml index 09084c0..d91ca5b 100644 --- a/ultralytics/yolo/v8/models/seg/yolov8m-seg.yaml +++ b/ultralytics/yolo/v8/models/seg/yolov8m-seg.yaml @@ -2,41 +2,39 @@ # Parameters nc: 80 # number of classes -depth_multiple: 0.67 # model depth multiple -width_multiple: 0.75 # layer channel multiple +depth_multiple: 0.67 # scales module repeats +width_multiple: 0.75 # scales convolution channels # YOLOv8.0m backbone backbone: - # [from, number, module, args] - [[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 3, C2f, [128, True]], - [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 6, C2f, [256, True]], - [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 6, C2f, [512, True]], - [-1, 1, Conv, [768, 3, 2]], # 7-P5/32 - [-1, 3, C2f, [768, True]], - [-1, 1, SPPF, [768, 5]], # 9 - ] + # [from, repeats, module, args] + - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 + - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 + - [-1, 3, C2f, [128, True]] + - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 + - [-1, 6, C2f, [256, True]] + - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 + - [-1, 6, C2f, [512, True]] + - [-1, 1, Conv, [768, 3, 2]] # 7-P5/32 + - [-1, 3, C2f, [768, True]] + - [-1, 1, SPPF, [768, 5]] # 9 # YOLOv8.0m head head: - [[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 6], 1, Concat, [1]], # cat backbone P4 - [-1, 3, C2f, [512]], # 13 + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 6], 1, Concat, [1]] # cat backbone P4 + - [-1, 3, C2f, [512]] # 13 - [-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 4], 1, Concat, [1]], # cat backbone P3 - [-1, 3, C2f, [256]], # 17 (P3/8-small) + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 4], 1, Concat, [1]] # cat backbone P3 + - [-1, 3, C2f, [256]] # 17 (P3/8-small) - [-1, 1, Conv, [256, 3, 2]], - [[-1, 12], 1, Concat, [1]], # cat head P4 - [-1, 3, C2f, [512]], # 20 (P4/16-medium) + - [-1, 1, Conv, [256, 3, 2]] + - [[-1, 12], 1, Concat, [1]] # cat head P4 + - [-1, 3, C2f, [512]] # 20 (P4/16-medium) - [-1, 1, Conv, [512, 3, 2]], - [[-1, 9], 1, Concat, [1]], # cat head P5 - [-1, 3, C2f, [768]], # 23 (P5/32-large) + - [-1, 1, Conv, [512, 3, 2]] + - [[-1, 9], 1, Concat, [1]] # cat head P5 + - [-1, 3, C2f, [768]] # 23 (P5/32-large) - [[15, 18, 21], 1, Segment, [nc, 32, 256]], # Detect(P3, P4, P5) - ] + - [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Detect(P3, P4, P5) diff --git a/ultralytics/yolo/v8/models/seg/yolov8n-seg.yaml b/ultralytics/yolo/v8/models/seg/yolov8n-seg.yaml index b8e4025..3ac78db 100644 --- a/ultralytics/yolo/v8/models/seg/yolov8n-seg.yaml +++ b/ultralytics/yolo/v8/models/seg/yolov8n-seg.yaml @@ -2,41 +2,39 @@ # Parameters nc: 80 # number of classes -depth_multiple: 0.33 # model depth multiple -width_multiple: 0.25 # layer channel multiple +depth_multiple: 0.33 # scales module repeats +width_multiple: 0.25 # scales convolution channels # YOLOv8.0n backbone backbone: - # [from, number, module, args] - [[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 3, C2f, [128, True]], - [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 6, C2f, [256, True]], - [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 6, C2f, [512, True]], - [-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 - [-1, 3, C2f, [1024, True]], - [-1, 1, SPPF, [1024, 5]], # 9 - ] + # [from, repeats, module, args] + - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 + - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 + - [-1, 3, C2f, [128, True]] + - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 + - [-1, 6, C2f, [256, True]] + - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 + - [-1, 6, C2f, [512, True]] + - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32 + - [-1, 3, C2f, [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, 3, C2f, [512]], # 13 + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 6], 1, Concat, [1]] # cat backbone P4 + - [-1, 3, C2f, [512]] # 13 - [-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 4], 1, Concat, [1]], # cat backbone P3 - [-1, 3, C2f, [256]], # 17 (P3/8-small) + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 4], 1, Concat, [1]] # cat backbone P3 + - [-1, 3, C2f, [256]] # 17 (P3/8-small) - [-1, 1, Conv, [256, 3, 2]], - [[-1, 12], 1, Concat, [1]], # cat head P4 - [-1, 3, C2f, [512]], # 20 (P4/16-medium) + - [-1, 1, Conv, [256, 3, 2]] + - [[-1, 12], 1, Concat, [1]] # cat head P4 + - [-1, 3, C2f, [512]] # 20 (P4/16-medium) - [-1, 1, Conv, [512, 3, 2]], - [[-1, 9], 1, Concat, [1]], # cat head P5 - [-1, 3, C2f, [1024]], # 23 (P5/32-large) + - [-1, 1, Conv, [512, 3, 2]] + - [[-1, 9], 1, Concat, [1]] # cat head P5 + - [-1, 3, C2f, [1024]] # 23 (P5/32-large) - [[15, 18, 21], 1, Segment, [nc, 32, 256]], # Detect(P3, P4, P5) - ] + - [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Detect(P3, P4, P5) diff --git a/ultralytics/yolo/v8/models/seg/yolov8s-seg.yaml b/ultralytics/yolo/v8/models/seg/yolov8s-seg.yaml index 9cdbb9f..3b2ebe4 100644 --- a/ultralytics/yolo/v8/models/seg/yolov8s-seg.yaml +++ b/ultralytics/yolo/v8/models/seg/yolov8s-seg.yaml @@ -2,41 +2,39 @@ # Parameters nc: 80 # number of classes -depth_multiple: 0.33 # model depth multiple -width_multiple: 0.50 # layer channel multiple +depth_multiple: 0.33 # scales module repeats +width_multiple: 0.50 # scales convolution channels # YOLOv8.0s backbone backbone: - # [from, number, module, args] - [[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 3, C2f, [128, True]], - [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 6, C2f, [256, True]], - [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 6, C2f, [512, True]], - [-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 - [-1, 3, C2f, [1024, True]], - [-1, 1, SPPF, [1024, 5]], # 9 - ] + # [from, repeats, module, args] + - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 + - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 + - [-1, 3, C2f, [128, True]] + - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 + - [-1, 6, C2f, [256, True]] + - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 + - [-1, 6, C2f, [512, True]] + - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32 + - [-1, 3, C2f, [1024, True]] + - [-1, 1, SPPF, [1024, 5]] # 9 # YOLOv8.0s head head: - [[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 6], 1, Concat, [1]], # cat backbone P4 - [-1, 3, C2f, [512]], # 13 + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 6], 1, Concat, [1]] # cat backbone P4 + - [-1, 3, C2f, [512]] # 13 - [-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 4], 1, Concat, [1]], # cat backbone P3 - [-1, 3, C2f, [256]], # 17 (P3/8-small) + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 4], 1, Concat, [1]] # cat backbone P3 + - [-1, 3, C2f, [256]] # 17 (P3/8-small) - [-1, 1, Conv, [256, 3, 2]], - [[-1, 12], 1, Concat, [1]], # cat head P4 - [-1, 3, C2f, [512]], # 20 (P4/16-medium) + - [-1, 1, Conv, [256, 3, 2]] + - [[-1, 12], 1, Concat, [1]] # cat head P4 + - [-1, 3, C2f, [512]] # 20 (P4/16-medium) - [-1, 1, Conv, [512, 3, 2]], - [[-1, 9], 1, Concat, [1]], # cat head P5 - [-1, 3, C2f, [1024]], # 23 (P5/32-large) + - [-1, 1, Conv, [512, 3, 2]] + - [[-1, 9], 1, Concat, [1]] # cat head P5 + - [-1, 3, C2f, [1024]] # 23 (P5/32-large) - [[15, 18, 21], 1, Segment, [nc, 32, 256]], # Detect(P3, P4, P5) - ] + - [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Detect(P3, P4, P5) diff --git a/ultralytics/yolo/v8/models/seg/yolov8x-seg.yaml b/ultralytics/yolo/v8/models/seg/yolov8x-seg.yaml index 42f3e47..646e187 100644 --- a/ultralytics/yolo/v8/models/seg/yolov8x-seg.yaml +++ b/ultralytics/yolo/v8/models/seg/yolov8x-seg.yaml @@ -2,41 +2,39 @@ # Parameters nc: 80 # number of classes -depth_multiple: 1.00 # model depth multiple -width_multiple: 1.25 # layer channel multiple +depth_multiple: 1.00 # scales module repeats +width_multiple: 1.25 # scales convolution channels # YOLOv8.0x backbone backbone: - # [from, number, module, args] - [[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 3, C2f, [128, True]], - [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 6, C2f, [256, True]], - [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 6, C2f, [512, True]], - [-1, 1, Conv, [512, 3, 2]], # 7-P5/32 - [-1, 3, C2f, [512, True]], - [-1, 1, SPPF, [512, 5]], # 9 - ] + # [from, repeats, module, args] + - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 + - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 + - [-1, 3, C2f, [128, True]] + - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 + - [-1, 6, C2f, [256, True]] + - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 + - [-1, 6, C2f, [512, True]] + - [-1, 1, Conv, [512, 3, 2]] # 7-P5/32 + - [-1, 3, C2f, [512, True]] + - [-1, 1, SPPF, [512, 5]] # 9 # YOLOv8.0x head head: - [[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 6], 1, Concat, [1]], # cat backbone P4 - [-1, 3, C2f, [512]], # 13 + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 6], 1, Concat, [1]] # cat backbone P4 + - [-1, 3, C2f, [512]] # 13 - [-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 4], 1, Concat, [1]], # cat backbone P3 - [-1, 3, C2f, [256]], # 17 (P3/8-small) + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 4], 1, Concat, [1]] # cat backbone P3 + - [-1, 3, C2f, [256]] # 17 (P3/8-small) - [-1, 1, Conv, [256, 3, 2]], - [[-1, 12], 1, Concat, [1]], # cat head P4 - [-1, 3, C2f, [512]], # 20 (P4/16-medium) + - [-1, 1, Conv, [256, 3, 2]] + - [[-1, 12], 1, Concat, [1]] # cat head P4 + - [-1, 3, C2f, [512]] # 20 (P4/16-medium) - [-1, 1, Conv, [512, 3, 2]], - [[-1, 9], 1, Concat, [1]], # cat head P5 - [-1, 3, C2f, [512]], # 23 (P5/32-large) + - [-1, 1, Conv, [512, 3, 2]] + - [[-1, 9], 1, Concat, [1]] # cat head P5 + - [-1, 3, C2f, [512]] # 23 (P5/32-large) - [[15, 18, 21], 1, Segment, [nc, 32, 256]], # Detect(P3, P4, P5) - ] + - [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Detect(P3, P4, P5) diff --git a/ultralytics/yolo/v8/models/yolov8l.yaml b/ultralytics/yolo/v8/models/yolov8l.yaml index 762b589..e8525f6 100644 --- a/ultralytics/yolo/v8/models/yolov8l.yaml +++ b/ultralytics/yolo/v8/models/yolov8l.yaml @@ -2,41 +2,39 @@ # Parameters nc: 80 # number of classes -depth_multiple: 1.00 # model depth multiple -width_multiple: 1.00 # layer channel multiple +depth_multiple: 1.00 # scales module repeats +width_multiple: 1.00 # scales convolution channels # YOLOv8.0l backbone backbone: - # [from, number, module, args] - [[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 3, C2f, [128, True]], - [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 6, C2f, [256, True]], - [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 6, C2f, [512, True]], - [-1, 1, Conv, [512, 3, 2]], # 7-P5/32 - [-1, 3, C2f, [512, True]], - [-1, 1, SPPF, [512, 5]], # 9 - ] + # [from, repeats, module, args] + - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 + - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 + - [-1, 3, C2f, [128, True]] + - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 + - [-1, 6, C2f, [256, True]] + - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 + - [-1, 6, C2f, [512, True]] + - [-1, 1, Conv, [512, 3, 2]] # 7-P5/32 + - [-1, 3, C2f, [512, True]] + - [-1, 1, SPPF, [512, 5]] # 9 # YOLOv8.0l head head: - [[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 6], 1, Concat, [1]], # cat backbone P4 - [-1, 3, C2f, [512]], # 13 + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 6], 1, Concat, [1]] # cat backbone P4 + - [-1, 3, C2f, [512]] # 13 - [-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 4], 1, Concat, [1]], # cat backbone P3 - [-1, 3, C2f, [256]], # 17 (P3/8-small) + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 4], 1, Concat, [1]] # cat backbone P3 + - [-1, 3, C2f, [256]] # 17 (P3/8-small) - [-1, 1, Conv, [256, 3, 2]], - [[-1, 12], 1, Concat, [1]], # cat head P4 - [-1, 3, C2f, [512]], # 20 (P4/16-medium) + - [-1, 1, Conv, [256, 3, 2]] + - [[-1, 12], 1, Concat, [1]] # cat head P4 + - [-1, 3, C2f, [512]] # 20 (P4/16-medium) - [-1, 1, Conv, [512, 3, 2]], - [[-1, 9], 1, Concat, [1]], # cat head P5 - [-1, 3, C2f, [512]], # 23 (P5/32-large) + - [-1, 1, Conv, [512, 3, 2]] + - [[-1, 9], 1, Concat, [1]] # cat head P5 + - [-1, 3, C2f, [512]] # 23 (P5/32-large) - [[15, 18, 21], 1, Detect, [nc]], # Detect(P3, P4, P5) - ] + - [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4, P5) diff --git a/ultralytics/yolo/v8/models/yolov8m.yaml b/ultralytics/yolo/v8/models/yolov8m.yaml index 381b003..2f7d3bb 100644 --- a/ultralytics/yolo/v8/models/yolov8m.yaml +++ b/ultralytics/yolo/v8/models/yolov8m.yaml @@ -2,41 +2,39 @@ # Parameters nc: 80 # number of classes -depth_multiple: 0.67 # model depth multiple -width_multiple: 0.75 # layer channel multiple +depth_multiple: 0.67 # scales module repeats +width_multiple: 0.75 # scales convolution channels # YOLOv8.0m backbone backbone: - # [from, number, module, args] - [[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 3, C2f, [128, True]], - [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 6, C2f, [256, True]], - [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 6, C2f, [512, True]], - [-1, 1, Conv, [768, 3, 2]], # 7-P5/32 - [-1, 3, C2f, [768, True]], - [-1, 1, SPPF, [768, 5]], # 9 - ] + # [from, repeats, module, args] + - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 + - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 + - [-1, 3, C2f, [128, True]] + - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 + - [-1, 6, C2f, [256, True]] + - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 + - [-1, 6, C2f, [512, True]] + - [-1, 1, Conv, [768, 3, 2]] # 7-P5/32 + - [-1, 3, C2f, [768, True]] + - [-1, 1, SPPF, [768, 5]] # 9 # YOLOv8.0m head head: - [[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 6], 1, Concat, [1]], # cat backbone P4 - [-1, 3, C2f, [512]], # 13 + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 6], 1, Concat, [1]] # cat backbone P4 + - [-1, 3, C2f, [512]] # 13 - [-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 4], 1, Concat, [1]], # cat backbone P3 - [-1, 3, C2f, [256]], # 17 (P3/8-small) + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 4], 1, Concat, [1]] # cat backbone P3 + - [-1, 3, C2f, [256]] # 17 (P3/8-small) - [-1, 1, Conv, [256, 3, 2]], - [[-1, 12], 1, Concat, [1]], # cat head P4 - [-1, 3, C2f, [512]], # 20 (P4/16-medium) + - [-1, 1, Conv, [256, 3, 2]] + - [[-1, 12], 1, Concat, [1]] # cat head P4 + - [-1, 3, C2f, [512]] # 20 (P4/16-medium) - [-1, 1, Conv, [512, 3, 2]], - [[-1, 9], 1, Concat, [1]], # cat head P5 - [-1, 3, C2f, [768]], # 23 (P5/32-large) + - [-1, 1, Conv, [512, 3, 2]] + - [[-1, 9], 1, Concat, [1]] # cat head P5 + - [-1, 3, C2f, [768]] # 23 (P5/32-large) - [[15, 18, 21], 1, Detect, [nc]], # Detect(P3, P4, P5) - ] + - [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4, P5) diff --git a/ultralytics/yolo/v8/models/yolov8n.yaml b/ultralytics/yolo/v8/models/yolov8n.yaml index ba0fcee..f0f9481 100644 --- a/ultralytics/yolo/v8/models/yolov8n.yaml +++ b/ultralytics/yolo/v8/models/yolov8n.yaml @@ -2,41 +2,39 @@ # Parameters nc: 80 # number of classes -depth_multiple: 0.33 # model depth multiple -width_multiple: 0.25 # layer channel multiple +depth_multiple: 0.33 # scales module repeats +width_multiple: 0.25 # scales convolution channels # YOLOv8.0n backbone backbone: - # [from, number, module, args] - [[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 3, C2f, [128, True]], - [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 6, C2f, [256, True]], - [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 6, C2f, [512, True]], - [-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 - [-1, 3, C2f, [1024, True]], - [-1, 1, SPPF, [1024, 5]], # 9 - ] + # [from, repeats, module, args] + - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 + - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 + - [-1, 3, C2f, [128, True]] + - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 + - [-1, 6, C2f, [256, True]] + - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 + - [-1, 6, C2f, [512, True]] + - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32 + - [-1, 3, C2f, [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, 3, C2f, [512]], # 13 + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 6], 1, Concat, [1]] # cat backbone P4 + - [-1, 3, C2f, [512]] # 13 - [-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 4], 1, Concat, [1]], # cat backbone P3 - [-1, 3, C2f, [256]], # 17 (P3/8-small) + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 4], 1, Concat, [1]] # cat backbone P3 + - [-1, 3, C2f, [256]] # 17 (P3/8-small) - [-1, 1, Conv, [256, 3, 2]], - [[-1, 12], 1, Concat, [1]], # cat head P4 - [-1, 3, C2f, [512]], # 20 (P4/16-medium) + - [-1, 1, Conv, [256, 3, 2]] + - [[-1, 12], 1, Concat, [1]] # cat head P4 + - [-1, 3, C2f, [512]] # 20 (P4/16-medium) - [-1, 1, Conv, [512, 3, 2]], - [[-1, 9], 1, Concat, [1]], # cat head P5 - [-1, 3, C2f, [1024]], # 23 (P5/32-large) + - [-1, 1, Conv, [512, 3, 2]] + - [[-1, 9], 1, Concat, [1]] # cat head P5 + - [-1, 3, C2f, [1024]] # 23 (P5/32-large) - [[15, 18, 21], 1, Detect, [nc]], # Detect(P3, P4, P5) - ] + - [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4, P5) diff --git a/ultralytics/yolo/v8/models/yolov8s.yaml b/ultralytics/yolo/v8/models/yolov8s.yaml index c946d8d..be621c9 100644 --- a/ultralytics/yolo/v8/models/yolov8s.yaml +++ b/ultralytics/yolo/v8/models/yolov8s.yaml @@ -2,41 +2,39 @@ # Parameters nc: 80 # number of classes -depth_multiple: 0.33 # model depth multiple -width_multiple: 0.50 # layer channel multiple +depth_multiple: 0.33 # scales module repeats +width_multiple: 0.50 # scales convolution channels # YOLOv8.0s backbone backbone: - # [from, number, module, args] - [[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 3, C2f, [128, True]], - [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 6, C2f, [256, True]], - [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 6, C2f, [512, True]], - [-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 - [-1, 3, C2f, [1024, True]], - [-1, 1, SPPF, [1024, 5]], # 9 - ] + # [from, repeats, module, args] + - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 + - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 + - [-1, 3, C2f, [128, True]] + - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 + - [-1, 6, C2f, [256, True]] + - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 + - [-1, 6, C2f, [512, True]] + - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32 + - [-1, 3, C2f, [1024, True]] + - [-1, 1, SPPF, [1024, 5]] # 9 # YOLOv8.0s head head: - [[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 6], 1, Concat, [1]], # cat backbone P4 - [-1, 3, C2f, [512]], # 13 + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 6], 1, Concat, [1]] # cat backbone P4 + - [-1, 3, C2f, [512]] # 13 - [-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 4], 1, Concat, [1]], # cat backbone P3 - [-1, 3, C2f, [256]], # 17 (P3/8-small) + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 4], 1, Concat, [1]] # cat backbone P3 + - [-1, 3, C2f, [256]] # 17 (P3/8-small) - [-1, 1, Conv, [256, 3, 2]], - [[-1, 12], 1, Concat, [1]], # cat head P4 - [-1, 3, C2f, [512]], # 20 (P4/16-medium) + - [-1, 1, Conv, [256, 3, 2]] + - [[-1, 12], 1, Concat, [1]] # cat head P4 + - [-1, 3, C2f, [512]] # 20 (P4/16-medium) - [-1, 1, Conv, [512, 3, 2]], - [[-1, 9], 1, Concat, [1]], # cat head P5 - [-1, 3, C2f, [1024]], # 23 (P5/32-large) + - [-1, 1, Conv, [512, 3, 2]] + - [[-1, 9], 1, Concat, [1]] # cat head P5 + - [-1, 3, C2f, [1024]] # 23 (P5/32-large) - [[15, 18, 21], 1, Detect, [nc]], # Detect(P3, P4, P5) - ] + - [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4, P5) diff --git a/ultralytics/yolo/v8/models/yolov8x.yaml b/ultralytics/yolo/v8/models/yolov8x.yaml index d484e85..3732e2e 100644 --- a/ultralytics/yolo/v8/models/yolov8x.yaml +++ b/ultralytics/yolo/v8/models/yolov8x.yaml @@ -2,41 +2,39 @@ # Parameters nc: 80 # number of classes -depth_multiple: 1.00 # model depth multiple -width_multiple: 1.25 # layer channel multiple +depth_multiple: 1.00 # scales module repeats +width_multiple: 1.25 # scales convolution channels # YOLOv8.0x backbone backbone: - # [from, number, module, args] - [[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 3, C2f, [128, True]], - [-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 6, C2f, [256, True]], - [-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 6, C2f, [512, True]], - [-1, 1, Conv, [512, 3, 2]], # 7-P5/32 - [-1, 3, C2f, [512, True]], - [-1, 1, SPPF, [512, 5]], # 9 - ] + # [from, repeats, module, args] + - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 + - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 + - [-1, 3, C2f, [128, True]] + - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 + - [-1, 6, C2f, [256, True]] + - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 + - [-1, 6, C2f, [512, True]] + - [-1, 1, Conv, [512, 3, 2]] # 7-P5/32 + - [-1, 3, C2f, [512, True]] + - [-1, 1, SPPF, [512, 5]] # 9 # YOLOv8.0x head head: - [[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 6], 1, Concat, [1]], # cat backbone P4 - [-1, 3, C2f, [512]], # 13 + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 6], 1, Concat, [1]] # cat backbone P4 + - [-1, 3, C2f, [512]] # 13 - [-1, 1, nn.Upsample, [None, 2, 'nearest']], - [[-1, 4], 1, Concat, [1]], # cat backbone P3 - [-1, 3, C2f, [256]], # 17 (P3/8-small) + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 4], 1, Concat, [1]] # cat backbone P3 + - [-1, 3, C2f, [256]] # 17 (P3/8-small) - [-1, 1, Conv, [256, 3, 2]], - [[-1, 12], 1, Concat, [1]], # cat head P4 - [-1, 3, C2f, [512]], # 20 (P4/16-medium) + - [-1, 1, Conv, [256, 3, 2]] + - [[-1, 12], 1, Concat, [1]] # cat head P4 + - [-1, 3, C2f, [512]] # 20 (P4/16-medium) - [-1, 1, Conv, [512, 3, 2]], - [[-1, 9], 1, Concat, [1]], # cat head P5 - [-1, 3, C2f, [512]], # 23 (P5/32-large) + - [-1, 1, Conv, [512, 3, 2]] + - [[-1, 9], 1, Concat, [1]] # cat head P5 + - [-1, 3, C2f, [512]] # 23 (P5/32-large) - [[15, 18, 21], 1, Detect, [nc]], # Detect(P3, P4, P5) - ] + - [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4, P5) diff --git a/ultralytics/yolo/v8/models/yolov8x6.yaml b/ultralytics/yolo/v8/models/yolov8x6.yaml new file mode 100644 index 0000000..b2e72ed --- /dev/null +++ b/ultralytics/yolo/v8/models/yolov8x6.yaml @@ -0,0 +1,50 @@ +# YOLOv5 🚀 by Ultralytics, GPL-3.0 license + +# Parameters +nc: 80 # number of classes +depth_multiple: 1.00 # scales module repeats +width_multiple: 1.25 # scales convolution channels + +# YOLOv8.0x6 backbone +backbone: + # [from, repeats, module, args] + - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2 + - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4 + - [-1, 3, C2f, [128, True]] + - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8 + - [-1, 6, C2f, [256, True]] + - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16 + - [-1, 6, C2f, [512, True]] + - [-1, 1, Conv, [512, 3, 2]] # 7-P5/32 + - [-1, 3, C2f, [512, True]] + - [-1, 1, Conv, [512, 3, 2]] # 9-P6/64 + - [-1, 3, C2f, [512, True]] + - [-1, 1, SPPF, [512, 5]] # 11 + +# YOLOv8.0x6 head +head: + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 8], 1, Concat, [1]] # cat backbone P5 + - [-1, 3, C2, [512, False]] # 14 + + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 6], 1, Concat, [1]] # cat backbone P4 + - [-1, 3, C2, [512, False]] # 17 + + - [-1, 1, nn.Upsample, [None, 2, 'nearest']] + - [[-1, 4], 1, Concat, [1]] # cat backbone P3 + - [-1, 3, C2, [256, False]] # 20 (P3/8-small) + + - [-1, 1, Conv, [256, 3, 2]] + - [[-1, 17], 1, Concat, [1]] # cat head P4 + - [-1, 3, C2, [512, False]] # 23 (P4/16-medium) + + - [-1, 1, Conv, [512, 3, 2]] + - [[-1, 14], 1, Concat, [1]] # cat head P5 + - [-1, 3, C2, [512, False]] # 26 (P5/32-large) + + - [-1, 1, Conv, [512, 3, 2]] + - [[-1, 11], 1, Concat, [1]] # cat head P6 + - [-1, 3, C2, [512, False]] # 29 (P6/64-xlarge) + + - [[20, 23, 26, 29], 1, Detect, [nc]] # Detect(P3, P4, P5, P6)