## 模型的深度和宽度

`yolo.py` 中， `parse_model` 函数下的这行代码将深度因子和宽度因子进行读取和赋值。

`anchors, nc, gd, gw = d['anchors'], d['nc'], d['depth_multiple'], d['width_multiple']`

## depth_multiple

`n = max(round(n * gd), 1) if n > 1 else n  # depth gain`

## width_multiple

`c2 = make_divisible(c2 * gw, 8)`

## backbone

```backbone:
# [from, number, module, args]
# from表示当前模块的输入来自那一层的输出，-1表示来自上一层的输出
# number表示本模块重复的次数，1表示只有一个，3表示重复3次
# module: 模块名
[[-1, 1, Focus, [64, 3]],          # 0-P1/2   [3, 32, 3]
[-1, 1, Conv, [128, 3, 2]],       # 1-P2/4   [32, 64, 3, 2]
[-1, 3, C3, [128]],               # 2        [64, 64, 1]
[-1, 1, Conv, [256, 3, 2]],       # 3-P3/8   [64, 128, 3, 2]
[-1, 9, C3, [256]],               # 4        [128, 128, 3]
[-1, 1, Conv, [512, 3, 2]],       # 5-P4/16  [128, 256, 3, 2]
[-1, 9, C3, [512]],               # 6        [256, 256, 3]
[-1, 1, Conv, [1024, 3, 2]],      # 7-P5/32  [256, 512, 3, 2]
[-1, 1, SPP, [1024, [5, 9, 13]]], # 8        [512, 512, [5, 9, 13]]
[-1, 3, C3, [1024, False]],       # 9        [512, 512, 1, False]
]```

`out_size = （in_size - K + 2P）/ S +1`

```head:
[[-1, 1, Conv, [512, 1, 1]], # 10                 [512, 256, 1, 1]
[-1, 1, nn.Upsample, [None, 2, 'nearest']], # 11 [None, 2, 'nearest']
[[-1, 6], 1, Concat, [1]],  # 12 cat backbone P4 [1]
[-1, 3, C3, [512, False]],  # 13                 [512, 256, 1, False]
[-1, 1, Conv, [256, 1, 1]], # 14                 [256, 128, 1, 1]
[-1, 1, nn.Upsample, [None, 2, 'nearest']], #15  [None, 2, 'nearest']
[[-1, 4], 1, Concat, [1]],  # 16 cat backbone P3 [1]
[-1, 3, C3, [256, False]],  # 17 (P3/8-small)    [256, 128, 1, False]
[-1, 1, Conv, [256, 3, 2]], # 18                 [128, 128, 3, 2]
[[-1, 14], 1, Concat, [1]], # 19 cat head P4     [1]
[-1, 3, C3, [512, False]],  # 20 (P4/16-medium)  [256, 256, 1, False]
[-1, 1, Conv, [512, 3, 2]], # 21                 [256, 256, 3, 2]
[[-1, 10], 1, Concat, [1]], # 22 cat head P5     [1]
[-1, 3, C3, [1024, False]], # 23 (P5/32-large)   [512, 512, 1, False]
[[17, 20, 23], 1, Detect, [nc, anchors]],  # 24  Detect(P3, P4, P5)
]```