glenn-jocher
commited on
Commit
β’
33a67b4
1
Parent(s):
ad565e3
Update P2-P7 `models/hub` variants (#6230)
Browse files* Update p2-p7 `models/hub` variants
* Update common.py
* AutoAnchor camelcase corrections
- models/common.py +1 -1
- models/hub/yolov5-p2.yaml +2 -2
- models/hub/yolov5-p34.yaml +41 -0
- models/hub/yolov5-p6.yaml +2 -2
- models/hub/yolov5-p7.yaml +2 -2
- train.py +1 -1
- tutorial.ipynb +1 -1
models/common.py
CHANGED
@@ -306,7 +306,7 @@ class DetectMultiBackend(nn.Module):
|
|
306 |
|
307 |
if pt: # PyTorch
|
308 |
model = attempt_load(weights if isinstance(weights, list) else w, map_location=device)
|
309 |
-
stride = int(model.stride.max()) # model stride
|
310 |
names = model.module.names if hasattr(model, 'module') else model.names # get class names
|
311 |
self.model = model # explicitly assign for to(), cpu(), cuda(), half()
|
312 |
elif jit: # TorchScript
|
|
|
306 |
|
307 |
if pt: # PyTorch
|
308 |
model = attempt_load(weights if isinstance(weights, list) else w, map_location=device)
|
309 |
+
stride = max(int(model.stride.max()), 32) # model stride
|
310 |
names = model.module.names if hasattr(model, 'module') else model.names # get class names
|
311 |
self.model = model # explicitly assign for to(), cpu(), cuda(), half()
|
312 |
elif jit: # TorchScript
|
models/hub/yolov5-p2.yaml
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
nc: 80 # number of classes
|
5 |
depth_multiple: 1.0 # model depth multiple
|
6 |
width_multiple: 1.0 # layer channel multiple
|
7 |
-
anchors: 3 #
|
8 |
|
9 |
# YOLOv5 v6.0 backbone
|
10 |
backbone:
|
@@ -21,7 +21,7 @@ backbone:
|
|
21 |
[-1, 1, SPPF, [1024, 5]], # 9
|
22 |
]
|
23 |
|
24 |
-
# YOLOv5 v6.0 head
|
25 |
head:
|
26 |
[[-1, 1, Conv, [512, 1, 1]],
|
27 |
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
|
4 |
nc: 80 # number of classes
|
5 |
depth_multiple: 1.0 # model depth multiple
|
6 |
width_multiple: 1.0 # layer channel multiple
|
7 |
+
anchors: 3 # AutoAnchor evolves 3 anchors per P output layer
|
8 |
|
9 |
# YOLOv5 v6.0 backbone
|
10 |
backbone:
|
|
|
21 |
[-1, 1, SPPF, [1024, 5]], # 9
|
22 |
]
|
23 |
|
24 |
+
# YOLOv5 v6.0 head with (P2, P3, P4, P5) outputs
|
25 |
head:
|
26 |
[[-1, 1, Conv, [512, 1, 1]],
|
27 |
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
models/hub/yolov5-p34.yaml
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# YOLOv5 π by Ultralytics, GPL-3.0 license
|
2 |
+
|
3 |
+
# Parameters
|
4 |
+
nc: 80 # number of classes
|
5 |
+
depth_multiple: 0.33 # model depth multiple
|
6 |
+
width_multiple: 0.50 # layer channel multiple
|
7 |
+
anchors: 3 # AutoAnchor evolves 3 anchors per P output layer
|
8 |
+
|
9 |
+
# YOLOv5 v6.0 backbone
|
10 |
+
backbone:
|
11 |
+
# [from, number, module, args]
|
12 |
+
[ [ -1, 1, Conv, [ 64, 6, 2, 2 ] ], # 0-P1/2
|
13 |
+
[ -1, 1, Conv, [ 128, 3, 2 ] ], # 1-P2/4
|
14 |
+
[ -1, 3, C3, [ 128 ] ],
|
15 |
+
[ -1, 1, Conv, [ 256, 3, 2 ] ], # 3-P3/8
|
16 |
+
[ -1, 6, C3, [ 256 ] ],
|
17 |
+
[ -1, 1, Conv, [ 512, 3, 2 ] ], # 5-P4/16
|
18 |
+
[ -1, 9, C3, [ 512 ] ],
|
19 |
+
[ -1, 1, Conv, [ 1024, 3, 2 ] ], # 7-P5/32
|
20 |
+
[ -1, 3, C3, [ 1024 ] ],
|
21 |
+
[ -1, 1, SPPF, [ 1024, 5 ] ], # 9
|
22 |
+
]
|
23 |
+
|
24 |
+
# YOLOv5 v6.0 head with (P3, P4) outputs
|
25 |
+
head:
|
26 |
+
[ [ -1, 1, Conv, [ 512, 1, 1 ] ],
|
27 |
+
[ -1, 1, nn.Upsample, [ None, 2, 'nearest' ] ],
|
28 |
+
[ [ -1, 6 ], 1, Concat, [ 1 ] ], # cat backbone P4
|
29 |
+
[ -1, 3, C3, [ 512, False ] ], # 13
|
30 |
+
|
31 |
+
[ -1, 1, Conv, [ 256, 1, 1 ] ],
|
32 |
+
[ -1, 1, nn.Upsample, [ None, 2, 'nearest' ] ],
|
33 |
+
[ [ -1, 4 ], 1, Concat, [ 1 ] ], # cat backbone P3
|
34 |
+
[ -1, 3, C3, [ 256, False ] ], # 17 (P3/8-small)
|
35 |
+
|
36 |
+
[ -1, 1, Conv, [ 256, 3, 2 ] ],
|
37 |
+
[ [ -1, 14 ], 1, Concat, [ 1 ] ], # cat head P4
|
38 |
+
[ -1, 3, C3, [ 512, False ] ], # 20 (P4/16-medium)
|
39 |
+
|
40 |
+
[ [ 17, 20 ], 1, Detect, [ nc, anchors ] ], # Detect(P3, P4)
|
41 |
+
]
|
models/hub/yolov5-p6.yaml
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
nc: 80 # number of classes
|
5 |
depth_multiple: 1.0 # model depth multiple
|
6 |
width_multiple: 1.0 # layer channel multiple
|
7 |
-
anchors: 3 #
|
8 |
|
9 |
# YOLOv5 v6.0 backbone
|
10 |
backbone:
|
@@ -23,7 +23,7 @@ backbone:
|
|
23 |
[-1, 1, SPPF, [1024, 5]], # 11
|
24 |
]
|
25 |
|
26 |
-
# YOLOv5 v6.0 head
|
27 |
head:
|
28 |
[[-1, 1, Conv, [768, 1, 1]],
|
29 |
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
|
4 |
nc: 80 # number of classes
|
5 |
depth_multiple: 1.0 # model depth multiple
|
6 |
width_multiple: 1.0 # layer channel multiple
|
7 |
+
anchors: 3 # AutoAnchor evolves 3 anchors per P output layer
|
8 |
|
9 |
# YOLOv5 v6.0 backbone
|
10 |
backbone:
|
|
|
23 |
[-1, 1, SPPF, [1024, 5]], # 11
|
24 |
]
|
25 |
|
26 |
+
# YOLOv5 v6.0 head with (P3, P4, P5, P6) outputs
|
27 |
head:
|
28 |
[[-1, 1, Conv, [768, 1, 1]],
|
29 |
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
models/hub/yolov5-p7.yaml
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
nc: 80 # number of classes
|
5 |
depth_multiple: 1.0 # model depth multiple
|
6 |
width_multiple: 1.0 # layer channel multiple
|
7 |
-
anchors: 3 #
|
8 |
|
9 |
# YOLOv5 v6.0 backbone
|
10 |
backbone:
|
@@ -25,7 +25,7 @@ backbone:
|
|
25 |
[-1, 1, SPPF, [1280, 5]], # 13
|
26 |
]
|
27 |
|
28 |
-
# YOLOv5 head
|
29 |
head:
|
30 |
[[-1, 1, Conv, [1024, 1, 1]],
|
31 |
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
|
|
4 |
nc: 80 # number of classes
|
5 |
depth_multiple: 1.0 # model depth multiple
|
6 |
width_multiple: 1.0 # layer channel multiple
|
7 |
+
anchors: 3 # AutoAnchor evolves 3 anchors per P output layer
|
8 |
|
9 |
# YOLOv5 v6.0 backbone
|
10 |
backbone:
|
|
|
25 |
[-1, 1, SPPF, [1280, 5]], # 13
|
26 |
]
|
27 |
|
28 |
+
# YOLOv5 v6.0 head with (P3, P4, P5, P6, P7) outputs
|
29 |
head:
|
30 |
[[-1, 1, Conv, [1024, 1, 1]],
|
31 |
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
|
train.py
CHANGED
@@ -461,7 +461,7 @@ def parse_opt(known=False):
|
|
461 |
parser.add_argument('--resume', nargs='?', const=True, default=False, help='resume most recent training')
|
462 |
parser.add_argument('--nosave', action='store_true', help='only save final checkpoint')
|
463 |
parser.add_argument('--noval', action='store_true', help='only validate final epoch')
|
464 |
-
parser.add_argument('--noautoanchor', action='store_true', help='disable
|
465 |
parser.add_argument('--evolve', type=int, nargs='?', const=300, help='evolve hyperparameters for x generations')
|
466 |
parser.add_argument('--bucket', type=str, default='', help='gsutil bucket')
|
467 |
parser.add_argument('--cache', type=str, nargs='?', const='ram', help='--cache images in "ram" (default) or "disk"')
|
|
|
461 |
parser.add_argument('--resume', nargs='?', const=True, default=False, help='resume most recent training')
|
462 |
parser.add_argument('--nosave', action='store_true', help='only save final checkpoint')
|
463 |
parser.add_argument('--noval', action='store_true', help='only validate final epoch')
|
464 |
+
parser.add_argument('--noautoanchor', action='store_true', help='disable AutoAnchor')
|
465 |
parser.add_argument('--evolve', type=int, nargs='?', const=300, help='evolve hyperparameters for x generations')
|
466 |
parser.add_argument('--bucket', type=str, default='', help='gsutil bucket')
|
467 |
parser.add_argument('--cache', type=str, nargs='?', const='ram', help='--cache images in "ram" (default) or "disk"')
|
tutorial.ipynb
CHANGED
@@ -777,7 +777,7 @@
|
|
777 |
"\u001b[34m\u001b[1mval: \u001b[0mCaching images (0.1GB ram): 100% 128/128 [00:01<00:00, 121.58it/s]\n",
|
778 |
"Plotting labels... \n",
|
779 |
"\n",
|
780 |
-
"\u001b[34m\u001b[
|
781 |
"Image sizes 640 train, 640 val\n",
|
782 |
"Using 2 dataloader workers\n",
|
783 |
"Logging results to \u001b[1mruns/train/exp\u001b[0m\n",
|
|
|
777 |
"\u001b[34m\u001b[1mval: \u001b[0mCaching images (0.1GB ram): 100% 128/128 [00:01<00:00, 121.58it/s]\n",
|
778 |
"Plotting labels... \n",
|
779 |
"\n",
|
780 |
+
"\u001b[34m\u001b[1mAutoAnchor: \u001b[0mAnalyzing anchors... anchors/target = 4.27, Best Possible Recall (BPR) = 0.9935\n",
|
781 |
"Image sizes 640 train, 640 val\n",
|
782 |
"Using 2 dataloader workers\n",
|
783 |
"Logging results to \u001b[1mruns/train/exp\u001b[0m\n",
|