输入的图片size为什么是32的倍数,yolo各个模型层说明。upsample+route过程

输入的图片size为什么是32的倍数,yolo各个模型层说明。upsample+route过程

enter description here
enter description here

以上是filter之后size的计算过程,总共是5次计算,所以是2的5次方次变值所以是32。其余size没有变值的没有改变。此时module形态:stride是2

(conv_1): Conv2d(32, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
(batch_norm_1): BatchNorm2d(64, eps=1e-05, momentum=0.9, affine=True, track_running_stats=True)
(leaky_1): LeakyReLU(negative_slope=0.1)

size没有改变的情况下,只有通道数改变,涉及到一个残差过程,所以有一个只改变通道的过程:stride 是1

(1): Sequential(
(conv_1): Conv2d(32, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
(batch_norm_1): BatchNorm2d(64, eps=1e-05, momentum=0.9, affine=True, track_running_stats=True)
(leaky_1): LeakyReLU(negative_slope=0.1)
)
(2): Sequential(
(conv_2): Conv2d(64, 32, kernel_size=(1, 1), stride=(1, 1), bias=False)
(batch_norm_2): BatchNorm2d(32, eps=1e-05, momentum=0.9, affine=True, track_running_stats=True)
(leaky_2): LeakyReLU(negative_slope=0.1)
)
(3): Sequential(
(conv_3): Conv2d(32, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)
(batch_norm_3): BatchNorm2d(64, eps=1e-05, momentum=0.9, affine=True, track_running_stats=True)
(leaky_3): LeakyReLU(negative_slope=0.1)
)

只有在改变size大小的时候大幅提升通道数

64->128->512->1024

第一个youlo层前变换: Conv2d(1024, 255, kernel_size=(1, 1), stride=(1, 1)),size是12

route

当前输出改为倒数第四个的输出,为第二个yolo层进入的x输入,这时候通道数改变了变成512

else if module_def["type"] == "route":
x = torch.cat([layer_outputs[int(layer_i)] for layer_i in module_def["layers"].

upsample+route过程

enter description here
enter description here

第一个yolo之后回route到yolo之前倒数第四个模型出来的x值。然后进行往下一层变换,到特定细节层之后,torch采样函数变成和上边某一层size一样的层,然后用torch.cat拼接成新的层。这个新的层之后只做通道操作不改变size大小,这个新的层重新提取特征。

enter description here
enter description here

都是在一个yolo之后进行路由到之前层,然后用采样函数和之前对应size层,cat住,再重新提取特征。进入下一个yolo层

1、通道数是可以确定的。
2、size数是分别是:imgsize/32的倍数,imgsize/16的倍数,imgsize/8的倍数
3、经过stride后会变换特征图大小一共有5次,每次都是2倍所以确定imgsize大小要是2^5=32倍数

posted @ 2020-03-18 20:26  vivia~  阅读(3038)  评论(0编辑  收藏  举报