Add YOLO8x6 and YAML syntax improvements (#120)

single_channel
Glenn Jocher 2 years ago committed by GitHub
parent 076d73cfaa
commit fec13ec773
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,16 +1,12 @@
from ultralytics import YOLO from ultralytics import YOLO
from ultralytics.yolo.utils import ROOT
if __name__ == "__main__": if __name__ == "__main__":
YOLO.new("yolov8n.yaml") for m in list((ROOT / 'yolo/v8/models').rglob('*.yaml')):
YOLO.new("yolov8n-seg.yaml") try:
YOLO.new("yolov8s.yaml") YOLO.new(m.name, verbose=True)
YOLO.new("yolov8s-seg.yaml") except Exception as e:
YOLO.new("yolov8m.yaml") print(f'ERROR for {m}: {e}')
YOLO.new("yolov8m-seg.yaml")
YOLO.new("yolov8l.yaml")
YOLO.new("yolov8l-seg.yaml")
YOLO.new("yolov8x.yaml")
YOLO.new("yolov8x-seg.yaml")
# n vs n-seg: 8.9GFLOPs vs 12.8GFLOPs, 3.16M vs 3.6M. ch[0] // 4 (11.9GFLOPs, 3.39M) # 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) # s vs s-seg: 28.8GFLOPs vs 44.4GFLOPs, 11.1M vs 12.9M. ch[0] // 4 (39.5GFLOPs, 11.7M)

@ -52,19 +52,20 @@ class YOLO:
self.init_disabled = False self.init_disabled = False
@classmethod @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 Initializes a new model and infers the task type from the model definitions
Args: Args:
cfg (str): model configuration file cfg (str): model configuration file
verbsoe (bool): display model info on load
""" """
cfg = check_yaml(cfg) # check YAML cfg = check_yaml(cfg) # check YAML
cfg_dict = yaml_load(cfg) # model dict cfg_dict = yaml_load(cfg) # model dict
obj = cls(init_key=cls.__init_key) obj = cls(init_key=cls.__init_key)
obj.task = obj._guess_task_from_head(cfg_dict["head"][-1][-2]) 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.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 obj.cfg = cfg
return obj return obj

@ -2,41 +2,39 @@
# Parameters # Parameters
nc: 80 # number of classes nc: 80 # number of classes
depth_multiple: 1.00 # model depth multiple depth_multiple: 1.00 # scales module repeats
width_multiple: 1.00 # layer channel multiple width_multiple: 1.00 # scales convolution channels
# YOLOv8.0l backbone # YOLOv8.0l backbone
backbone: backbone:
# [from, number, module, args] # [from, repeats, module, args]
[[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
[-1, 3, C2f, [128, True]], - [-1, 3, C2f, [128, True]]
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
[-1, 6, C2f, [256, True]], - [-1, 6, C2f, [256, True]]
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
[-1, 6, C2f, [512, True]], - [-1, 6, C2f, [512, True]]
[-1, 1, Conv, [512, 3, 2]], # 7-P5/32 - [-1, 1, Conv, [512, 3, 2]] # 7-P5/32
[-1, 3, C2f, [512, True]], - [-1, 3, C2f, [512, True]]
[-1, 1, SPPF, [512, 5]], # 9 - [-1, 1, SPPF, [512, 5]] # 9
]
# YOLOv8.0l head # YOLOv8.0l head
head: head:
[[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 6], 1, Concat, [1]], # cat backbone P4 - [[-1, 6], 1, Concat, [1]] # cat backbone P4
[-1, 3, C2f, [512]], # 13 - [-1, 3, C2f, [512]] # 13
[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 4], 1, Concat, [1]], # cat backbone P3 - [[-1, 4], 1, Concat, [1]] # cat backbone P3
[-1, 3, C2f, [256]], # 17 (P3/8-small) - [-1, 3, C2f, [256]] # 17 (P3/8-small)
[-1, 1, Conv, [256, 3, 2]], - [-1, 1, Conv, [256, 3, 2]]
[[-1, 12], 1, Concat, [1]], # cat head P4 - [[-1, 12], 1, Concat, [1]] # cat head P4
[-1, 3, C2f, [512]], # 20 (P4/16-medium) - [-1, 3, C2f, [512]] # 20 (P4/16-medium)
[-1, 1, Conv, [512, 3, 2]], - [-1, 1, Conv, [512, 3, 2]]
[[-1, 9], 1, Concat, [1]], # cat head P5 - [[-1, 9], 1, Concat, [1]] # cat head P5
[-1, 3, C2f, [512]], # 23 (P5/32-large) - [-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)
]

@ -2,41 +2,39 @@
# Parameters # Parameters
nc: 80 # number of classes nc: 80 # number of classes
depth_multiple: 0.67 # model depth multiple depth_multiple: 0.67 # scales module repeats
width_multiple: 0.75 # layer channel multiple width_multiple: 0.75 # scales convolution channels
# YOLOv8.0m backbone # YOLOv8.0m backbone
backbone: backbone:
# [from, number, module, args] # [from, repeats, module, args]
[[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
[-1, 3, C2f, [128, True]], - [-1, 3, C2f, [128, True]]
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
[-1, 6, C2f, [256, True]], - [-1, 6, C2f, [256, True]]
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
[-1, 6, C2f, [512, True]], - [-1, 6, C2f, [512, True]]
[-1, 1, Conv, [768, 3, 2]], # 7-P5/32 - [-1, 1, Conv, [768, 3, 2]] # 7-P5/32
[-1, 3, C2f, [768, True]], - [-1, 3, C2f, [768, True]]
[-1, 1, SPPF, [768, 5]], # 9 - [-1, 1, SPPF, [768, 5]] # 9
]
# YOLOv8.0m head # YOLOv8.0m head
head: head:
[[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 6], 1, Concat, [1]], # cat backbone P4 - [[-1, 6], 1, Concat, [1]] # cat backbone P4
[-1, 3, C2f, [512]], # 13 - [-1, 3, C2f, [512]] # 13
[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 4], 1, Concat, [1]], # cat backbone P3 - [[-1, 4], 1, Concat, [1]] # cat backbone P3
[-1, 3, C2f, [256]], # 17 (P3/8-small) - [-1, 3, C2f, [256]] # 17 (P3/8-small)
[-1, 1, Conv, [256, 3, 2]], - [-1, 1, Conv, [256, 3, 2]]
[[-1, 12], 1, Concat, [1]], # cat head P4 - [[-1, 12], 1, Concat, [1]] # cat head P4
[-1, 3, C2f, [512]], # 20 (P4/16-medium) - [-1, 3, C2f, [512]] # 20 (P4/16-medium)
[-1, 1, Conv, [512, 3, 2]], - [-1, 1, Conv, [512, 3, 2]]
[[-1, 9], 1, Concat, [1]], # cat head P5 - [[-1, 9], 1, Concat, [1]] # cat head P5
[-1, 3, C2f, [768]], # 23 (P5/32-large) - [-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)
]

@ -2,41 +2,39 @@
# Parameters # Parameters
nc: 80 # number of classes nc: 80 # number of classes
depth_multiple: 0.33 # model depth multiple depth_multiple: 0.33 # scales module repeats
width_multiple: 0.25 # layer channel multiple width_multiple: 0.25 # scales convolution channels
# YOLOv8.0n backbone # YOLOv8.0n backbone
backbone: backbone:
# [from, number, module, args] # [from, repeats, module, args]
[[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
[-1, 3, C2f, [128, True]], - [-1, 3, C2f, [128, True]]
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
[-1, 6, C2f, [256, True]], - [-1, 6, C2f, [256, True]]
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
[-1, 6, C2f, [512, True]], - [-1, 6, C2f, [512, True]]
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32
[-1, 3, C2f, [1024, True]], - [-1, 3, C2f, [1024, True]]
[-1, 1, SPPF, [1024, 5]], # 9 - [-1, 1, SPPF, [1024, 5]] # 9
]
# YOLOv8.0n head # YOLOv8.0n head
head: head:
[[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 6], 1, Concat, [1]], # cat backbone P4 - [[-1, 6], 1, Concat, [1]] # cat backbone P4
[-1, 3, C2f, [512]], # 13 - [-1, 3, C2f, [512]] # 13
[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 4], 1, Concat, [1]], # cat backbone P3 - [[-1, 4], 1, Concat, [1]] # cat backbone P3
[-1, 3, C2f, [256]], # 17 (P3/8-small) - [-1, 3, C2f, [256]] # 17 (P3/8-small)
[-1, 1, Conv, [256, 3, 2]], - [-1, 1, Conv, [256, 3, 2]]
[[-1, 12], 1, Concat, [1]], # cat head P4 - [[-1, 12], 1, Concat, [1]] # cat head P4
[-1, 3, C2f, [512]], # 20 (P4/16-medium) - [-1, 3, C2f, [512]] # 20 (P4/16-medium)
[-1, 1, Conv, [512, 3, 2]], - [-1, 1, Conv, [512, 3, 2]]
[[-1, 9], 1, Concat, [1]], # cat head P5 - [[-1, 9], 1, Concat, [1]] # cat head P5
[-1, 3, C2f, [1024]], # 23 (P5/32-large) - [-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)
]

@ -2,41 +2,39 @@
# Parameters # Parameters
nc: 80 # number of classes nc: 80 # number of classes
depth_multiple: 0.33 # model depth multiple depth_multiple: 0.33 # scales module repeats
width_multiple: 0.50 # layer channel multiple width_multiple: 0.50 # scales convolution channels
# YOLOv8.0s backbone # YOLOv8.0s backbone
backbone: backbone:
# [from, number, module, args] # [from, repeats, module, args]
[[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
[-1, 3, C2f, [128, True]], - [-1, 3, C2f, [128, True]]
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
[-1, 6, C2f, [256, True]], - [-1, 6, C2f, [256, True]]
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
[-1, 6, C2f, [512, True]], - [-1, 6, C2f, [512, True]]
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32
[-1, 3, C2f, [1024, True]], - [-1, 3, C2f, [1024, True]]
[-1, 1, SPPF, [1024, 5]], # 9 - [-1, 1, SPPF, [1024, 5]] # 9
]
# YOLOv8.0s head # YOLOv8.0s head
head: head:
[[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 6], 1, Concat, [1]], # cat backbone P4 - [[-1, 6], 1, Concat, [1]] # cat backbone P4
[-1, 3, C2f, [512]], # 13 - [-1, 3, C2f, [512]] # 13
[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 4], 1, Concat, [1]], # cat backbone P3 - [[-1, 4], 1, Concat, [1]] # cat backbone P3
[-1, 3, C2f, [256]], # 17 (P3/8-small) - [-1, 3, C2f, [256]] # 17 (P3/8-small)
[-1, 1, Conv, [256, 3, 2]], - [-1, 1, Conv, [256, 3, 2]]
[[-1, 12], 1, Concat, [1]], # cat head P4 - [[-1, 12], 1, Concat, [1]] # cat head P4
[-1, 3, C2f, [512]], # 20 (P4/16-medium) - [-1, 3, C2f, [512]] # 20 (P4/16-medium)
[-1, 1, Conv, [512, 3, 2]], - [-1, 1, Conv, [512, 3, 2]]
[[-1, 9], 1, Concat, [1]], # cat head P5 - [[-1, 9], 1, Concat, [1]] # cat head P5
[-1, 3, C2f, [1024]], # 23 (P5/32-large) - [-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)
]

@ -2,41 +2,39 @@
# Parameters # Parameters
nc: 80 # number of classes nc: 80 # number of classes
depth_multiple: 1.00 # model depth multiple depth_multiple: 1.00 # scales module repeats
width_multiple: 1.25 # layer channel multiple width_multiple: 1.25 # scales convolution channels
# YOLOv8.0x backbone # YOLOv8.0x backbone
backbone: backbone:
# [from, number, module, args] # [from, repeats, module, args]
[[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
[-1, 3, C2f, [128, True]], - [-1, 3, C2f, [128, True]]
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
[-1, 6, C2f, [256, True]], - [-1, 6, C2f, [256, True]]
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
[-1, 6, C2f, [512, True]], - [-1, 6, C2f, [512, True]]
[-1, 1, Conv, [512, 3, 2]], # 7-P5/32 - [-1, 1, Conv, [512, 3, 2]] # 7-P5/32
[-1, 3, C2f, [512, True]], - [-1, 3, C2f, [512, True]]
[-1, 1, SPPF, [512, 5]], # 9 - [-1, 1, SPPF, [512, 5]] # 9
]
# YOLOv8.0x head # YOLOv8.0x head
head: head:
[[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 6], 1, Concat, [1]], # cat backbone P4 - [[-1, 6], 1, Concat, [1]] # cat backbone P4
[-1, 3, C2f, [512]], # 13 - [-1, 3, C2f, [512]] # 13
[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 4], 1, Concat, [1]], # cat backbone P3 - [[-1, 4], 1, Concat, [1]] # cat backbone P3
[-1, 3, C2f, [256]], # 17 (P3/8-small) - [-1, 3, C2f, [256]] # 17 (P3/8-small)
[-1, 1, Conv, [256, 3, 2]], - [-1, 1, Conv, [256, 3, 2]]
[[-1, 12], 1, Concat, [1]], # cat head P4 - [[-1, 12], 1, Concat, [1]] # cat head P4
[-1, 3, C2f, [512]], # 20 (P4/16-medium) - [-1, 3, C2f, [512]] # 20 (P4/16-medium)
[-1, 1, Conv, [512, 3, 2]], - [-1, 1, Conv, [512, 3, 2]]
[[-1, 9], 1, Concat, [1]], # cat head P5 - [[-1, 9], 1, Concat, [1]] # cat head P5
[-1, 3, C2f, [512]], # 23 (P5/32-large) - [-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)
]

@ -2,41 +2,39 @@
# Parameters # Parameters
nc: 80 # number of classes nc: 80 # number of classes
depth_multiple: 1.00 # model depth multiple depth_multiple: 1.00 # scales module repeats
width_multiple: 1.00 # layer channel multiple width_multiple: 1.00 # scales convolution channels
# YOLOv8.0l backbone # YOLOv8.0l backbone
backbone: backbone:
# [from, number, module, args] # [from, repeats, module, args]
[[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
[-1, 3, C2f, [128, True]], - [-1, 3, C2f, [128, True]]
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
[-1, 6, C2f, [256, True]], - [-1, 6, C2f, [256, True]]
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
[-1, 6, C2f, [512, True]], - [-1, 6, C2f, [512, True]]
[-1, 1, Conv, [512, 3, 2]], # 7-P5/32 - [-1, 1, Conv, [512, 3, 2]] # 7-P5/32
[-1, 3, C2f, [512, True]], - [-1, 3, C2f, [512, True]]
[-1, 1, SPPF, [512, 5]], # 9 - [-1, 1, SPPF, [512, 5]] # 9
]
# YOLOv8.0l head # YOLOv8.0l head
head: head:
[[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 6], 1, Concat, [1]], # cat backbone P4 - [[-1, 6], 1, Concat, [1]] # cat backbone P4
[-1, 3, C2f, [512]], # 13 - [-1, 3, C2f, [512]] # 13
[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 4], 1, Concat, [1]], # cat backbone P3 - [[-1, 4], 1, Concat, [1]] # cat backbone P3
[-1, 3, C2f, [256]], # 17 (P3/8-small) - [-1, 3, C2f, [256]] # 17 (P3/8-small)
[-1, 1, Conv, [256, 3, 2]], - [-1, 1, Conv, [256, 3, 2]]
[[-1, 12], 1, Concat, [1]], # cat head P4 - [[-1, 12], 1, Concat, [1]] # cat head P4
[-1, 3, C2f, [512]], # 20 (P4/16-medium) - [-1, 3, C2f, [512]] # 20 (P4/16-medium)
[-1, 1, Conv, [512, 3, 2]], - [-1, 1, Conv, [512, 3, 2]]
[[-1, 9], 1, Concat, [1]], # cat head P5 - [[-1, 9], 1, Concat, [1]] # cat head P5
[-1, 3, C2f, [512]], # 23 (P5/32-large) - [-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)
]

@ -2,41 +2,39 @@
# Parameters # Parameters
nc: 80 # number of classes nc: 80 # number of classes
depth_multiple: 0.67 # model depth multiple depth_multiple: 0.67 # scales module repeats
width_multiple: 0.75 # layer channel multiple width_multiple: 0.75 # scales convolution channels
# YOLOv8.0m backbone # YOLOv8.0m backbone
backbone: backbone:
# [from, number, module, args] # [from, repeats, module, args]
[[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
[-1, 3, C2f, [128, True]], - [-1, 3, C2f, [128, True]]
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
[-1, 6, C2f, [256, True]], - [-1, 6, C2f, [256, True]]
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
[-1, 6, C2f, [512, True]], - [-1, 6, C2f, [512, True]]
[-1, 1, Conv, [768, 3, 2]], # 7-P5/32 - [-1, 1, Conv, [768, 3, 2]] # 7-P5/32
[-1, 3, C2f, [768, True]], - [-1, 3, C2f, [768, True]]
[-1, 1, SPPF, [768, 5]], # 9 - [-1, 1, SPPF, [768, 5]] # 9
]
# YOLOv8.0m head # YOLOv8.0m head
head: head:
[[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 6], 1, Concat, [1]], # cat backbone P4 - [[-1, 6], 1, Concat, [1]] # cat backbone P4
[-1, 3, C2f, [512]], # 13 - [-1, 3, C2f, [512]] # 13
[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 4], 1, Concat, [1]], # cat backbone P3 - [[-1, 4], 1, Concat, [1]] # cat backbone P3
[-1, 3, C2f, [256]], # 17 (P3/8-small) - [-1, 3, C2f, [256]] # 17 (P3/8-small)
[-1, 1, Conv, [256, 3, 2]], - [-1, 1, Conv, [256, 3, 2]]
[[-1, 12], 1, Concat, [1]], # cat head P4 - [[-1, 12], 1, Concat, [1]] # cat head P4
[-1, 3, C2f, [512]], # 20 (P4/16-medium) - [-1, 3, C2f, [512]] # 20 (P4/16-medium)
[-1, 1, Conv, [512, 3, 2]], - [-1, 1, Conv, [512, 3, 2]]
[[-1, 9], 1, Concat, [1]], # cat head P5 - [[-1, 9], 1, Concat, [1]] # cat head P5
[-1, 3, C2f, [768]], # 23 (P5/32-large) - [-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)
]

@ -2,41 +2,39 @@
# Parameters # Parameters
nc: 80 # number of classes nc: 80 # number of classes
depth_multiple: 0.33 # model depth multiple depth_multiple: 0.33 # scales module repeats
width_multiple: 0.25 # layer channel multiple width_multiple: 0.25 # scales convolution channels
# YOLOv8.0n backbone # YOLOv8.0n backbone
backbone: backbone:
# [from, number, module, args] # [from, repeats, module, args]
[[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
[-1, 3, C2f, [128, True]], - [-1, 3, C2f, [128, True]]
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
[-1, 6, C2f, [256, True]], - [-1, 6, C2f, [256, True]]
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
[-1, 6, C2f, [512, True]], - [-1, 6, C2f, [512, True]]
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32
[-1, 3, C2f, [1024, True]], - [-1, 3, C2f, [1024, True]]
[-1, 1, SPPF, [1024, 5]], # 9 - [-1, 1, SPPF, [1024, 5]] # 9
]
# YOLOv8.0n head # YOLOv8.0n head
head: head:
[[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 6], 1, Concat, [1]], # cat backbone P4 - [[-1, 6], 1, Concat, [1]] # cat backbone P4
[-1, 3, C2f, [512]], # 13 - [-1, 3, C2f, [512]] # 13
[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 4], 1, Concat, [1]], # cat backbone P3 - [[-1, 4], 1, Concat, [1]] # cat backbone P3
[-1, 3, C2f, [256]], # 17 (P3/8-small) - [-1, 3, C2f, [256]] # 17 (P3/8-small)
[-1, 1, Conv, [256, 3, 2]], - [-1, 1, Conv, [256, 3, 2]]
[[-1, 12], 1, Concat, [1]], # cat head P4 - [[-1, 12], 1, Concat, [1]] # cat head P4
[-1, 3, C2f, [512]], # 20 (P4/16-medium) - [-1, 3, C2f, [512]] # 20 (P4/16-medium)
[-1, 1, Conv, [512, 3, 2]], - [-1, 1, Conv, [512, 3, 2]]
[[-1, 9], 1, Concat, [1]], # cat head P5 - [[-1, 9], 1, Concat, [1]] # cat head P5
[-1, 3, C2f, [1024]], # 23 (P5/32-large) - [-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)
]

@ -2,41 +2,39 @@
# Parameters # Parameters
nc: 80 # number of classes nc: 80 # number of classes
depth_multiple: 0.33 # model depth multiple depth_multiple: 0.33 # scales module repeats
width_multiple: 0.50 # layer channel multiple width_multiple: 0.50 # scales convolution channels
# YOLOv8.0s backbone # YOLOv8.0s backbone
backbone: backbone:
# [from, number, module, args] # [from, repeats, module, args]
[[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
[-1, 3, C2f, [128, True]], - [-1, 3, C2f, [128, True]]
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
[-1, 6, C2f, [256, True]], - [-1, 6, C2f, [256, True]]
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
[-1, 6, C2f, [512, True]], - [-1, 6, C2f, [512, True]]
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32 - [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32
[-1, 3, C2f, [1024, True]], - [-1, 3, C2f, [1024, True]]
[-1, 1, SPPF, [1024, 5]], # 9 - [-1, 1, SPPF, [1024, 5]] # 9
]
# YOLOv8.0s head # YOLOv8.0s head
head: head:
[[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 6], 1, Concat, [1]], # cat backbone P4 - [[-1, 6], 1, Concat, [1]] # cat backbone P4
[-1, 3, C2f, [512]], # 13 - [-1, 3, C2f, [512]] # 13
[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 4], 1, Concat, [1]], # cat backbone P3 - [[-1, 4], 1, Concat, [1]] # cat backbone P3
[-1, 3, C2f, [256]], # 17 (P3/8-small) - [-1, 3, C2f, [256]] # 17 (P3/8-small)
[-1, 1, Conv, [256, 3, 2]], - [-1, 1, Conv, [256, 3, 2]]
[[-1, 12], 1, Concat, [1]], # cat head P4 - [[-1, 12], 1, Concat, [1]] # cat head P4
[-1, 3, C2f, [512]], # 20 (P4/16-medium) - [-1, 3, C2f, [512]] # 20 (P4/16-medium)
[-1, 1, Conv, [512, 3, 2]], - [-1, 1, Conv, [512, 3, 2]]
[[-1, 9], 1, Concat, [1]], # cat head P5 - [[-1, 9], 1, Concat, [1]] # cat head P5
[-1, 3, C2f, [1024]], # 23 (P5/32-large) - [-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)
]

@ -2,41 +2,39 @@
# Parameters # Parameters
nc: 80 # number of classes nc: 80 # number of classes
depth_multiple: 1.00 # model depth multiple depth_multiple: 1.00 # scales module repeats
width_multiple: 1.25 # layer channel multiple width_multiple: 1.25 # scales convolution channels
# YOLOv8.0x backbone # YOLOv8.0x backbone
backbone: backbone:
# [from, number, module, args] # [from, repeats, module, args]
[[-1, 1, Conv, [64, 3, 2]], # 0-P1/2 - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4 - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
[-1, 3, C2f, [128, True]], - [-1, 3, C2f, [128, True]]
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8 - [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
[-1, 6, C2f, [256, True]], - [-1, 6, C2f, [256, True]]
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16 - [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
[-1, 6, C2f, [512, True]], - [-1, 6, C2f, [512, True]]
[-1, 1, Conv, [512, 3, 2]], # 7-P5/32 - [-1, 1, Conv, [512, 3, 2]] # 7-P5/32
[-1, 3, C2f, [512, True]], - [-1, 3, C2f, [512, True]]
[-1, 1, SPPF, [512, 5]], # 9 - [-1, 1, SPPF, [512, 5]] # 9
]
# YOLOv8.0x head # YOLOv8.0x head
head: head:
[[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 6], 1, Concat, [1]], # cat backbone P4 - [[-1, 6], 1, Concat, [1]] # cat backbone P4
[-1, 3, C2f, [512]], # 13 - [-1, 3, C2f, [512]] # 13
[-1, 1, nn.Upsample, [None, 2, 'nearest']], - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
[[-1, 4], 1, Concat, [1]], # cat backbone P3 - [[-1, 4], 1, Concat, [1]] # cat backbone P3
[-1, 3, C2f, [256]], # 17 (P3/8-small) - [-1, 3, C2f, [256]] # 17 (P3/8-small)
[-1, 1, Conv, [256, 3, 2]], - [-1, 1, Conv, [256, 3, 2]]
[[-1, 12], 1, Concat, [1]], # cat head P4 - [[-1, 12], 1, Concat, [1]] # cat head P4
[-1, 3, C2f, [512]], # 20 (P4/16-medium) - [-1, 3, C2f, [512]] # 20 (P4/16-medium)
[-1, 1, Conv, [512, 3, 2]], - [-1, 1, Conv, [512, 3, 2]]
[[-1, 9], 1, Concat, [1]], # cat head P5 - [[-1, 9], 1, Concat, [1]] # cat head P5
[-1, 3, C2f, [512]], # 23 (P5/32-large) - [-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)
]

@ -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)
Loading…
Cancel
Save