mirror of
https://github.com/THU-MIG/yolov10.git
synced 2025-05-23 21:44:22 +08:00
ultralytics 8.0.55
unified YOLOv8 model YAMLs (#1475)
This commit is contained in:
parent
701fba4770
commit
25cc07401f
2
.github/workflows/greetings.yml
vendored
2
.github/workflows/greetings.yml
vendored
@ -52,4 +52,4 @@ jobs:
|
|||||||
|
|
||||||
<a href="https://github.com/ultralytics/ultralytics/actions/workflows/ci.yaml?query=event%3Aschedule"><img src="https://github.com/ultralytics/ultralytics/actions/workflows/ci.yaml/badge.svg" alt="Ultralytics CI"></a>
|
<a href="https://github.com/ultralytics/ultralytics/actions/workflows/ci.yaml?query=event%3Aschedule"><img src="https://github.com/ultralytics/ultralytics/actions/workflows/ci.yaml/badge.svg" alt="Ultralytics CI"></a>
|
||||||
|
|
||||||
If this badge is green, all [Ultralytics CI](https://github.com/ultralytics/ultralytics/actions/workflows/ci.yaml?query=event%3Aschedule) tests are currently passing. CI tests verify correct operation of all YOLOv8 modes and tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.
|
If this badge is green, all [Ultralytics CI](https://github.com/ultralytics/ultralytics/actions/workflows/ci.yaml?query=event%3Aschedule) tests are currently passing. CI tests verify correct operation of all YOLOv8 [Modes](https://docs.ultralytics.com/modes/) and [Tasks](https://docs.ultralytics.com/tasks/) on macOS, Windows, and Ubuntu every 24 hours and on every commit.
|
||||||
|
@ -26,16 +26,25 @@ see the [Configuration](../usage/cfg.md) page.
|
|||||||
from ultralytics import YOLO
|
from ultralytics import YOLO
|
||||||
|
|
||||||
# Load a model
|
# Load a model
|
||||||
model = YOLO('yolov8n-cls.yaml') # build a new model from scratch
|
model = YOLO('yolov8n-cls.yaml') # build a new model from YAML
|
||||||
model = YOLO('yolov8n-cls.pt') # load a pretrained model (recommended for training)
|
model = YOLO('yolov8n-cls.pt') # load a pretrained model (recommended for training)
|
||||||
|
model = YOLO('yolov8n-cls.yaml').load('yolov8n-cls.pt') # build from YAML and transfer weights
|
||||||
|
|
||||||
# Train the model
|
# Train the model
|
||||||
model.train(data='mnist160', epochs=100, imgsz=64)
|
model.train(data='mnist160', epochs=100, imgsz=64)
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "CLI"
|
=== "CLI"
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Build a new model from YAML and start training from scratch
|
||||||
|
yolo classify train data=mnist160 model=yolov8n-cls.yaml epochs=100 imgsz=64
|
||||||
|
|
||||||
|
# Start training from a pretrained *.pt model
|
||||||
yolo classify train data=mnist160 model=yolov8n-cls.pt epochs=100 imgsz=64
|
yolo classify train data=mnist160 model=yolov8n-cls.pt epochs=100 imgsz=64
|
||||||
|
|
||||||
|
# Build a new model from YAML, transfer pretrained weights to it and start training
|
||||||
|
yolo classify train data=mnist160 model=yolov8n-cls.yaml pretrained=yolov8n-cls.pt epochs=100 imgsz=64
|
||||||
```
|
```
|
||||||
|
|
||||||
## Val
|
## Val
|
||||||
|
@ -26,8 +26,9 @@ the [Configuration](../usage/cfg.md) page.
|
|||||||
from ultralytics import YOLO
|
from ultralytics import YOLO
|
||||||
|
|
||||||
# Load a model
|
# Load a model
|
||||||
model = YOLO('yolov8n.yaml') # build a new model from scratch
|
model = YOLO('yolov8n.yaml') # build a new model from YAML
|
||||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||||
|
model = YOLO('yolov8n.yaml').load('yolov8n.pt') # build from YAML and transfer weights
|
||||||
|
|
||||||
# Train the model
|
# Train the model
|
||||||
model.train(data='coco128.yaml', epochs=100, imgsz=640)
|
model.train(data='coco128.yaml', epochs=100, imgsz=640)
|
||||||
@ -35,7 +36,14 @@ the [Configuration](../usage/cfg.md) page.
|
|||||||
=== "CLI"
|
=== "CLI"
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Build a new model from YAML and start training from scratch
|
||||||
|
yolo detect train data=coco128.yaml model=yolov8n.yaml epochs=100 imgsz=640
|
||||||
|
|
||||||
|
# Start training from a pretrained *.pt model
|
||||||
yolo detect train data=coco128.yaml model=yolov8n.pt epochs=100 imgsz=640
|
yolo detect train data=coco128.yaml model=yolov8n.pt epochs=100 imgsz=640
|
||||||
|
|
||||||
|
# Build a new model from YAML, transfer pretrained weights to it and start training
|
||||||
|
yolo detect train data=coco128.yaml model=yolov8n.yaml pretrained=yolov8n.pt epochs=100 imgsz=640
|
||||||
```
|
```
|
||||||
|
|
||||||
## Val
|
## Val
|
||||||
|
@ -28,8 +28,9 @@ train an OpenPose model on a custom dataset, see the OpenPose Training page.
|
|||||||
from ultralytics import YOLO
|
from ultralytics import YOLO
|
||||||
|
|
||||||
# Load a model
|
# Load a model
|
||||||
model = YOLO('yolov8n.yaml') # build a new model from scratch
|
model = YOLO('yolov8n.yaml') # build a new model from YAML
|
||||||
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
model = YOLO('yolov8n.pt') # load a pretrained model (recommended for training)
|
||||||
|
model = YOLO('yolov8n.yaml').load('yolov8n.pt') # build from YAML and transfer weights
|
||||||
|
|
||||||
# Train the model
|
# Train the model
|
||||||
model.train(data='coco128.yaml', epochs=100, imgsz=640)
|
model.train(data='coco128.yaml', epochs=100, imgsz=640)
|
||||||
@ -37,7 +38,14 @@ train an OpenPose model on a custom dataset, see the OpenPose Training page.
|
|||||||
=== "CLI"
|
=== "CLI"
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Build a new model from YAML and start training from scratch
|
||||||
|
yolo detect train data=coco128.yaml model=yolov8n.yaml epochs=100 imgsz=640
|
||||||
|
|
||||||
|
# Start training from a pretrained *.pt model
|
||||||
yolo detect train data=coco128.yaml model=yolov8n.pt epochs=100 imgsz=640
|
yolo detect train data=coco128.yaml model=yolov8n.pt epochs=100 imgsz=640
|
||||||
|
|
||||||
|
# Build a new model from YAML, transfer pretrained weights to it and start training
|
||||||
|
yolo detect train data=coco128.yaml model=yolov8n.yaml pretrained=yolov8n.pt epochs=100 imgsz=640
|
||||||
```
|
```
|
||||||
|
|
||||||
## Val TODO
|
## Val TODO
|
||||||
|
@ -26,8 +26,9 @@ arguments see the [Configuration](../usage/cfg.md) page.
|
|||||||
from ultralytics import YOLO
|
from ultralytics import YOLO
|
||||||
|
|
||||||
# Load a model
|
# Load a model
|
||||||
model = YOLO('yolov8n-seg.yaml') # build a new model from scratch
|
model = YOLO('yolov8n-seg.yaml') # build a new model from YAML
|
||||||
model = YOLO('yolov8n-seg.pt') # load a pretrained model (recommended for training)
|
model = YOLO('yolov8n-seg.pt') # load a pretrained model (recommended for training)
|
||||||
|
model = YOLO('yolov8n-seg.yaml').load('yolov8n.pt') # build from YAML and transfer weights
|
||||||
|
|
||||||
# Train the model
|
# Train the model
|
||||||
model.train(data='coco128-seg.yaml', epochs=100, imgsz=640)
|
model.train(data='coco128-seg.yaml', epochs=100, imgsz=640)
|
||||||
@ -35,7 +36,14 @@ arguments see the [Configuration](../usage/cfg.md) page.
|
|||||||
=== "CLI"
|
=== "CLI"
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Build a new model from YAML and start training from scratch
|
||||||
|
yolo segment train data=coco128-seg.yaml model=yolov8n-seg.yaml epochs=100 imgsz=640
|
||||||
|
|
||||||
|
# Start training from a pretrained *.pt model
|
||||||
yolo segment train data=coco128-seg.yaml model=yolov8n-seg.pt epochs=100 imgsz=640
|
yolo segment train data=coco128-seg.yaml model=yolov8n-seg.pt epochs=100 imgsz=640
|
||||||
|
|
||||||
|
# Build a new model from YAML, transfer pretrained weights to it and start training
|
||||||
|
yolo segment train data=coco128-seg.yaml model=yolov8n-seg.yaml pretrained=yolov8n-seg.pt epochs=100 imgsz=640
|
||||||
```
|
```
|
||||||
|
|
||||||
## Val
|
## Val
|
||||||
|
@ -143,7 +143,7 @@ given task.
|
|||||||
| `agnostic_nms` | `False` | class-agnostic NMS |
|
| `agnostic_nms` | `False` | class-agnostic NMS |
|
||||||
| `retina_masks` | `False` | use high-resolution segmentation masks |
|
| `retina_masks` | `False` | use high-resolution segmentation masks |
|
||||||
| `classes` | `None` | filter results by class, i.e. class=0, or class=[0,2,3] |
|
| `classes` | `None` | filter results by class, i.e. class=0, or class=[0,2,3] |
|
||||||
| `box` | `True` | Show boxes in segmentation predictions |
|
| `boxes` | `True` | Show boxes in segmentation predictions |
|
||||||
|
|
||||||
### Validation
|
### Validation
|
||||||
|
|
||||||
|
@ -74,16 +74,9 @@ def test_segment():
|
|||||||
|
|
||||||
|
|
||||||
def test_classify():
|
def test_classify():
|
||||||
overrides = {
|
overrides = {'data': 'imagenet10', 'model': 'yolov8n-cls.yaml', 'imgsz': 32, 'epochs': 1, 'save': False}
|
||||||
'data': 'imagenet10',
|
|
||||||
'model': 'yolov8n-cls.yaml',
|
|
||||||
'imgsz': 32,
|
|
||||||
'epochs': 1,
|
|
||||||
'batch': 64,
|
|
||||||
'save': False}
|
|
||||||
CFG.data = 'imagenet10'
|
CFG.data = 'imagenet10'
|
||||||
CFG.imgsz = 32
|
CFG.imgsz = 32
|
||||||
CFG.batch = 64
|
|
||||||
# YOLO(CFG_SEG).train(**overrides) # works
|
# YOLO(CFG_SEG).train(**overrides) # works
|
||||||
|
|
||||||
# Trainer
|
# Trainer
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
# Ultralytics YOLO 🚀, GPL-3.0 license
|
||||||
|
|
||||||
__version__ = '8.0.54'
|
__version__ = '8.0.55'
|
||||||
|
|
||||||
from ultralytics.yolo.engine.model import YOLO
|
from ultralytics.yolo.engine.model import YOLO
|
||||||
from ultralytics.yolo.utils.checks import check_yolo as checks
|
from ultralytics.yolo.utils.checks import check_yolo as checks
|
||||||
|
@ -2,8 +2,13 @@
|
|||||||
|
|
||||||
# Parameters
|
# Parameters
|
||||||
nc: 80 # number of classes
|
nc: 80 # number of classes
|
||||||
depth_multiple: 1.0 # model depth multiple
|
scales: # model compound scaling constants, i.e. 'model=yolov5n-p6.yaml' will call yolov5-p6.yaml with scale 'n'
|
||||||
width_multiple: 1.0 # layer channel multiple
|
# [depth, width, max_channels]
|
||||||
|
n: [0.33, 0.25, 1024]
|
||||||
|
s: [0.33, 0.50, 1024]
|
||||||
|
m: [0.67, 0.75, 1024]
|
||||||
|
l: [1.00, 1.00, 1024]
|
||||||
|
x: [1.33, 1.25, 1024]
|
||||||
|
|
||||||
# YOLOv5 v6.0 backbone
|
# YOLOv5 v6.0 backbone
|
||||||
backbone:
|
backbone:
|
@ -2,8 +2,13 @@
|
|||||||
|
|
||||||
# Parameters
|
# Parameters
|
||||||
nc: 80 # number of classes
|
nc: 80 # number of classes
|
||||||
depth_multiple: 0.33 # model depth multiple
|
scales: # model compound scaling constants, i.e. 'model=yolov5n.yaml' will call yolov5.yaml with scale 'n'
|
||||||
width_multiple: 0.50 # layer channel multiple
|
# [depth, width, max_channels]
|
||||||
|
n: [0.33, 0.25, 1024]
|
||||||
|
s: [0.33, 0.50, 1024]
|
||||||
|
m: [0.67, 0.75, 1024]
|
||||||
|
l: [1.00, 1.00, 1024]
|
||||||
|
x: [1.33, 1.25, 1024]
|
||||||
|
|
||||||
# YOLOv5 v6.0 backbone
|
# YOLOv5 v6.0 backbone
|
||||||
backbone:
|
backbone:
|
@ -1,44 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 80 # number of classes
|
|
||||||
depth_multiple: 1.0 # model depth multiple
|
|
||||||
width_multiple: 1.0 # layer channel multiple
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 backbone
|
|
||||||
backbone:
|
|
||||||
# [from, number, module, args]
|
|
||||||
[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
|
|
||||||
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
|
|
||||||
[-1, 3, C3, [128]],
|
|
||||||
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
|
|
||||||
[-1, 6, C3, [256]],
|
|
||||||
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
|
|
||||||
[-1, 9, C3, [512]],
|
|
||||||
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
|
|
||||||
[-1, 3, C3, [1024]],
|
|
||||||
[-1, 1, SPPF, [1024, 5]], # 9
|
|
||||||
]
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 head
|
|
||||||
head:
|
|
||||||
[[-1, 1, Conv, [512, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 6], 1, Concat, [1]], # cat backbone P4
|
|
||||||
[-1, 3, C3, [512, False]], # 13
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 4], 1, Concat, [1]], # cat backbone P3
|
|
||||||
[-1, 3, C3, [256, False]], # 17 (P3/8-small)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 3, 2]],
|
|
||||||
[[-1, 14], 1, Concat, [1]], # cat head P4
|
|
||||||
[-1, 3, C3, [512, False]], # 20 (P4/16-medium)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [512, 3, 2]],
|
|
||||||
[[-1, 10], 1, Concat, [1]], # cat head P5
|
|
||||||
[-1, 3, C3, [1024, False]], # 23 (P5/32-large)
|
|
||||||
|
|
||||||
[[17, 20, 23], 1, Detect, [nc]], # Detect(P3, P4, P5)
|
|
||||||
]
|
|
@ -1,55 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 80 # number of classes
|
|
||||||
depth_multiple: 0.67 # model depth multiple
|
|
||||||
width_multiple: 0.75 # layer channel multiple
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 backbone
|
|
||||||
backbone:
|
|
||||||
# [from, number, module, args]
|
|
||||||
[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
|
|
||||||
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
|
|
||||||
[-1, 3, C3, [128]],
|
|
||||||
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
|
|
||||||
[-1, 6, C3, [256]],
|
|
||||||
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
|
|
||||||
[-1, 9, C3, [512]],
|
|
||||||
[-1, 1, Conv, [768, 3, 2]], # 7-P5/32
|
|
||||||
[-1, 3, C3, [768]],
|
|
||||||
[-1, 1, Conv, [1024, 3, 2]], # 9-P6/64
|
|
||||||
[-1, 3, C3, [1024]],
|
|
||||||
[-1, 1, SPPF, [1024, 5]], # 11
|
|
||||||
]
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 head
|
|
||||||
head:
|
|
||||||
[[-1, 1, Conv, [768, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 8], 1, Concat, [1]], # cat backbone P5
|
|
||||||
[-1, 3, C3, [768, False]], # 15
|
|
||||||
|
|
||||||
[-1, 1, Conv, [512, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 6], 1, Concat, [1]], # cat backbone P4
|
|
||||||
[-1, 3, C3, [512, False]], # 19
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 4], 1, Concat, [1]], # cat backbone P3
|
|
||||||
[-1, 3, C3, [256, False]], # 23 (P3/8-small)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 3, 2]],
|
|
||||||
[[-1, 20], 1, Concat, [1]], # cat head P4
|
|
||||||
[-1, 3, C3, [512, False]], # 26 (P4/16-medium)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [512, 3, 2]],
|
|
||||||
[[-1, 16], 1, Concat, [1]], # cat head P5
|
|
||||||
[-1, 3, C3, [768, False]], # 29 (P5/32-large)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [768, 3, 2]],
|
|
||||||
[[-1, 12], 1, Concat, [1]], # cat head P6
|
|
||||||
[-1, 3, C3, [1024, False]], # 32 (P6/64-xlarge)
|
|
||||||
|
|
||||||
[[23, 26, 29, 32], 1, Detect, [nc]], # Detect(P3, P4, P5, P6)
|
|
||||||
]
|
|
@ -1,44 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 80 # number of classes
|
|
||||||
depth_multiple: 0.67 # model depth multiple
|
|
||||||
width_multiple: 0.75 # layer channel multiple
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 backbone
|
|
||||||
backbone:
|
|
||||||
# [from, number, module, args]
|
|
||||||
[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
|
|
||||||
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
|
|
||||||
[-1, 3, C3, [128]],
|
|
||||||
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
|
|
||||||
[-1, 6, C3, [256]],
|
|
||||||
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
|
|
||||||
[-1, 9, C3, [512]],
|
|
||||||
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
|
|
||||||
[-1, 3, C3, [1024]],
|
|
||||||
[-1, 1, SPPF, [1024, 5]], # 9
|
|
||||||
]
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 head
|
|
||||||
head:
|
|
||||||
[[-1, 1, Conv, [512, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 6], 1, Concat, [1]], # cat backbone P4
|
|
||||||
[-1, 3, C3, [512, False]], # 13
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 4], 1, Concat, [1]], # cat backbone P3
|
|
||||||
[-1, 3, C3, [256, False]], # 17 (P3/8-small)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 3, 2]],
|
|
||||||
[[-1, 14], 1, Concat, [1]], # cat head P4
|
|
||||||
[-1, 3, C3, [512, False]], # 20 (P4/16-medium)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [512, 3, 2]],
|
|
||||||
[[-1, 10], 1, Concat, [1]], # cat head P5
|
|
||||||
[-1, 3, C3, [1024, False]], # 23 (P5/32-large)
|
|
||||||
|
|
||||||
[[17, 20, 23], 1, Detect, [nc]], # Detect(P3, P4, P5)
|
|
||||||
]
|
|
@ -1,55 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 80 # number of classes
|
|
||||||
depth_multiple: 0.33 # model depth multiple
|
|
||||||
width_multiple: 0.25 # layer channel multiple
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 backbone
|
|
||||||
backbone:
|
|
||||||
# [from, number, module, args]
|
|
||||||
[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
|
|
||||||
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
|
|
||||||
[-1, 3, C3, [128]],
|
|
||||||
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
|
|
||||||
[-1, 6, C3, [256]],
|
|
||||||
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
|
|
||||||
[-1, 9, C3, [512]],
|
|
||||||
[-1, 1, Conv, [768, 3, 2]], # 7-P5/32
|
|
||||||
[-1, 3, C3, [768]],
|
|
||||||
[-1, 1, Conv, [1024, 3, 2]], # 9-P6/64
|
|
||||||
[-1, 3, C3, [1024]],
|
|
||||||
[-1, 1, SPPF, [1024, 5]], # 11
|
|
||||||
]
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 head
|
|
||||||
head:
|
|
||||||
[[-1, 1, Conv, [768, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 8], 1, Concat, [1]], # cat backbone P5
|
|
||||||
[-1, 3, C3, [768, False]], # 15
|
|
||||||
|
|
||||||
[-1, 1, Conv, [512, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 6], 1, Concat, [1]], # cat backbone P4
|
|
||||||
[-1, 3, C3, [512, False]], # 19
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 4], 1, Concat, [1]], # cat backbone P3
|
|
||||||
[-1, 3, C3, [256, False]], # 23 (P3/8-small)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 3, 2]],
|
|
||||||
[[-1, 20], 1, Concat, [1]], # cat head P4
|
|
||||||
[-1, 3, C3, [512, False]], # 26 (P4/16-medium)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [512, 3, 2]],
|
|
||||||
[[-1, 16], 1, Concat, [1]], # cat head P5
|
|
||||||
[-1, 3, C3, [768, False]], # 29 (P5/32-large)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [768, 3, 2]],
|
|
||||||
[[-1, 12], 1, Concat, [1]], # cat head P6
|
|
||||||
[-1, 3, C3, [1024, False]], # 32 (P6/64-xlarge)
|
|
||||||
|
|
||||||
[[23, 26, 29, 32], 1, Detect, [nc]], # Detect(P3, P4, P5, P6)
|
|
||||||
]
|
|
@ -1,44 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 80 # number of classes
|
|
||||||
depth_multiple: 0.33 # model depth multiple
|
|
||||||
width_multiple: 0.25 # layer channel multiple
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 backbone
|
|
||||||
backbone:
|
|
||||||
# [from, number, module, args]
|
|
||||||
[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
|
|
||||||
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
|
|
||||||
[-1, 3, C3, [128]],
|
|
||||||
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
|
|
||||||
[-1, 6, C3, [256]],
|
|
||||||
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
|
|
||||||
[-1, 9, C3, [512]],
|
|
||||||
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
|
|
||||||
[-1, 3, C3, [1024]],
|
|
||||||
[-1, 1, SPPF, [1024, 5]], # 9
|
|
||||||
]
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 head
|
|
||||||
head:
|
|
||||||
[[-1, 1, Conv, [512, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 6], 1, Concat, [1]], # cat backbone P4
|
|
||||||
[-1, 3, C3, [512, False]], # 13
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 4], 1, Concat, [1]], # cat backbone P3
|
|
||||||
[-1, 3, C3, [256, False]], # 17 (P3/8-small)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 3, 2]],
|
|
||||||
[[-1, 14], 1, Concat, [1]], # cat head P4
|
|
||||||
[-1, 3, C3, [512, False]], # 20 (P4/16-medium)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [512, 3, 2]],
|
|
||||||
[[-1, 10], 1, Concat, [1]], # cat head P5
|
|
||||||
[-1, 3, C3, [1024, False]], # 23 (P5/32-large)
|
|
||||||
|
|
||||||
[[17, 20, 23], 1, Detect, [nc]], # Detect(P3, P4, P5)
|
|
||||||
]
|
|
@ -1,55 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 80 # number of classes
|
|
||||||
depth_multiple: 0.33 # model depth multiple
|
|
||||||
width_multiple: 0.50 # layer channel multiple
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 backbone
|
|
||||||
backbone:
|
|
||||||
# [from, number, module, args]
|
|
||||||
[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
|
|
||||||
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
|
|
||||||
[-1, 3, C3, [128]],
|
|
||||||
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
|
|
||||||
[-1, 6, C3, [256]],
|
|
||||||
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
|
|
||||||
[-1, 9, C3, [512]],
|
|
||||||
[-1, 1, Conv, [768, 3, 2]], # 7-P5/32
|
|
||||||
[-1, 3, C3, [768]],
|
|
||||||
[-1, 1, Conv, [1024, 3, 2]], # 9-P6/64
|
|
||||||
[-1, 3, C3, [1024]],
|
|
||||||
[-1, 1, SPPF, [1024, 5]], # 11
|
|
||||||
]
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 head
|
|
||||||
head:
|
|
||||||
[[-1, 1, Conv, [768, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 8], 1, Concat, [1]], # cat backbone P5
|
|
||||||
[-1, 3, C3, [768, False]], # 15
|
|
||||||
|
|
||||||
[-1, 1, Conv, [512, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 6], 1, Concat, [1]], # cat backbone P4
|
|
||||||
[-1, 3, C3, [512, False]], # 19
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 4], 1, Concat, [1]], # cat backbone P3
|
|
||||||
[-1, 3, C3, [256, False]], # 23 (P3/8-small)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 3, 2]],
|
|
||||||
[[-1, 20], 1, Concat, [1]], # cat head P4
|
|
||||||
[-1, 3, C3, [512, False]], # 26 (P4/16-medium)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [512, 3, 2]],
|
|
||||||
[[-1, 16], 1, Concat, [1]], # cat head P5
|
|
||||||
[-1, 3, C3, [768, False]], # 29 (P5/32-large)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [768, 3, 2]],
|
|
||||||
[[-1, 12], 1, Concat, [1]], # cat head P6
|
|
||||||
[-1, 3, C3, [1024, False]], # 32 (P6/64-xlarge)
|
|
||||||
|
|
||||||
[[23, 26, 29, 32], 1, Detect, [nc]], # Detect(P3, P4, P5, P6)
|
|
||||||
]
|
|
@ -1,55 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 80 # number of classes
|
|
||||||
depth_multiple: 1.33 # model depth multiple
|
|
||||||
width_multiple: 1.25 # layer channel multiple
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 backbone
|
|
||||||
backbone:
|
|
||||||
# [from, number, module, args]
|
|
||||||
[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
|
|
||||||
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
|
|
||||||
[-1, 3, C3, [128]],
|
|
||||||
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
|
|
||||||
[-1, 6, C3, [256]],
|
|
||||||
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
|
|
||||||
[-1, 9, C3, [512]],
|
|
||||||
[-1, 1, Conv, [768, 3, 2]], # 7-P5/32
|
|
||||||
[-1, 3, C3, [768]],
|
|
||||||
[-1, 1, Conv, [1024, 3, 2]], # 9-P6/64
|
|
||||||
[-1, 3, C3, [1024]],
|
|
||||||
[-1, 1, SPPF, [1024, 5]], # 11
|
|
||||||
]
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 head
|
|
||||||
head:
|
|
||||||
[[-1, 1, Conv, [768, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 8], 1, Concat, [1]], # cat backbone P5
|
|
||||||
[-1, 3, C3, [768, False]], # 15
|
|
||||||
|
|
||||||
[-1, 1, Conv, [512, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 6], 1, Concat, [1]], # cat backbone P4
|
|
||||||
[-1, 3, C3, [512, False]], # 19
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 4], 1, Concat, [1]], # cat backbone P3
|
|
||||||
[-1, 3, C3, [256, False]], # 23 (P3/8-small)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 3, 2]],
|
|
||||||
[[-1, 20], 1, Concat, [1]], # cat head P4
|
|
||||||
[-1, 3, C3, [512, False]], # 26 (P4/16-medium)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [512, 3, 2]],
|
|
||||||
[[-1, 16], 1, Concat, [1]], # cat head P5
|
|
||||||
[-1, 3, C3, [768, False]], # 29 (P5/32-large)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [768, 3, 2]],
|
|
||||||
[[-1, 12], 1, Concat, [1]], # cat head P6
|
|
||||||
[-1, 3, C3, [1024, False]], # 32 (P6/64-xlarge)
|
|
||||||
|
|
||||||
[[23, 26, 29, 32], 1, Detect, [nc]], # Detect(P3, P4, P5, P6)
|
|
||||||
]
|
|
@ -1,44 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 80 # number of classes
|
|
||||||
depth_multiple: 1.33 # model depth multiple
|
|
||||||
width_multiple: 1.25 # layer channel multiple
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 backbone
|
|
||||||
backbone:
|
|
||||||
# [from, number, module, args]
|
|
||||||
[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
|
|
||||||
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
|
|
||||||
[-1, 3, C3, [128]],
|
|
||||||
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
|
|
||||||
[-1, 6, C3, [256]],
|
|
||||||
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
|
|
||||||
[-1, 9, C3, [512]],
|
|
||||||
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
|
|
||||||
[-1, 3, C3, [1024]],
|
|
||||||
[-1, 1, SPPF, [1024, 5]], # 9
|
|
||||||
]
|
|
||||||
|
|
||||||
# YOLOv5 v6.0 head
|
|
||||||
head:
|
|
||||||
[[-1, 1, Conv, [512, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 6], 1, Concat, [1]], # cat backbone P4
|
|
||||||
[-1, 3, C3, [512, False]], # 13
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 1, 1]],
|
|
||||||
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
||||||
[[-1, 4], 1, Concat, [1]], # cat backbone P3
|
|
||||||
[-1, 3, C3, [256, False]], # 17 (P3/8-small)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [256, 3, 2]],
|
|
||||||
[[-1, 14], 1, Concat, [1]], # cat head P4
|
|
||||||
[-1, 3, C3, [512, False]], # 20 (P4/16-medium)
|
|
||||||
|
|
||||||
[-1, 1, Conv, [512, 3, 2]],
|
|
||||||
[[-1, 10], 1, Concat, [1]], # cat head P5
|
|
||||||
[-1, 3, C3, [1024, False]], # 23 (P5/32-large)
|
|
||||||
|
|
||||||
[[17, 20, 23], 1, Detect, [nc]], # Detect(P3, P4, P5)
|
|
||||||
]
|
|
@ -1,23 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 1000 # number of classes
|
|
||||||
depth_multiple: 0.67 # scales module repeats
|
|
||||||
width_multiple: 0.75 # scales convolution channels
|
|
||||||
|
|
||||||
# YOLOv8.0n 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, [1024, 3, 2]] # 7-P5/32
|
|
||||||
- [-1, 3, C2f, [1024, True]]
|
|
||||||
|
|
||||||
# YOLOv8.0n head
|
|
||||||
head:
|
|
||||||
- [-1, 1, Classify, [nc]]
|
|
@ -1,23 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 1000 # number of classes
|
|
||||||
depth_multiple: 0.33 # scales module repeats
|
|
||||||
width_multiple: 0.25 # scales convolution channels
|
|
||||||
|
|
||||||
# YOLOv8.0n 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, [1024, 3, 2]] # 7-P5/32
|
|
||||||
- [-1, 3, C2f, [1024, True]]
|
|
||||||
|
|
||||||
# YOLOv8.0n head
|
|
||||||
head:
|
|
||||||
- [-1, 1, Classify, [nc]]
|
|
@ -1,23 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 1000 # number of classes
|
|
||||||
depth_multiple: 0.33 # scales module repeats
|
|
||||||
width_multiple: 0.50 # scales convolution channels
|
|
||||||
|
|
||||||
# YOLOv8.0n 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, [1024, 3, 2]] # 7-P5/32
|
|
||||||
- [-1, 3, C2f, [1024, True]]
|
|
||||||
|
|
||||||
# YOLOv8.0n head
|
|
||||||
head:
|
|
||||||
- [-1, 1, Classify, [nc]]
|
|
@ -1,23 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 1000 # number of classes
|
|
||||||
depth_multiple: 1.00 # scales module repeats
|
|
||||||
width_multiple: 1.25 # scales convolution channels
|
|
||||||
|
|
||||||
# YOLOv8.0n 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, [1024, 3, 2]] # 7-P5/32
|
|
||||||
- [-1, 3, C2f, [1024, True]]
|
|
||||||
|
|
||||||
# YOLOv8.0n head
|
|
||||||
head:
|
|
||||||
- [-1, 1, Classify, [nc]]
|
|
@ -1,40 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 80 # number of classes
|
|
||||||
depth_multiple: 1.00 # scales module repeats
|
|
||||||
width_multiple: 1.00 # scales convolution channels
|
|
||||||
|
|
||||||
# YOLOv8.0l 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, 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]] # 12
|
|
||||||
|
|
||||||
- [-1, 1, nn.Upsample, [None, 2, 'nearest']]
|
|
||||||
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
|
|
||||||
- [-1, 3, C2f, [256]] # 15 (P3/8-small)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [256, 3, 2]]
|
|
||||||
- [[-1, 12], 1, Concat, [1]] # cat head P4
|
|
||||||
- [-1, 3, C2f, [512]] # 18 (P4/16-medium)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [512, 3, 2]]
|
|
||||||
- [[-1, 9], 1, Concat, [1]] # cat head P5
|
|
||||||
- [-1, 3, C2f, [512]] # 21 (P5/32-large)
|
|
||||||
|
|
||||||
- [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Detect(P3, P4, P5)
|
|
@ -1,40 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 80 # number of classes
|
|
||||||
depth_multiple: 0.67 # scales module repeats
|
|
||||||
width_multiple: 0.75 # scales convolution channels
|
|
||||||
|
|
||||||
# YOLOv8.0m 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, [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]] # 12
|
|
||||||
|
|
||||||
- [-1, 1, nn.Upsample, [None, 2, 'nearest']]
|
|
||||||
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
|
|
||||||
- [-1, 3, C2f, [256]] # 15 (P3/8-small)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [256, 3, 2]]
|
|
||||||
- [[-1, 12], 1, Concat, [1]] # cat head P4
|
|
||||||
- [-1, 3, C2f, [512]] # 18 (P4/16-medium)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [512, 3, 2]]
|
|
||||||
- [[-1, 9], 1, Concat, [1]] # cat head P5
|
|
||||||
- [-1, 3, C2f, [768]] # 21 (P5/32-large)
|
|
||||||
|
|
||||||
- [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Detect(P3, P4, P5)
|
|
@ -1,40 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 80 # number of classes
|
|
||||||
depth_multiple: 0.33 # scales module repeats
|
|
||||||
width_multiple: 0.25 # scales convolution channels
|
|
||||||
|
|
||||||
# YOLOv8.0n 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, [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]] # 12
|
|
||||||
|
|
||||||
- [-1, 1, nn.Upsample, [None, 2, 'nearest']]
|
|
||||||
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
|
|
||||||
- [-1, 3, C2f, [256]] # 15 (P3/8-small)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [256, 3, 2]]
|
|
||||||
- [[-1, 12], 1, Concat, [1]] # cat head P4
|
|
||||||
- [-1, 3, C2f, [512]] # 18 (P4/16-medium)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [512, 3, 2]]
|
|
||||||
- [[-1, 9], 1, Concat, [1]] # cat head P5
|
|
||||||
- [-1, 3, C2f, [1024]] # 21 (P5/32-large)
|
|
||||||
|
|
||||||
- [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Detect(P3, P4, P5)
|
|
@ -1,40 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 80 # number of classes
|
|
||||||
depth_multiple: 0.33 # scales module repeats
|
|
||||||
width_multiple: 0.50 # scales convolution channels
|
|
||||||
|
|
||||||
# YOLOv8.0s 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, [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]] # 12
|
|
||||||
|
|
||||||
- [-1, 1, nn.Upsample, [None, 2, 'nearest']]
|
|
||||||
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
|
|
||||||
- [-1, 3, C2f, [256]] # 15 (P3/8-small)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [256, 3, 2]]
|
|
||||||
- [[-1, 12], 1, Concat, [1]] # cat head P4
|
|
||||||
- [-1, 3, C2f, [512]] # 18 (P4/16-medium)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [512, 3, 2]]
|
|
||||||
- [[-1, 9], 1, Concat, [1]] # cat head P5
|
|
||||||
- [-1, 3, C2f, [1024]] # 21 (P5/32-large)
|
|
||||||
|
|
||||||
- [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Detect(P3, P4, P5)
|
|
@ -1,40 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, 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.0x 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, 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]] # 12
|
|
||||||
|
|
||||||
- [-1, 1, nn.Upsample, [None, 2, 'nearest']]
|
|
||||||
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
|
|
||||||
- [-1, 3, C2f, [256]] # 15 (P3/8-small)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [256, 3, 2]]
|
|
||||||
- [[-1, 12], 1, Concat, [1]] # cat head P4
|
|
||||||
- [-1, 3, C2f, [512]] # 18 (P4/16-medium)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [512, 3, 2]]
|
|
||||||
- [[-1, 9], 1, Concat, [1]] # cat head P5
|
|
||||||
- [-1, 3, C2f, [512]] # 21 (P5/32-large)
|
|
||||||
|
|
||||||
- [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Detect(P3, P4, P5)
|
|
@ -1,9 +1,15 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
# Ultralytics YOLO 🚀, GPL-3.0 license
|
||||||
|
# YOLOv8-cls image classification model. For Usage examples see https://docs.ultralytics.com/tasks/classify
|
||||||
|
|
||||||
# Parameters
|
# Parameters
|
||||||
nc: 1000 # number of classes
|
nc: 1000 # number of classes
|
||||||
depth_multiple: 1.00 # scales module repeats
|
scales: # model compound scaling constants, i.e. 'model=yolov8n-cls.yaml' will call yolov8-cls.yaml with scale 'n'
|
||||||
width_multiple: 1.00 # scales convolution channels
|
# [depth, width, max_channels]
|
||||||
|
n: [0.33, 0.25, 1024]
|
||||||
|
s: [0.33, 0.50, 1024]
|
||||||
|
m: [0.67, 0.75, 1024]
|
||||||
|
l: [1.00, 1.00, 1024]
|
||||||
|
x: [1.00, 1.25, 1024]
|
||||||
|
|
||||||
# YOLOv8.0n backbone
|
# YOLOv8.0n backbone
|
||||||
backbone:
|
backbone:
|
||||||
@ -20,4 +26,4 @@ backbone:
|
|||||||
|
|
||||||
# YOLOv8.0n head
|
# YOLOv8.0n head
|
||||||
head:
|
head:
|
||||||
- [-1, 1, Classify, [nc]]
|
- [-1, 1, Classify, [nc]] # Classify
|
@ -1,9 +1,15 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
# Ultralytics YOLO 🚀, GPL-3.0 license
|
||||||
|
# YOLOv8 object detection model with P3-P6 outputs. For Usage examples see https://docs.ultralytics.com/tasks/detect
|
||||||
|
|
||||||
# Parameters
|
# Parameters
|
||||||
nc: 80 # number of classes
|
nc: 80 # number of classes
|
||||||
depth_multiple: 1.00 # scales module repeats
|
scales: # model compound scaling constants, i.e. 'model=yolov8n-p6.yaml' will call yolov8-p6.yaml with scale 'n'
|
||||||
width_multiple: 1.25 # scales convolution channels
|
# [depth, width, max_channels]
|
||||||
|
n: [0.33, 0.25, 1024]
|
||||||
|
s: [0.33, 0.50, 1024]
|
||||||
|
m: [0.67, 0.75, 768]
|
||||||
|
l: [1.00, 1.00, 512]
|
||||||
|
x: [1.00, 1.25, 512]
|
||||||
|
|
||||||
# YOLOv8.0x6 backbone
|
# YOLOv8.0x6 backbone
|
||||||
backbone:
|
backbone:
|
||||||
@ -15,17 +21,17 @@ backbone:
|
|||||||
- [-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, [768, 3, 2]] # 7-P5/32
|
||||||
- [-1, 3, C2f, [512, True]]
|
- [-1, 3, C2f, [768, True]]
|
||||||
- [-1, 1, Conv, [512, 3, 2]] # 9-P6/64
|
- [-1, 1, Conv, [1024, 3, 2]] # 9-P6/64
|
||||||
- [-1, 3, C2f, [512, True]]
|
- [-1, 3, C2f, [1024, True]]
|
||||||
- [-1, 1, SPPF, [512, 5]] # 11
|
- [-1, 1, SPPF, [1024, 5]] # 11
|
||||||
|
|
||||||
# YOLOv8.0x6 head
|
# YOLOv8.0x6 head
|
||||||
head:
|
head:
|
||||||
- [-1, 1, nn.Upsample, [None, 2, 'nearest']]
|
- [-1, 1, nn.Upsample, [None, 2, 'nearest']]
|
||||||
- [[-1, 8], 1, Concat, [1]] # cat backbone P5
|
- [[-1, 8], 1, Concat, [1]] # cat backbone P5
|
||||||
- [-1, 3, C2, [512, False]] # 14
|
- [-1, 3, C2, [768, False]] # 14
|
||||||
|
|
||||||
- [-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
|
||||||
@ -41,10 +47,10 @@ head:
|
|||||||
|
|
||||||
- [-1, 1, Conv, [512, 3, 2]]
|
- [-1, 1, Conv, [512, 3, 2]]
|
||||||
- [[-1, 14], 1, Concat, [1]] # cat head P5
|
- [[-1, 14], 1, Concat, [1]] # cat head P5
|
||||||
- [-1, 3, C2, [512, False]] # 26 (P5/32-large)
|
- [-1, 3, C2, [768, False]] # 26 (P5/32-large)
|
||||||
|
|
||||||
- [-1, 1, Conv, [512, 3, 2]]
|
- [-1, 1, Conv, [768, 3, 2]]
|
||||||
- [[-1, 11], 1, Concat, [1]] # cat head P6
|
- [[-1, 11], 1, Concat, [1]] # cat head P6
|
||||||
- [-1, 3, C2, [512, False]] # 29 (P6/64-xlarge)
|
- [-1, 3, C2, [1024, False]] # 29 (P6/64-xlarge)
|
||||||
|
|
||||||
- [[20, 23, 26, 29], 1, Detect, [nc]] # Detect(P3, P4, P5, P6)
|
- [[20, 23, 26, 29], 1, Detect, [nc]] # Detect(P3, P4, P5, P6)
|
@ -1,9 +1,15 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
# Ultralytics YOLO 🚀, GPL-3.0 license
|
||||||
|
# YOLOv8-seg instance segmentation model. For Usage examples see https://docs.ultralytics.com/tasks/segment
|
||||||
|
|
||||||
# Parameters
|
# Parameters
|
||||||
nc: 80 # number of classes
|
nc: 80 # number of classes
|
||||||
depth_multiple: 0.33 # scales module repeats
|
scales: # model compound scaling constants, i.e. 'model=yolov8n-seg.yaml' will call yolov8-seg.yaml with scale 'n'
|
||||||
width_multiple: 0.25 # scales convolution channels
|
# [depth, width, max_channels]
|
||||||
|
n: [0.33, 0.25, 1024]
|
||||||
|
s: [0.33, 0.50, 1024]
|
||||||
|
m: [0.67, 0.75, 768]
|
||||||
|
l: [1.00, 1.00, 512]
|
||||||
|
x: [1.00, 1.25, 512]
|
||||||
|
|
||||||
# YOLOv8.0n backbone
|
# YOLOv8.0n backbone
|
||||||
backbone:
|
backbone:
|
||||||
@ -37,4 +43,4 @@ head:
|
|||||||
- [[-1, 9], 1, Concat, [1]] # cat head P5
|
- [[-1, 9], 1, Concat, [1]] # cat head P5
|
||||||
- [-1, 3, C2f, [1024]] # 21 (P5/32-large)
|
- [-1, 3, C2f, [1024]] # 21 (P5/32-large)
|
||||||
|
|
||||||
- [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4, P5)
|
- [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Segment(P3, P4, P5)
|
@ -1,11 +1,17 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
# Ultralytics YOLO 🚀, GPL-3.0 license
|
||||||
|
# YOLOv8 object detection model with P3-P5 outputs. For Usage examples see https://docs.ultralytics.com/tasks/detect
|
||||||
|
|
||||||
# Parameters
|
# Parameters
|
||||||
nc: 80 # number of classes
|
nc: 80 # number of classes
|
||||||
depth_multiple: 0.33 # scales module repeats
|
scales: # model compound scaling constants, i.e. 'model=yolov8n.yaml' will call yolov8.yaml with scale 'n'
|
||||||
width_multiple: 0.50 # scales convolution channels
|
# [depth, width, max_channels]
|
||||||
|
n: [0.33, 0.25, 1024] # YOLOv8n summary: 225 layers, 3157200 parameters, 3157184 gradients, 8.9 GFLOPs
|
||||||
|
s: [0.33, 0.50, 1024] # YOLOv8s summary: 225 layers, 11166560 parameters, 11166544 gradients, 28.8 GFLOPs
|
||||||
|
m: [0.67, 0.75, 768] # YOLOv8m summary: 295 layers, 25902640 parameters, 25902624 gradients, 79.3 GFLOPs
|
||||||
|
l: [1.00, 1.00, 512] # YOLOv8l summary: 365 layers, 43691520 parameters, 43691504 gradients, 165.7 GFLOPs
|
||||||
|
x: [1.00, 1.25, 512] # YOLOv8x summary: 365 layers, 68229648 parameters, 68229632 gradients, 258.5 GFLOPs
|
||||||
|
|
||||||
# YOLOv8.0s backbone
|
# YOLOv8.0n backbone
|
||||||
backbone:
|
backbone:
|
||||||
# [from, repeats, module, args]
|
# [from, repeats, module, args]
|
||||||
- [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
|
- [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
|
||||||
@ -19,7 +25,7 @@ backbone:
|
|||||||
- [-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.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,40 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 80 # number of classes
|
|
||||||
depth_multiple: 1.00 # scales module repeats
|
|
||||||
width_multiple: 1.00 # scales convolution channels
|
|
||||||
|
|
||||||
# YOLOv8.0l 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, 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]] # 12
|
|
||||||
|
|
||||||
- [-1, 1, nn.Upsample, [None, 2, 'nearest']]
|
|
||||||
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
|
|
||||||
- [-1, 3, C2f, [256]] # 15 (P3/8-small)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [256, 3, 2]]
|
|
||||||
- [[-1, 12], 1, Concat, [1]] # cat head P4
|
|
||||||
- [-1, 3, C2f, [512]] # 18 (P4/16-medium)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [512, 3, 2]]
|
|
||||||
- [[-1, 9], 1, Concat, [1]] # cat head P5
|
|
||||||
- [-1, 3, C2f, [512]] # 21 (P5/32-large)
|
|
||||||
|
|
||||||
- [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4, P5)
|
|
@ -1,40 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
|
||||||
|
|
||||||
# Parameters
|
|
||||||
nc: 80 # number of classes
|
|
||||||
depth_multiple: 0.67 # scales module repeats
|
|
||||||
width_multiple: 0.75 # scales convolution channels
|
|
||||||
|
|
||||||
# YOLOv8.0m 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, [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]] # 12
|
|
||||||
|
|
||||||
- [-1, 1, nn.Upsample, [None, 2, 'nearest']]
|
|
||||||
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
|
|
||||||
- [-1, 3, C2f, [256]] # 15 (P3/8-small)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [256, 3, 2]]
|
|
||||||
- [[-1, 12], 1, Concat, [1]] # cat head P4
|
|
||||||
- [-1, 3, C2f, [512]] # 18 (P4/16-medium)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [512, 3, 2]]
|
|
||||||
- [[-1, 9], 1, Concat, [1]] # cat head P5
|
|
||||||
- [-1, 3, C2f, [768]] # 21 (P5/32-large)
|
|
||||||
|
|
||||||
- [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4, P5)
|
|
@ -1,40 +0,0 @@
|
|||||||
# Ultralytics YOLO 🚀, 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.0x 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, 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]] # 12
|
|
||||||
|
|
||||||
- [-1, 1, nn.Upsample, [None, 2, 'nearest']]
|
|
||||||
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
|
|
||||||
- [-1, 3, C2f, [256]] # 15 (P3/8-small)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [256, 3, 2]]
|
|
||||||
- [[-1, 12], 1, Concat, [1]] # cat head P4
|
|
||||||
- [-1, 3, C2f, [512]] # 18 (P4/16-medium)
|
|
||||||
|
|
||||||
- [-1, 1, Conv, [512, 3, 2]]
|
|
||||||
- [[-1, 9], 1, Concat, [1]] # cat head P5
|
|
||||||
- [-1, 3, C2f, [512]] # 21 (P5/32-large)
|
|
||||||
|
|
||||||
- [[15, 18, 21], 1, Detect, [nc]] # Detect(P3, P4, P5)
|
|
@ -170,7 +170,7 @@ class DetectionModel(BaseModel):
|
|||||||
# YOLOv8 detection model
|
# YOLOv8 detection model
|
||||||
def __init__(self, cfg='yolov8n.yaml', ch=3, nc=None, verbose=True): # model, input channels, number of classes
|
def __init__(self, cfg='yolov8n.yaml', ch=3, nc=None, verbose=True): # model, input channels, number of classes
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.yaml = cfg if isinstance(cfg, dict) else yaml_load(check_yaml(cfg), append_filename=True) # cfg dict
|
self.yaml = cfg if isinstance(cfg, dict) else yaml_model_load(cfg) # cfg dict
|
||||||
|
|
||||||
# Define model
|
# Define model
|
||||||
ch = self.yaml['ch'] = self.yaml.get('ch', ch) # input channels
|
ch = self.yaml['ch'] = self.yaml.get('ch', ch) # input channels
|
||||||
@ -277,7 +277,8 @@ class ClassificationModel(BaseModel):
|
|||||||
self.nc = nc
|
self.nc = nc
|
||||||
|
|
||||||
def _from_yaml(self, cfg, ch, nc, verbose):
|
def _from_yaml(self, cfg, ch, nc, verbose):
|
||||||
self.yaml = cfg if isinstance(cfg, dict) else yaml_load(check_yaml(cfg), append_filename=True) # cfg dict
|
self.yaml = cfg if isinstance(cfg, dict) else yaml_model_load(cfg) # cfg dict
|
||||||
|
|
||||||
# Define model
|
# Define model
|
||||||
ch = self.yaml['ch'] = self.yaml.get('ch', ch) # input channels
|
ch = self.yaml['ch'] = self.yaml.get('ch', ch) # input channels
|
||||||
if nc and nc != self.yaml['nc']:
|
if nc and nc != self.yaml['nc']:
|
||||||
@ -418,30 +419,42 @@ def attempt_load_one_weight(weight, device=None, inplace=True, fuse=False):
|
|||||||
|
|
||||||
|
|
||||||
def parse_model(d, ch, verbose=True): # model_dict, input_channels(3)
|
def parse_model(d, ch, verbose=True): # model_dict, input_channels(3)
|
||||||
# Parse a YOLO model.yaml dictionary
|
# Parse a YOLO model.yaml dictionary into a PyTorch model
|
||||||
if verbose:
|
import ast
|
||||||
LOGGER.info(f"\n{'':>3}{'from':>20}{'n':>3}{'params':>10} {'module':<45}{'arguments':<30}")
|
|
||||||
nc, gd, gw, act = d['nc'], d['depth_multiple'], d['width_multiple'], d.get('activation')
|
# Args
|
||||||
|
max_channels = float('inf')
|
||||||
|
nc, act, scales = (d.get(x) for x in ('nc', 'act', 'scales'))
|
||||||
|
depth, width = (d.get(x, 1.0) for x in ('depth_multiple', 'width_multiple'))
|
||||||
|
if scales:
|
||||||
|
scale = d.get('scale')
|
||||||
|
if not scale:
|
||||||
|
scale = tuple(scales.keys())[0]
|
||||||
|
LOGGER.warning(f"WARNING ⚠️ no model scale passed. Assuming scale='{scale}'.")
|
||||||
|
depth, width, max_channels = scales[scale]
|
||||||
|
|
||||||
if act:
|
if act:
|
||||||
Conv.default_act = eval(act) # redefine default activation, i.e. Conv.default_act = nn.SiLU()
|
Conv.default_act = eval(act) # redefine default activation, i.e. Conv.default_act = nn.SiLU()
|
||||||
if verbose:
|
if verbose:
|
||||||
LOGGER.info(f"{colorstr('activation:')} {act}") # print
|
LOGGER.info(f"{colorstr('activation:')} {act}") # print
|
||||||
|
|
||||||
|
if verbose:
|
||||||
|
LOGGER.info(f"\n{'':>3}{'from':>20}{'n':>3}{'params':>10} {'module':<45}{'arguments':<30}")
|
||||||
ch = [ch]
|
ch = [ch]
|
||||||
layers, save, c2 = [], [], ch[-1] # layers, savelist, ch out
|
layers, save, c2 = [], [], ch[-1] # layers, savelist, ch out
|
||||||
for i, (f, n, m, args) in enumerate(d['backbone'] + d['head']): # from, number, module, args
|
for i, (f, n, m, args) in enumerate(d['backbone'] + d['head']): # from, number, module, args
|
||||||
m = getattr(torch.nn, m[3:]) if 'nn.' in m else globals()[m] # get module
|
m = getattr(torch.nn, m[3:]) if 'nn.' in m else globals()[m] # get module
|
||||||
for j, a in enumerate(args):
|
for j, a in enumerate(args):
|
||||||
# TODO: re-implement with eval() removal if possible
|
if isinstance(a, str):
|
||||||
# args[j] = (locals()[a] if a in locals() else ast.literal_eval(a)) if isinstance(a, str) else a
|
with contextlib.suppress(ValueError):
|
||||||
with contextlib.suppress(NameError):
|
args[j] = locals()[a] if a in locals() else ast.literal_eval(a)
|
||||||
args[j] = eval(a) if isinstance(a, str) else a # eval strings
|
|
||||||
|
|
||||||
n = n_ = max(round(n * gd), 1) if n > 1 else n # depth gain
|
n = n_ = max(round(n * depth), 1) if n > 1 else n # depth gain
|
||||||
if m in (Classify, Conv, ConvTranspose, GhostConv, Bottleneck, GhostBottleneck, SPP, SPPF, DWConv, Focus,
|
if m in (Classify, Conv, ConvTranspose, GhostConv, Bottleneck, GhostBottleneck, SPP, SPPF, DWConv, Focus,
|
||||||
BottleneckCSP, C1, C2, C2f, C3, C3TR, C3Ghost, nn.ConvTranspose2d, DWConvTranspose2d, C3x):
|
BottleneckCSP, C1, C2, C2f, C3, C3TR, C3Ghost, nn.ConvTranspose2d, DWConvTranspose2d, C3x):
|
||||||
c1, c2 = ch[f], args[0]
|
c1, c2 = ch[f], args[0]
|
||||||
if c2 != nc: # if c2 not equal to number of classes (i.e. for Classify() output)
|
if c2 != nc: # if c2 not equal to number of classes (i.e. for Classify() output)
|
||||||
c2 = make_divisible(c2 * gw, 8)
|
c2 = make_divisible(min(c2, max_channels) * width, 8)
|
||||||
|
|
||||||
args = [c1, c2, *args[1:]]
|
args = [c1, c2, *args[1:]]
|
||||||
if m in (BottleneckCSP, C1, C2, C2f, C3, C3TR, C3Ghost, C3x):
|
if m in (BottleneckCSP, C1, C2, C2f, C3, C3TR, C3Ghost, C3x):
|
||||||
@ -454,7 +467,7 @@ def parse_model(d, ch, verbose=True): # model_dict, input_channels(3)
|
|||||||
elif m in (Detect, Segment):
|
elif m in (Detect, Segment):
|
||||||
args.append([ch[x] for x in f])
|
args.append([ch[x] for x in f])
|
||||||
if m is Segment:
|
if m is Segment:
|
||||||
args[2] = make_divisible(args[2] * gw, 8)
|
args[2] = make_divisible(min(args[2], max_channels) * width, 8)
|
||||||
else:
|
else:
|
||||||
c2 = ch[f]
|
c2 = ch[f]
|
||||||
|
|
||||||
@ -472,6 +485,41 @@ def parse_model(d, ch, verbose=True): # model_dict, input_channels(3)
|
|||||||
return nn.Sequential(*layers), sorted(save)
|
return nn.Sequential(*layers), sorted(save)
|
||||||
|
|
||||||
|
|
||||||
|
def yaml_model_load(path):
|
||||||
|
import re
|
||||||
|
|
||||||
|
path = Path(path)
|
||||||
|
if path.stem in (f'yolov{d}{x}6' for x in 'nsmlx' for d in (5, 8)):
|
||||||
|
new_stem = re.sub(r'(\d+)([nslmx])6(.+)?$', r'\1\2-p6\3', path.stem)
|
||||||
|
LOGGER.warning(f'WARNING ⚠️ Ultralytics YOLO P6 models now use -p6 suffix. Renaming {path.stem} to {new_stem}.')
|
||||||
|
path = path.with_stem(new_stem)
|
||||||
|
|
||||||
|
unified_path = re.sub(r'(\d+)([nslmx])(.+)?$', r'\1\3', str(path)) # i.e. yolov8x.yaml -> yolov8.yaml
|
||||||
|
yaml_file = check_yaml(unified_path, hard=False) or check_yaml(path)
|
||||||
|
d = yaml_load(yaml_file) # model dict
|
||||||
|
d['scale'] = guess_model_scale(path)
|
||||||
|
d['yaml_file'] = str(path)
|
||||||
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
def guess_model_scale(model_path):
|
||||||
|
"""
|
||||||
|
Takes a path to a YOLO model's YAML file as input and extracts the size character of the model's scale.
|
||||||
|
The function uses regular expression matching to find the pattern of the model scale in the YAML file name,
|
||||||
|
which is denoted by n, s, m, l, or x. The function returns the size character of the model scale as a string.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
model_path (str or Path): The path to the YOLO model's YAML file.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
(str): The size character of the model's scale, which can be n, s, m, l, or x.
|
||||||
|
"""
|
||||||
|
with contextlib.suppress(AttributeError):
|
||||||
|
import re
|
||||||
|
return re.search(r'yolov\d+([nslmx])', Path(model_path).stem).group(1) # n, s, m, l, or x
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def guess_model_task(model):
|
def guess_model_task(model):
|
||||||
"""
|
"""
|
||||||
Guess the task of a PyTorch model from its architecture or configuration.
|
Guess the task of a PyTorch model from its architecture or configuration.
|
||||||
|
@ -17,7 +17,7 @@ from .utils import HELP_URL, LOCAL_RANK, LOGGER, get_hash, img2label_paths, veri
|
|||||||
|
|
||||||
|
|
||||||
class YOLODataset(BaseDataset):
|
class YOLODataset(BaseDataset):
|
||||||
cache_version = '1.0.1' # dataset labels *.cache version, >= 1.0.0 for YOLOv8
|
cache_version = '1.0.2' # dataset labels *.cache version, >= 1.0.0 for YOLOv8
|
||||||
rand_interp_methods = [cv2.INTER_NEAREST, cv2.INTER_LINEAR, cv2.INTER_CUBIC, cv2.INTER_AREA, cv2.INTER_LANCZOS4]
|
rand_interp_methods = [cv2.INTER_NEAREST, cv2.INTER_LINEAR, cv2.INTER_CUBIC, cv2.INTER_AREA, cv2.INTER_LANCZOS4]
|
||||||
"""
|
"""
|
||||||
Dataset class for loading images object detection and/or segmentation labels in YOLO format.
|
Dataset class for loading images object detection and/or segmentation labels in YOLO format.
|
||||||
|
@ -245,8 +245,7 @@ class Exporter:
|
|||||||
if tflite:
|
if tflite:
|
||||||
f[7], _ = self._export_tflite(s_model, nms=False, agnostic_nms=self.args.agnostic_nms)
|
f[7], _ = self._export_tflite(s_model, nms=False, agnostic_nms=self.args.agnostic_nms)
|
||||||
if edgetpu:
|
if edgetpu:
|
||||||
f[8], _ = self._export_edgetpu(tflite_model=str(
|
f[8], _ = self._export_edgetpu(tflite_model=Path(f[5]) / f'{self.file.stem}_full_integer_quant.tflite')
|
||||||
Path(f[5]) / (self.file.stem + '_full_integer_quant.tflite'))) # int8 in/out
|
|
||||||
if tfjs:
|
if tfjs:
|
||||||
f[9], _ = self._export_tfjs()
|
f[9], _ = self._export_tfjs()
|
||||||
if paddle: # PaddlePaddle
|
if paddle: # PaddlePaddle
|
||||||
@ -532,9 +531,16 @@ class Exporter:
|
|||||||
subprocess.run(cmd, shell=True)
|
subprocess.run(cmd, shell=True)
|
||||||
yaml_save(f / 'metadata.yaml', self.metadata) # add metadata.yaml
|
yaml_save(f / 'metadata.yaml', self.metadata) # add metadata.yaml
|
||||||
|
|
||||||
|
# Remove/rename TFLite models
|
||||||
|
if self.args.int8:
|
||||||
|
for file in f.rglob('*_dynamic_range_quant.tflite'):
|
||||||
|
file.rename(file.with_stem(file.stem.replace('_dynamic_range_quant', '_int8')))
|
||||||
|
for file in f.rglob('*_integer_quant_with_int16_act.tflite'):
|
||||||
|
file.unlink() # delete extra fp16 activation TFLite files
|
||||||
|
|
||||||
# Add TFLite metadata
|
# Add TFLite metadata
|
||||||
for file in f.rglob('*.tflite'):
|
for file in f.rglob('*.tflite'):
|
||||||
self._add_tflite_metadata(file)
|
f.unlink() if 'quant_with_int16_act.tflite' in str(f) else self._add_tflite_metadata(file)
|
||||||
|
|
||||||
# Load saved_model
|
# Load saved_model
|
||||||
keras_model = tf.saved_model.load(f, tags=None, options=None)
|
keras_model = tf.saved_model.load(f, tags=None, options=None)
|
||||||
@ -565,9 +571,9 @@ class Exporter:
|
|||||||
LOGGER.info(f'\n{prefix} starting export with tensorflow {tf.__version__}...')
|
LOGGER.info(f'\n{prefix} starting export with tensorflow {tf.__version__}...')
|
||||||
saved_model = Path(str(self.file).replace(self.file.suffix, '_saved_model'))
|
saved_model = Path(str(self.file).replace(self.file.suffix, '_saved_model'))
|
||||||
if self.args.int8:
|
if self.args.int8:
|
||||||
f = saved_model / f'{self.file.stem}_integer_quant.tflite' # fp32 in/out
|
f = saved_model / f'{self.file.stem}_int8.tflite' # fp32 in/out
|
||||||
elif self.args.half:
|
elif self.args.half:
|
||||||
f = saved_model / f'{self.file.stem}_float16.tflite'
|
f = saved_model / f'{self.file.stem}_float16.tflite' # fp32 in/out
|
||||||
else:
|
else:
|
||||||
f = saved_model / f'{self.file.stem}_float32.tflite'
|
f = saved_model / f'{self.file.stem}_float32.tflite'
|
||||||
return str(f), None
|
return str(f), None
|
||||||
|
@ -5,7 +5,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
from ultralytics import yolo # noqa
|
from ultralytics import yolo # noqa
|
||||||
from ultralytics.nn.tasks import (ClassificationModel, DetectionModel, SegmentationModel, attempt_load_one_weight,
|
from ultralytics.nn.tasks import (ClassificationModel, DetectionModel, SegmentationModel, attempt_load_one_weight,
|
||||||
guess_model_task, nn)
|
guess_model_task, nn, yaml_model_load)
|
||||||
from ultralytics.yolo.cfg import get_cfg
|
from ultralytics.yolo.cfg import get_cfg
|
||||||
from ultralytics.yolo.engine.exporter import Exporter
|
from ultralytics.yolo.engine.exporter import Exporter
|
||||||
from ultralytics.yolo.utils import (DEFAULT_CFG, DEFAULT_CFG_DICT, DEFAULT_CFG_KEYS, LOGGER, RANK, ROOT, callbacks,
|
from ultralytics.yolo.utils import (DEFAULT_CFG, DEFAULT_CFG_DICT, DEFAULT_CFG_KEYS, LOGGER, RANK, ROOT, callbacks,
|
||||||
@ -111,8 +111,8 @@ class YOLO:
|
|||||||
task (str) or (None): model task
|
task (str) or (None): model task
|
||||||
verbose (bool): display model info on load
|
verbose (bool): display model info on load
|
||||||
"""
|
"""
|
||||||
self.cfg = check_yaml(cfg) # check YAML
|
cfg_dict = yaml_model_load(cfg)
|
||||||
cfg_dict = yaml_load(self.cfg, append_filename=True) # model dict
|
self.cfg = cfg
|
||||||
self.task = task or guess_model_task(cfg_dict)
|
self.task = task or guess_model_task(cfg_dict)
|
||||||
self.model = TASK_MAP[self.task][0](cfg_dict, verbose=verbose and RANK == -1) # build model
|
self.model = TASK_MAP[self.task][0](cfg_dict, verbose=verbose and RANK == -1) # build model
|
||||||
self.overrides['model'] = self.cfg
|
self.overrides['model'] = self.cfg
|
||||||
|
@ -248,9 +248,9 @@ def check_yolov5u_filename(file: str, verbose: bool = True):
|
|||||||
# Replace legacy YOLOv5 filenames with updated YOLOv5u filenames
|
# Replace legacy YOLOv5 filenames with updated YOLOv5u filenames
|
||||||
if ('yolov3' in file or 'yolov5' in file) and 'u' not in file:
|
if ('yolov3' in file or 'yolov5' in file) and 'u' not in file:
|
||||||
original_file = file
|
original_file = file
|
||||||
file = re.sub(r'(.*yolov5([nsmlx]))\.', '\\1u.', file) # i.e. yolov5n.pt -> yolov5nu.pt
|
file = re.sub(r'(.*yolov5([nsmlx]))\.pt', '\\1u.pt', file) # i.e. yolov5n.pt -> yolov5nu.pt
|
||||||
file = re.sub(r'(.*yolov5([nsmlx])6)\.', '\\1u.', file) # i.e. yolov5n6.pt -> yolov5n6u.pt
|
file = re.sub(r'(.*yolov5([nsmlx])6)\.pt', '\\1u.pt', file) # i.e. yolov5n6.pt -> yolov5n6u.pt
|
||||||
file = re.sub(r'(.*yolov3(|-tiny|-spp))\.', '\\1u.', file) # i.e. yolov3-spp.pt -> yolov3-sppu.pt
|
file = re.sub(r'(.*yolov3(|-tiny|-spp))\.pt', '\\1u.pt', file) # i.e. yolov3-spp.pt -> yolov3-sppu.pt
|
||||||
if file != original_file and verbose:
|
if file != original_file and verbose:
|
||||||
LOGGER.info(f"PRO TIP 💡 Replace 'model={original_file}' with new 'model={file}'.\nYOLOv5 'u' models are "
|
LOGGER.info(f"PRO TIP 💡 Replace 'model={original_file}' with new 'model={file}'.\nYOLOv5 'u' models are "
|
||||||
f'trained with https://github.com/ultralytics/ultralytics and feature improved performance vs '
|
f'trained with https://github.com/ultralytics/ultralytics and feature improved performance vs '
|
||||||
@ -258,7 +258,7 @@ def check_yolov5u_filename(file: str, verbose: bool = True):
|
|||||||
return file
|
return file
|
||||||
|
|
||||||
|
|
||||||
def check_file(file, suffix='', download=True):
|
def check_file(file, suffix='', download=True, hard=True):
|
||||||
# Search/download file (if necessary) and return path
|
# Search/download file (if necessary) and return path
|
||||||
check_suffix(file, suffix) # optional
|
check_suffix(file, suffix) # optional
|
||||||
file = str(file) # convert to string
|
file = str(file) # convert to string
|
||||||
@ -277,16 +277,16 @@ def check_file(file, suffix='', download=True):
|
|||||||
files = []
|
files = []
|
||||||
for d in 'models', 'datasets', 'tracker/cfg', 'yolo/cfg': # search directories
|
for d in 'models', 'datasets', 'tracker/cfg', 'yolo/cfg': # search directories
|
||||||
files.extend(glob.glob(str(ROOT / d / '**' / file), recursive=True)) # find file
|
files.extend(glob.glob(str(ROOT / d / '**' / file), recursive=True)) # find file
|
||||||
if not files:
|
if not files and hard:
|
||||||
raise FileNotFoundError(f"'{file}' does not exist")
|
raise FileNotFoundError(f"'{file}' does not exist")
|
||||||
elif len(files) > 1:
|
elif len(files) > 1 and hard:
|
||||||
raise FileNotFoundError(f"Multiple files match '{file}', specify exact path: {files}")
|
raise FileNotFoundError(f"Multiple files match '{file}', specify exact path: {files}")
|
||||||
return files[0] # return file
|
return files[0] if len(files) else [] # return file
|
||||||
|
|
||||||
|
|
||||||
def check_yaml(file, suffix=('.yaml', '.yml')):
|
def check_yaml(file, suffix=('.yaml', '.yml'), hard=True):
|
||||||
# Search/download YAML file (if necessary) and return path, checking suffix
|
# Search/download YAML file (if necessary) and return path, checking suffix
|
||||||
return check_file(file, suffix)
|
return check_file(file, suffix, hard=hard)
|
||||||
|
|
||||||
|
|
||||||
def check_imshow(warn=False):
|
def check_imshow(warn=False):
|
||||||
|
@ -63,13 +63,12 @@ class DetectionPredictor(BasePredictor):
|
|||||||
|
|
||||||
# write
|
# write
|
||||||
for d in reversed(det):
|
for d in reversed(det):
|
||||||
cls, conf, id = d.cls.squeeze(), d.conf.squeeze(), None if d.id is None else int(d.id.item())
|
c, conf, id = int(d.cls), float(d.conf), None if d.id is None else int(d.id.item())
|
||||||
if self.args.save_txt: # Write to file
|
if self.args.save_txt: # Write to file
|
||||||
line = (cls, *d.xywhn.view(-1)) + (conf, ) * self.args.save_conf + (() if id is None else (id, ))
|
line = (c, *d.xywhn.view(-1)) + (conf, ) * self.args.save_conf + (() if id is None else (id, ))
|
||||||
with open(f'{self.txt_path}.txt', 'a') as f:
|
with open(f'{self.txt_path}.txt', 'a') as f:
|
||||||
f.write(('%g ' * len(line)).rstrip() % line + '\n')
|
f.write(('%g ' * len(line)).rstrip() % line + '\n')
|
||||||
if self.args.save or self.args.save_crop or self.args.show: # Add bbox to image
|
if self.args.save or self.args.show: # Add bbox to image
|
||||||
c = int(cls) # integer class
|
|
||||||
name = ('' if id is None else f'id:{id} ') + self.model.names[c]
|
name = ('' if id is None else f'id:{id} ') + self.model.names[c]
|
||||||
label = None if self.args.hide_labels else (name if self.args.hide_conf else f'{name} {conf:.2f}')
|
label = None if self.args.hide_labels else (name if self.args.hide_conf else f'{name} {conf:.2f}')
|
||||||
self.annotator.box_label(d.xyxy.squeeze(), label, color=colors(c, True))
|
self.annotator.box_label(d.xyxy.squeeze(), label, color=colors(c, True))
|
||||||
|
@ -76,17 +76,17 @@ class SegmentationPredictor(DetectionPredictor):
|
|||||||
|
|
||||||
# Write results
|
# Write results
|
||||||
for j, d in enumerate(reversed(det)):
|
for j, d in enumerate(reversed(det)):
|
||||||
cls, conf, id = d.cls.squeeze(), d.conf.squeeze(), None if d.id is None else int(d.id.item())
|
c, conf, id = int(d.cls), float(d.conf), None if d.id is None else int(d.id.item())
|
||||||
if self.args.save_txt: # Write to file
|
if self.args.save_txt: # Write to file
|
||||||
seg = mask.segments[len(det) - j - 1].copy().reshape(-1) # reversed mask.segments, (n,2) to (n*2)
|
seg = mask.segments[len(det) - j - 1].copy().reshape(-1) # reversed mask.segments, (n,2) to (n*2)
|
||||||
line = (cls, *seg) + (conf, ) * self.args.save_conf + (() if id is None else (id, ))
|
line = (c, *seg) + (conf, ) * self.args.save_conf + (() if id is None else (id, ))
|
||||||
with open(f'{self.txt_path}.txt', 'a') as f:
|
with open(f'{self.txt_path}.txt', 'a') as f:
|
||||||
f.write(('%g ' * len(line)).rstrip() % line + '\n')
|
f.write(('%g ' * len(line)).rstrip() % line + '\n')
|
||||||
if self.args.save or self.args.save_crop or self.args.show: # Add bbox to image
|
if self.args.save or self.args.show: # Add bbox to image
|
||||||
c = int(cls) # integer class
|
|
||||||
name = ('' if id is None else f'id:{id} ') + self.model.names[c]
|
name = ('' if id is None else f'id:{id} ') + self.model.names[c]
|
||||||
label = None if self.args.hide_labels else (name if self.args.hide_conf else f'{name} {conf:.2f}')
|
label = None if self.args.hide_labels else (name if self.args.hide_conf else f'{name} {conf:.2f}')
|
||||||
self.annotator.box_label(d.xyxy.squeeze(), label, color=colors(c, True)) if self.args.boxes else None
|
if self.args.boxes:
|
||||||
|
self.annotator.box_label(d.xyxy.squeeze(), label, color=colors(c, True))
|
||||||
if self.args.save_crop:
|
if self.args.save_crop:
|
||||||
save_one_box(d.xyxy,
|
save_one_box(d.xyxy,
|
||||||
imc,
|
imc,
|
||||||
|
@ -122,13 +122,15 @@ class SegLoss(Loss):
|
|||||||
xyxyn = target_bboxes[i][fg_mask[i]] / imgsz[[1, 0, 1, 0]]
|
xyxyn = target_bboxes[i][fg_mask[i]] / imgsz[[1, 0, 1, 0]]
|
||||||
marea = xyxy2xywh(xyxyn)[:, 2:].prod(1)
|
marea = xyxy2xywh(xyxyn)[:, 2:].prod(1)
|
||||||
mxyxy = xyxyn * torch.tensor([mask_w, mask_h, mask_w, mask_h], device=self.device)
|
mxyxy = xyxyn * torch.tensor([mask_w, mask_h, mask_w, mask_h], device=self.device)
|
||||||
loss[1] += self.single_mask_loss(gt_mask, pred_masks[i][fg_mask[i]], proto[i], mxyxy,
|
loss[1] += self.single_mask_loss(gt_mask, pred_masks[i][fg_mask[i]], proto[i], mxyxy, marea) # seg
|
||||||
marea) # seg loss
|
|
||||||
# WARNING: Uncomment lines below in case of Multi-GPU DDP unused gradient errors
|
# WARNING: lines below prevents Multi-GPU DDP 'unused gradient' PyTorch errors, do not remove
|
||||||
# else:
|
else:
|
||||||
# loss[1] += proto.sum() * 0 + pred_masks.sum() * 0
|
loss[1] += proto.sum() * 0 + pred_masks.sum() * 0
|
||||||
# else:
|
|
||||||
# loss[1] += proto.sum() * 0 + pred_masks.sum() * 0
|
# WARNING: lines below prevent Multi-GPU DDP 'unused gradient' PyTorch errors, do not remove
|
||||||
|
else:
|
||||||
|
loss[1] += proto.sum() * 0 + pred_masks.sum() * 0
|
||||||
|
|
||||||
loss[0] *= self.hyp.box # box gain
|
loss[0] *= self.hyp.box # box gain
|
||||||
loss[1] *= self.hyp.box / batch_size # seg gain
|
loss[1] *= self.hyp.box / batch_size # seg gain
|
||||||
|
Loading…
x
Reference in New Issue
Block a user