保姆级 Keras 实现 YOLO v3 一

保姆级 Keras 实现 YOLO v3 一

  • 一. YOLO v3 总览
  • 二. 特征提取网络
    • 特征提取网络代码实现
  • 三. 特征融合
    • 特征融合代码实现
  • 四. 网络输出
    • 模型输出代码实现
  • 五. 网络模型代码实现

如果要给 YOLO 目标检测算法一个评价的话, 就是快和准, 现在已经到了 v8, 但是我为什么还要写 v3 呢? 我觉得 v3 是一个节点, 承上启下的节点. 它有 v1 和 v2 的影子, 也为后面的其他版本奠定了基础. 对于教学或者学习 YOLO 是极好的

一. YOLO v3 总览

如果要给 YOLO v3 一个学习的策略的话, 我觉得从整体到局部比较合适, 我们把 YOLO v3 总结如下

v3 view
相比于祥细的结构图, 这样的三个框就把 YOLO v3 概括完了. 后面我们再将各个部分拆开祥细说明, 这就是从整体到局部的策略

二. 特征提取网络

这是最容易实现的部分, 因为不会涉及到坐标计算与损失函数之类的东西, 只需要按结构用代码实现即可, 下面是结构图, 括号里面的数字是各方块输出的 shape

dark_net

这个也不是祥细的结构图, 祥细的结构图还需要将各个方块展开, 前面的数字是 n 个这样的 Block 重复, 现在把 Conv Block 展开如下

conv_block

Residual Block 展开如下

residual block

特征图的尺寸是输入图像的 1 32 1 \over 32 321, 但是并没有用我们常见的 Pooling 来减小特征图尺寸, 而是使用步长为 2 的卷积层来实现的, 就是各个 Residual Block 之前的 Conv2D 层

Conv2D(kernel_size = (3, 3), strides = (2, 2), padding = "same")

特征提取网络代码实现

因为结构有重复性, 所以可以定义一个函数来重复调用

# 定义 cbl (Conv2D, BatchNormalization, LeakyReLU) 函数
def cbl(inputs, filters, kernel_size):x = keras.layers.Conv2D(filters = filters, kernel_size = kernel_size, strides = (1, 1),padding = "valid" if (1, 1) == kernel_size else "same")(inputs)x = keras.layers.BatchNormalization()(x)x = keras.layers.LeakyReLU(alpha = 0.1)(x)return x

接下来定义 Residual Block

# 定义 residual_block 函数
# filters: 第一个 cbl 的卷积核数量, 第二个 cbl 卷积核数量自动乘 2
# repeats: 模块重复次数
def residual_block(inputs, filters, repeats):x = inputsfor i in range(repeats):x = cbl(x, filters, kernel_size = (1, 1))x = cbl(x, filters * 2, kernel_size = (3, 3))x = keras.layers.Add()([inputs, x])return x

有了这两个函数, 就可以定义完整的特征提取网络 darknet

# 定义 darn_net 函数
def dark_net(inputs = None):x = cbl(inputs, filters = 32, kernel_size = (3, 3))x = keras.layers.Conv2D(filters = 64, kernel_size = (3, 3), strides = (2, 2), padding = "same")(x)x = residual_block(x, filters = 32, repeats = 1)x = keras.layers.Conv2D(filters = 128, kernel_size = (3, 3), strides = (2, 2), padding = "same")(x)x = residual_block(x, filters = 64, repeats = 2)x = keras.layers.Conv2D(filters = 256, kernel_size = (3, 3), strides = (2, 2), padding = "same")(x)# 52 × 52 特征图x_52 = residual_block(x, filters = 128, repeats = 8)x = keras.layers.Conv2D(filters = 512, kernel_size = (3, 3), strides = (2, 2), padding = "same")(x_52)# 26 × 26 特征图x_26 = residual_block(x, filters = 256, repeats = 8)x = keras.layers.Conv2D(filters = 1024, kernel_size = (3, 3), strides = (2, 2), padding = "same")(x_26)# 13 × 13 特征图x_13 = residual_block(x, filters = 512, repeats = 4)return x_13, x_26, x_52

这样就和前面的结构图对上了, 函数输出 x_13, x_26, x_52 三层, 后面特征融合的时候会用到

三. 特征融合

这个也没有什么大问题, 只需要将上面的 13 × 13 特征图上采样放大与 26 × 26 特征图在最后一个维度拼接, 26 × 26 特征图上采样放大与 52 × 52 特征图在最后一个维度拼接, 如下图

neck

特征融合代码实现

特征融合 Conv Block 部分也有很多重复的方块, 所以可以定义成一个函数方便调用

# 定义 cbl block 函数
# filters: 第一个 block 的卷积核数量, 其他会自动计算
def cbl_block(inputs, filters):x = cbl(inputs, filters, kernel_size = (1, 1))x = cbl(x, filters * 2, kernel_size = (3, 3))x = cbl(x, filters, kernel_size = (1, 1))x = cbl(x, filters * 2, kernel_size = (3, 3))x = cbl(x, filters, kernel_size = (1, 1))return x

总的特征融合函数如下

# 定义 neck 函数
def neck(inputs = None):x_13, x_26, x_52 = inputsfeature = cbl_block(x_13, 512)feature = cbl(feature, filters = 256, kernel_size = (1, 1))feature = keras.layers.UpSampling2D(size = (2, 2), interpolation = "bilinear")(feature)feature = keras.layers.Concatenate(axis = -1)([feature, x_26])x_26 = cbl_block(feature, 256)feature = cbl(x_26, filters = 128, kernel_size = (1, 1))feature = keras.layers.UpSampling2D(size = (2, 2), interpolation = "bilinear")(feature)feature = keras.layers.Concatenate(axis = -1)([feature, x_52])x_52 = cbl_block(feature, 128)return x_13, x_26, x_52

四. 网络输出

这部分就更简单了, 将融合后的特征图做卷积, 变换到对应的通道数, 因为我要训练的数据集是 VOC2007, 所以输出通道数为 75 = (4 + 1 + 20) × 3. 模型结构如下

head

模型输出代码实现

输出函数如下, 输入是三个融合后的特征图

# 定义 head 函数
def head(inputs, filters):x_13, x_26, x_52 = inputsx_13 = cbl(x_13, 1024, kernel_size = (3, 3))x_13 = cbl(x_13, filters, kernel_size = (1, 1))x_26 = cbl(x_26, 512, kernel_size = (3, 3))x_26 = cbl(x_26, filters, kernel_size = (1, 1))x_52 = cbl(x_52, 256, kernel_size = (3, 3))x_52 = cbl(x_52, filters, kernel_size = (1, 1))return x_13, x_26, x_52

五. 网络模型代码实现

有了上面的相应的函数之后, 定义完整的模型就变得很简单了, 由 dark_net, neck, head 三部分构成

# 模型定义
image = keras.layers.Input(shape = (416, 416, 3), name = "input")x_13, x_26, x_52 = dark_net(inputs = image)
x_13, x_26, x_52 = neck([x_13, x_26, x_52])
x_13, x_26, x_52 = head([x_13, x_26, x_52], filters = 75)model = keras.Model(inputs = image,outputs = [x_13, x_26, x_52],name = "yolov3")
model.summary()
Model: "yolov3"
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input (InputLayer)              [(None, 416, 416, 3) 0                                            
__________________________________________________________________________________________________
conv2d (Conv2D)                 (None, 416, 416, 32) 896         input[0][0]                      
__________________________________________________________________________________________________
batch_normalization (BatchNorma (None, 416, 416, 32) 128         conv2d[0][0]                     
__________________________________________________________________________________________________
leaky_re_lu (LeakyReLU)         (None, 416, 416, 32) 0           batch_normalization[0][0]        
__________________________________________________________________________________________________
conv2d_1 (Conv2D)               (None, 208, 208, 64) 18496       leaky_re_lu[0][0]                
__________________________________________________________________________________________________
conv2d_2 (Conv2D)               (None, 208, 208, 32) 2080        conv2d_1[0][0]                   
__________________________________________________________________________________________________
batch_normalization_1 (BatchNor (None, 208, 208, 32) 128         conv2d_2[0][0]                   
__________________________________________________________________________________________________
leaky_re_lu_1 (LeakyReLU)       (None, 208, 208, 32) 0           batch_normalization_1[0][0]      
__________________________________________________________________________________________________
conv2d_3 (Conv2D)               (None, 208, 208, 64) 18496       leaky_re_lu_1[0][0]              
__________________________________________________________________________________________________
batch_normalization_2 (BatchNor (None, 208, 208, 64) 256         conv2d_3[0][0]                   
__________________________________________________________________________________________________
leaky_re_lu_2 (LeakyReLU)       (None, 208, 208, 64) 0           batch_normalization_2[0][0]      
__________________________________________________________________________________________________
add (Add)                       (None, 208, 208, 64) 0           conv2d_1[0][0]                   leaky_re_lu_2[0][0]              
__________________________________________________________________________________________________
conv2d_4 (Conv2D)               (None, 104, 104, 128 73856       add[0][0]                        
__________________________________________________________________________________________________
conv2d_5 (Conv2D)               (None, 104, 104, 64) 8256        conv2d_4[0][0]                   
__________________________________________________________________________________________________
batch_normalization_3 (BatchNor (None, 104, 104, 64) 256         conv2d_5[0][0]                   
__________________________________________________________________________________________________
leaky_re_lu_3 (LeakyReLU)       (None, 104, 104, 64) 0           batch_normalization_3[0][0]      
__________________________________________________________________________________________________
conv2d_6 (Conv2D)               (None, 104, 104, 128 73856       leaky_re_lu_3[0][0]              
__________________________________________________________________________________________________
batch_normalization_4 (BatchNor (None, 104, 104, 128 512         conv2d_6[0][0]                   
__________________________________________________________________________________________________
leaky_re_lu_4 (LeakyReLU)       (None, 104, 104, 128 0           batch_normalization_4[0][0]      
__________________________________________________________________________________________________
add_1 (Add)                     (None, 104, 104, 128 0           conv2d_4[0][0]                   leaky_re_lu_4[0][0]              
__________________________________________________________________________________________________
conv2d_7 (Conv2D)               (None, 104, 104, 64) 8256        add_1[0][0]                      
__________________________________________________________________________________________________
batch_normalization_5 (BatchNor (None, 104, 104, 64) 256         conv2d_7[0][0]                   
__________________________________________________________________________________________________
leaky_re_lu_5 (LeakyReLU)       (None, 104, 104, 64) 0           batch_normalization_5[0][0]      
__________________________________________________________________________________________________
conv2d_8 (Conv2D)               (None, 104, 104, 128 73856       leaky_re_lu_5[0][0]              
__________________________________________________________________________________________________
batch_normalization_6 (BatchNor (None, 104, 104, 128 512         conv2d_8[0][0]                   
__________________________________________________________________________________________________
leaky_re_lu_6 (LeakyReLU)       (None, 104, 104, 128 0           batch_normalization_6[0][0]      
__________________________________________________________________________________________________
add_2 (Add)                     (None, 104, 104, 128 0           conv2d_4[0][0]                   leaky_re_lu_6[0][0]              
__________________________________________________________________________________________________
conv2d_9 (Conv2D)               (None, 52, 52, 256)  295168      add_2[0][0]                      
__________________________________________________________________________________________________
conv2d_10 (Conv2D)              (None, 52, 52, 128)  32896       conv2d_9[0][0]                   
__________________________________________________________________________________________________
batch_normalization_7 (BatchNor (None, 52, 52, 128)  512         conv2d_10[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_7 (LeakyReLU)       (None, 52, 52, 128)  0           batch_normalization_7[0][0]      
__________________________________________________________________________________________________
conv2d_11 (Conv2D)              (None, 52, 52, 256)  295168      leaky_re_lu_7[0][0]              
__________________________________________________________________________________________________
batch_normalization_8 (BatchNor (None, 52, 52, 256)  1024        conv2d_11[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_8 (LeakyReLU)       (None, 52, 52, 256)  0           batch_normalization_8[0][0]      
__________________________________________________________________________________________________
add_3 (Add)                     (None, 52, 52, 256)  0           conv2d_9[0][0]                   leaky_re_lu_8[0][0]              
__________________________________________________________________________________________________
conv2d_12 (Conv2D)              (None, 52, 52, 128)  32896       add_3[0][0]                      
__________________________________________________________________________________________________
batch_normalization_9 (BatchNor (None, 52, 52, 128)  512         conv2d_12[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_9 (LeakyReLU)       (None, 52, 52, 128)  0           batch_normalization_9[0][0]      
__________________________________________________________________________________________________
conv2d_13 (Conv2D)              (None, 52, 52, 256)  295168      leaky_re_lu_9[0][0]              
__________________________________________________________________________________________________
batch_normalization_10 (BatchNo (None, 52, 52, 256)  1024        conv2d_13[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_10 (LeakyReLU)      (None, 52, 52, 256)  0           batch_normalization_10[0][0]     
__________________________________________________________________________________________________
add_4 (Add)                     (None, 52, 52, 256)  0           conv2d_9[0][0]                   leaky_re_lu_10[0][0]             
__________________________________________________________________________________________________
conv2d_14 (Conv2D)              (None, 52, 52, 128)  32896       add_4[0][0]                      
__________________________________________________________________________________________________
batch_normalization_11 (BatchNo (None, 52, 52, 128)  512         conv2d_14[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_11 (LeakyReLU)      (None, 52, 52, 128)  0           batch_normalization_11[0][0]     
__________________________________________________________________________________________________
conv2d_15 (Conv2D)              (None, 52, 52, 256)  295168      leaky_re_lu_11[0][0]             
__________________________________________________________________________________________________
batch_normalization_12 (BatchNo (None, 52, 52, 256)  1024        conv2d_15[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_12 (LeakyReLU)      (None, 52, 52, 256)  0           batch_normalization_12[0][0]     
__________________________________________________________________________________________________
add_5 (Add)                     (None, 52, 52, 256)  0           conv2d_9[0][0]                   leaky_re_lu_12[0][0]             
__________________________________________________________________________________________________
conv2d_16 (Conv2D)              (None, 52, 52, 128)  32896       add_5[0][0]                      
__________________________________________________________________________________________________
batch_normalization_13 (BatchNo (None, 52, 52, 128)  512         conv2d_16[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_13 (LeakyReLU)      (None, 52, 52, 128)  0           batch_normalization_13[0][0]     
__________________________________________________________________________________________________
conv2d_17 (Conv2D)              (None, 52, 52, 256)  295168      leaky_re_lu_13[0][0]             
__________________________________________________________________________________________________
batch_normalization_14 (BatchNo (None, 52, 52, 256)  1024        conv2d_17[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_14 (LeakyReLU)      (None, 52, 52, 256)  0           batch_normalization_14[0][0]     
__________________________________________________________________________________________________
add_6 (Add)                     (None, 52, 52, 256)  0           conv2d_9[0][0]                   leaky_re_lu_14[0][0]             
__________________________________________________________________________________________________
conv2d_18 (Conv2D)              (None, 52, 52, 128)  32896       add_6[0][0]                      
__________________________________________________________________________________________________
batch_normalization_15 (BatchNo (None, 52, 52, 128)  512         conv2d_18[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_15 (LeakyReLU)      (None, 52, 52, 128)  0           batch_normalization_15[0][0]     
__________________________________________________________________________________________________
conv2d_19 (Conv2D)              (None, 52, 52, 256)  295168      leaky_re_lu_15[0][0]             
__________________________________________________________________________________________________
batch_normalization_16 (BatchNo (None, 52, 52, 256)  1024        conv2d_19[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_16 (LeakyReLU)      (None, 52, 52, 256)  0           batch_normalization_16[0][0]     
__________________________________________________________________________________________________
add_7 (Add)                     (None, 52, 52, 256)  0           conv2d_9[0][0]                   leaky_re_lu_16[0][0]             
__________________________________________________________________________________________________
conv2d_20 (Conv2D)              (None, 52, 52, 128)  32896       add_7[0][0]                      
__________________________________________________________________________________________________
batch_normalization_17 (BatchNo (None, 52, 52, 128)  512         conv2d_20[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_17 (LeakyReLU)      (None, 52, 52, 128)  0           batch_normalization_17[0][0]     
__________________________________________________________________________________________________
conv2d_21 (Conv2D)              (None, 52, 52, 256)  295168      leaky_re_lu_17[0][0]             
__________________________________________________________________________________________________
batch_normalization_18 (BatchNo (None, 52, 52, 256)  1024        conv2d_21[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_18 (LeakyReLU)      (None, 52, 52, 256)  0           batch_normalization_18[0][0]     
__________________________________________________________________________________________________
add_8 (Add)                     (None, 52, 52, 256)  0           conv2d_9[0][0]                   leaky_re_lu_18[0][0]             
__________________________________________________________________________________________________
conv2d_22 (Conv2D)              (None, 52, 52, 128)  32896       add_8[0][0]                      
__________________________________________________________________________________________________
batch_normalization_19 (BatchNo (None, 52, 52, 128)  512         conv2d_22[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_19 (LeakyReLU)      (None, 52, 52, 128)  0           batch_normalization_19[0][0]     
__________________________________________________________________________________________________
conv2d_23 (Conv2D)              (None, 52, 52, 256)  295168      leaky_re_lu_19[0][0]             
__________________________________________________________________________________________________
batch_normalization_20 (BatchNo (None, 52, 52, 256)  1024        conv2d_23[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_20 (LeakyReLU)      (None, 52, 52, 256)  0           batch_normalization_20[0][0]     
__________________________________________________________________________________________________
add_9 (Add)                     (None, 52, 52, 256)  0           conv2d_9[0][0]                   leaky_re_lu_20[0][0]             
__________________________________________________________________________________________________
conv2d_24 (Conv2D)              (None, 52, 52, 128)  32896       add_9[0][0]                      
__________________________________________________________________________________________________
batch_normalization_21 (BatchNo (None, 52, 52, 128)  512         conv2d_24[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_21 (LeakyReLU)      (None, 52, 52, 128)  0           batch_normalization_21[0][0]     
__________________________________________________________________________________________________
conv2d_25 (Conv2D)              (None, 52, 52, 256)  295168      leaky_re_lu_21[0][0]             
__________________________________________________________________________________________________
batch_normalization_22 (BatchNo (None, 52, 52, 256)  1024        conv2d_25[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_22 (LeakyReLU)      (None, 52, 52, 256)  0           batch_normalization_22[0][0]     
__________________________________________________________________________________________________
add_10 (Add)                    (None, 52, 52, 256)  0           conv2d_9[0][0]                   leaky_re_lu_22[0][0]             
__________________________________________________________________________________________________
conv2d_26 (Conv2D)              (None, 26, 26, 512)  1180160     add_10[0][0]                     
__________________________________________________________________________________________________
conv2d_27 (Conv2D)              (None, 26, 26, 256)  131328      conv2d_26[0][0]                  
__________________________________________________________________________________________________
batch_normalization_23 (BatchNo (None, 26, 26, 256)  1024        conv2d_27[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_23 (LeakyReLU)      (None, 26, 26, 256)  0           batch_normalization_23[0][0]     
__________________________________________________________________________________________________
conv2d_28 (Conv2D)              (None, 26, 26, 512)  1180160     leaky_re_lu_23[0][0]             
__________________________________________________________________________________________________
batch_normalization_24 (BatchNo (None, 26, 26, 512)  2048        conv2d_28[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_24 (LeakyReLU)      (None, 26, 26, 512)  0           batch_normalization_24[0][0]     
__________________________________________________________________________________________________
add_11 (Add)                    (None, 26, 26, 512)  0           conv2d_26[0][0]                  leaky_re_lu_24[0][0]             
__________________________________________________________________________________________________
conv2d_29 (Conv2D)              (None, 26, 26, 256)  131328      add_11[0][0]                     
__________________________________________________________________________________________________
batch_normalization_25 (BatchNo (None, 26, 26, 256)  1024        conv2d_29[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_25 (LeakyReLU)      (None, 26, 26, 256)  0           batch_normalization_25[0][0]     
__________________________________________________________________________________________________
conv2d_30 (Conv2D)              (None, 26, 26, 512)  1180160     leaky_re_lu_25[0][0]             
__________________________________________________________________________________________________
batch_normalization_26 (BatchNo (None, 26, 26, 512)  2048        conv2d_30[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_26 (LeakyReLU)      (None, 26, 26, 512)  0           batch_normalization_26[0][0]     
__________________________________________________________________________________________________
add_12 (Add)                    (None, 26, 26, 512)  0           conv2d_26[0][0]                  leaky_re_lu_26[0][0]             
__________________________________________________________________________________________________
conv2d_31 (Conv2D)              (None, 26, 26, 256)  131328      add_12[0][0]                     
__________________________________________________________________________________________________
batch_normalization_27 (BatchNo (None, 26, 26, 256)  1024        conv2d_31[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_27 (LeakyReLU)      (None, 26, 26, 256)  0           batch_normalization_27[0][0]     
__________________________________________________________________________________________________
conv2d_32 (Conv2D)              (None, 26, 26, 512)  1180160     leaky_re_lu_27[0][0]             
__________________________________________________________________________________________________
batch_normalization_28 (BatchNo (None, 26, 26, 512)  2048        conv2d_32[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_28 (LeakyReLU)      (None, 26, 26, 512)  0           batch_normalization_28[0][0]     
__________________________________________________________________________________________________
add_13 (Add)                    (None, 26, 26, 512)  0           conv2d_26[0][0]                  leaky_re_lu_28[0][0]             
__________________________________________________________________________________________________
conv2d_33 (Conv2D)              (None, 26, 26, 256)  131328      add_13[0][0]                     
__________________________________________________________________________________________________
batch_normalization_29 (BatchNo (None, 26, 26, 256)  1024        conv2d_33[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_29 (LeakyReLU)      (None, 26, 26, 256)  0           batch_normalization_29[0][0]     
__________________________________________________________________________________________________
conv2d_34 (Conv2D)              (None, 26, 26, 512)  1180160     leaky_re_lu_29[0][0]             
__________________________________________________________________________________________________
batch_normalization_30 (BatchNo (None, 26, 26, 512)  2048        conv2d_34[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_30 (LeakyReLU)      (None, 26, 26, 512)  0           batch_normalization_30[0][0]     
__________________________________________________________________________________________________
add_14 (Add)                    (None, 26, 26, 512)  0           conv2d_26[0][0]                  leaky_re_lu_30[0][0]             
__________________________________________________________________________________________________
conv2d_35 (Conv2D)              (None, 26, 26, 256)  131328      add_14[0][0]                     
__________________________________________________________________________________________________
batch_normalization_31 (BatchNo (None, 26, 26, 256)  1024        conv2d_35[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_31 (LeakyReLU)      (None, 26, 26, 256)  0           batch_normalization_31[0][0]     
__________________________________________________________________________________________________
conv2d_36 (Conv2D)              (None, 26, 26, 512)  1180160     leaky_re_lu_31[0][0]             
__________________________________________________________________________________________________
batch_normalization_32 (BatchNo (None, 26, 26, 512)  2048        conv2d_36[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_32 (LeakyReLU)      (None, 26, 26, 512)  0           batch_normalization_32[0][0]     
__________________________________________________________________________________________________
add_15 (Add)                    (None, 26, 26, 512)  0           conv2d_26[0][0]                  leaky_re_lu_32[0][0]             
__________________________________________________________________________________________________
conv2d_37 (Conv2D)              (None, 26, 26, 256)  131328      add_15[0][0]                     
__________________________________________________________________________________________________
batch_normalization_33 (BatchNo (None, 26, 26, 256)  1024        conv2d_37[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_33 (LeakyReLU)      (None, 26, 26, 256)  0           batch_normalization_33[0][0]     
__________________________________________________________________________________________________
conv2d_38 (Conv2D)              (None, 26, 26, 512)  1180160     leaky_re_lu_33[0][0]             
__________________________________________________________________________________________________
batch_normalization_34 (BatchNo (None, 26, 26, 512)  2048        conv2d_38[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_34 (LeakyReLU)      (None, 26, 26, 512)  0           batch_normalization_34[0][0]     
__________________________________________________________________________________________________
add_16 (Add)                    (None, 26, 26, 512)  0           conv2d_26[0][0]                  leaky_re_lu_34[0][0]             
__________________________________________________________________________________________________
conv2d_39 (Conv2D)              (None, 26, 26, 256)  131328      add_16[0][0]                     
__________________________________________________________________________________________________
batch_normalization_35 (BatchNo (None, 26, 26, 256)  1024        conv2d_39[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_35 (LeakyReLU)      (None, 26, 26, 256)  0           batch_normalization_35[0][0]     
__________________________________________________________________________________________________
conv2d_40 (Conv2D)              (None, 26, 26, 512)  1180160     leaky_re_lu_35[0][0]             
__________________________________________________________________________________________________
batch_normalization_36 (BatchNo (None, 26, 26, 512)  2048        conv2d_40[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_36 (LeakyReLU)      (None, 26, 26, 512)  0           batch_normalization_36[0][0]     
__________________________________________________________________________________________________
add_17 (Add)                    (None, 26, 26, 512)  0           conv2d_26[0][0]                  leaky_re_lu_36[0][0]             
__________________________________________________________________________________________________
conv2d_41 (Conv2D)              (None, 26, 26, 256)  131328      add_17[0][0]                     
__________________________________________________________________________________________________
batch_normalization_37 (BatchNo (None, 26, 26, 256)  1024        conv2d_41[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_37 (LeakyReLU)      (None, 26, 26, 256)  0           batch_normalization_37[0][0]     
__________________________________________________________________________________________________
conv2d_42 (Conv2D)              (None, 26, 26, 512)  1180160     leaky_re_lu_37[0][0]             
__________________________________________________________________________________________________
batch_normalization_38 (BatchNo (None, 26, 26, 512)  2048        conv2d_42[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_38 (LeakyReLU)      (None, 26, 26, 512)  0           batch_normalization_38[0][0]     
__________________________________________________________________________________________________
add_18 (Add)                    (None, 26, 26, 512)  0           conv2d_26[0][0]                  leaky_re_lu_38[0][0]             
__________________________________________________________________________________________________
conv2d_43 (Conv2D)              (None, 13, 13, 1024) 4719616     add_18[0][0]                     
__________________________________________________________________________________________________
conv2d_44 (Conv2D)              (None, 13, 13, 512)  524800      conv2d_43[0][0]                  
__________________________________________________________________________________________________
batch_normalization_39 (BatchNo (None, 13, 13, 512)  2048        conv2d_44[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_39 (LeakyReLU)      (None, 13, 13, 512)  0           batch_normalization_39[0][0]     
__________________________________________________________________________________________________
conv2d_45 (Conv2D)              (None, 13, 13, 1024) 4719616     leaky_re_lu_39[0][0]             
__________________________________________________________________________________________________
batch_normalization_40 (BatchNo (None, 13, 13, 1024) 4096        conv2d_45[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_40 (LeakyReLU)      (None, 13, 13, 1024) 0           batch_normalization_40[0][0]     
__________________________________________________________________________________________________
add_19 (Add)                    (None, 13, 13, 1024) 0           conv2d_43[0][0]                  leaky_re_lu_40[0][0]             
__________________________________________________________________________________________________
conv2d_46 (Conv2D)              (None, 13, 13, 512)  524800      add_19[0][0]                     
__________________________________________________________________________________________________
batch_normalization_41 (BatchNo (None, 13, 13, 512)  2048        conv2d_46[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_41 (LeakyReLU)      (None, 13, 13, 512)  0           batch_normalization_41[0][0]     
__________________________________________________________________________________________________
conv2d_47 (Conv2D)              (None, 13, 13, 1024) 4719616     leaky_re_lu_41[0][0]             
__________________________________________________________________________________________________
batch_normalization_42 (BatchNo (None, 13, 13, 1024) 4096        conv2d_47[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_42 (LeakyReLU)      (None, 13, 13, 1024) 0           batch_normalization_42[0][0]     
__________________________________________________________________________________________________
add_20 (Add)                    (None, 13, 13, 1024) 0           conv2d_43[0][0]                  leaky_re_lu_42[0][0]             
__________________________________________________________________________________________________
conv2d_48 (Conv2D)              (None, 13, 13, 512)  524800      add_20[0][0]                     
__________________________________________________________________________________________________
batch_normalization_43 (BatchNo (None, 13, 13, 512)  2048        conv2d_48[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_43 (LeakyReLU)      (None, 13, 13, 512)  0           batch_normalization_43[0][0]     
__________________________________________________________________________________________________
conv2d_49 (Conv2D)              (None, 13, 13, 1024) 4719616     leaky_re_lu_43[0][0]             
__________________________________________________________________________________________________
batch_normalization_44 (BatchNo (None, 13, 13, 1024) 4096        conv2d_49[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_44 (LeakyReLU)      (None, 13, 13, 1024) 0           batch_normalization_44[0][0]     
__________________________________________________________________________________________________
add_21 (Add)                    (None, 13, 13, 1024) 0           conv2d_43[0][0]                  leaky_re_lu_44[0][0]             
__________________________________________________________________________________________________
conv2d_50 (Conv2D)              (None, 13, 13, 512)  524800      add_21[0][0]                     
__________________________________________________________________________________________________
batch_normalization_45 (BatchNo (None, 13, 13, 512)  2048        conv2d_50[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_45 (LeakyReLU)      (None, 13, 13, 512)  0           batch_normalization_45[0][0]     
__________________________________________________________________________________________________
conv2d_51 (Conv2D)              (None, 13, 13, 1024) 4719616     leaky_re_lu_45[0][0]             
__________________________________________________________________________________________________
batch_normalization_46 (BatchNo (None, 13, 13, 1024) 4096        conv2d_51[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_46 (LeakyReLU)      (None, 13, 13, 1024) 0           batch_normalization_46[0][0]     
__________________________________________________________________________________________________
add_22 (Add)                    (None, 13, 13, 1024) 0           conv2d_43[0][0]                  leaky_re_lu_46[0][0]             
__________________________________________________________________________________________________
conv2d_52 (Conv2D)              (None, 13, 13, 512)  524800      add_22[0][0]                     
__________________________________________________________________________________________________
batch_normalization_47 (BatchNo (None, 13, 13, 512)  2048        conv2d_52[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_47 (LeakyReLU)      (None, 13, 13, 512)  0           batch_normalization_47[0][0]     
__________________________________________________________________________________________________
conv2d_53 (Conv2D)              (None, 13, 13, 1024) 4719616     leaky_re_lu_47[0][0]             
__________________________________________________________________________________________________
batch_normalization_48 (BatchNo (None, 13, 13, 1024) 4096        conv2d_53[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_48 (LeakyReLU)      (None, 13, 13, 1024) 0           batch_normalization_48[0][0]     
__________________________________________________________________________________________________
conv2d_54 (Conv2D)              (None, 13, 13, 512)  524800      leaky_re_lu_48[0][0]             
__________________________________________________________________________________________________
batch_normalization_49 (BatchNo (None, 13, 13, 512)  2048        conv2d_54[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_49 (LeakyReLU)      (None, 13, 13, 512)  0           batch_normalization_49[0][0]     
__________________________________________________________________________________________________
conv2d_55 (Conv2D)              (None, 13, 13, 1024) 4719616     leaky_re_lu_49[0][0]             
__________________________________________________________________________________________________
batch_normalization_50 (BatchNo (None, 13, 13, 1024) 4096        conv2d_55[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_50 (LeakyReLU)      (None, 13, 13, 1024) 0           batch_normalization_50[0][0]     
__________________________________________________________________________________________________
conv2d_56 (Conv2D)              (None, 13, 13, 512)  524800      leaky_re_lu_50[0][0]             
__________________________________________________________________________________________________
batch_normalization_51 (BatchNo (None, 13, 13, 512)  2048        conv2d_56[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_51 (LeakyReLU)      (None, 13, 13, 512)  0           batch_normalization_51[0][0]     
__________________________________________________________________________________________________
conv2d_57 (Conv2D)              (None, 13, 13, 256)  131328      leaky_re_lu_51[0][0]             
__________________________________________________________________________________________________
batch_normalization_52 (BatchNo (None, 13, 13, 256)  1024        conv2d_57[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_52 (LeakyReLU)      (None, 13, 13, 256)  0           batch_normalization_52[0][0]     
__________________________________________________________________________________________________
up_sampling2d (UpSampling2D)    (None, 26, 26, 256)  0           leaky_re_lu_52[0][0]             
__________________________________________________________________________________________________
concatenate (Concatenate)       (None, 26, 26, 768)  0           up_sampling2d[0][0]              add_18[0][0]                     
__________________________________________________________________________________________________
conv2d_58 (Conv2D)              (None, 26, 26, 256)  196864      concatenate[0][0]                
__________________________________________________________________________________________________
batch_normalization_53 (BatchNo (None, 26, 26, 256)  1024        conv2d_58[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_53 (LeakyReLU)      (None, 26, 26, 256)  0           batch_normalization_53[0][0]     
__________________________________________________________________________________________________
conv2d_59 (Conv2D)              (None, 26, 26, 512)  1180160     leaky_re_lu_53[0][0]             
__________________________________________________________________________________________________
batch_normalization_54 (BatchNo (None, 26, 26, 512)  2048        conv2d_59[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_54 (LeakyReLU)      (None, 26, 26, 512)  0           batch_normalization_54[0][0]     
__________________________________________________________________________________________________
conv2d_60 (Conv2D)              (None, 26, 26, 256)  131328      leaky_re_lu_54[0][0]             
__________________________________________________________________________________________________
batch_normalization_55 (BatchNo (None, 26, 26, 256)  1024        conv2d_60[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_55 (LeakyReLU)      (None, 26, 26, 256)  0           batch_normalization_55[0][0]     
__________________________________________________________________________________________________
conv2d_61 (Conv2D)              (None, 26, 26, 512)  1180160     leaky_re_lu_55[0][0]             
__________________________________________________________________________________________________
batch_normalization_56 (BatchNo (None, 26, 26, 512)  2048        conv2d_61[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_56 (LeakyReLU)      (None, 26, 26, 512)  0           batch_normalization_56[0][0]     
__________________________________________________________________________________________________
conv2d_62 (Conv2D)              (None, 26, 26, 256)  131328      leaky_re_lu_56[0][0]             
__________________________________________________________________________________________________
batch_normalization_57 (BatchNo (None, 26, 26, 256)  1024        conv2d_62[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_57 (LeakyReLU)      (None, 26, 26, 256)  0           batch_normalization_57[0][0]     
__________________________________________________________________________________________________
conv2d_63 (Conv2D)              (None, 26, 26, 128)  32896       leaky_re_lu_57[0][0]             
__________________________________________________________________________________________________
batch_normalization_58 (BatchNo (None, 26, 26, 128)  512         conv2d_63[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_58 (LeakyReLU)      (None, 26, 26, 128)  0           batch_normalization_58[0][0]     
__________________________________________________________________________________________________
up_sampling2d_1 (UpSampling2D)  (None, 52, 52, 128)  0           leaky_re_lu_58[0][0]             
__________________________________________________________________________________________________
concatenate_1 (Concatenate)     (None, 52, 52, 384)  0           up_sampling2d_1[0][0]            add_10[0][0]                     
__________________________________________________________________________________________________
conv2d_64 (Conv2D)              (None, 52, 52, 128)  49280       concatenate_1[0][0]              
__________________________________________________________________________________________________
batch_normalization_59 (BatchNo (None, 52, 52, 128)  512         conv2d_64[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_59 (LeakyReLU)      (None, 52, 52, 128)  0           batch_normalization_59[0][0]     
__________________________________________________________________________________________________
conv2d_65 (Conv2D)              (None, 52, 52, 256)  295168      leaky_re_lu_59[0][0]             
__________________________________________________________________________________________________
batch_normalization_60 (BatchNo (None, 52, 52, 256)  1024        conv2d_65[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_60 (LeakyReLU)      (None, 52, 52, 256)  0           batch_normalization_60[0][0]     
__________________________________________________________________________________________________
conv2d_66 (Conv2D)              (None, 52, 52, 128)  32896       leaky_re_lu_60[0][0]             
__________________________________________________________________________________________________
batch_normalization_61 (BatchNo (None, 52, 52, 128)  512         conv2d_66[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_61 (LeakyReLU)      (None, 52, 52, 128)  0           batch_normalization_61[0][0]     
__________________________________________________________________________________________________
conv2d_67 (Conv2D)              (None, 52, 52, 256)  295168      leaky_re_lu_61[0][0]             
__________________________________________________________________________________________________
batch_normalization_62 (BatchNo (None, 52, 52, 256)  1024        conv2d_67[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_62 (LeakyReLU)      (None, 52, 52, 256)  0           batch_normalization_62[0][0]     
__________________________________________________________________________________________________
conv2d_68 (Conv2D)              (None, 52, 52, 128)  32896       leaky_re_lu_62[0][0]             
__________________________________________________________________________________________________
batch_normalization_63 (BatchNo (None, 52, 52, 128)  512         conv2d_68[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_63 (LeakyReLU)      (None, 52, 52, 128)  0           batch_normalization_63[0][0]     
__________________________________________________________________________________________________
conv2d_69 (Conv2D)              (None, 13, 13, 1024) 9438208     add_22[0][0]                     
__________________________________________________________________________________________________
conv2d_71 (Conv2D)              (None, 26, 26, 512)  1180160     leaky_re_lu_57[0][0]             
__________________________________________________________________________________________________
conv2d_73 (Conv2D)              (None, 52, 52, 256)  295168      leaky_re_lu_63[0][0]             
__________________________________________________________________________________________________
batch_normalization_64 (BatchNo (None, 13, 13, 1024) 4096        conv2d_69[0][0]                  
__________________________________________________________________________________________________
batch_normalization_66 (BatchNo (None, 26, 26, 512)  2048        conv2d_71[0][0]                  
__________________________________________________________________________________________________
batch_normalization_68 (BatchNo (None, 52, 52, 256)  1024        conv2d_73[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_64 (LeakyReLU)      (None, 13, 13, 1024) 0           batch_normalization_64[0][0]     
__________________________________________________________________________________________________
leaky_re_lu_66 (LeakyReLU)      (None, 26, 26, 512)  0           batch_normalization_66[0][0]     
__________________________________________________________________________________________________
leaky_re_lu_68 (LeakyReLU)      (None, 52, 52, 256)  0           batch_normalization_68[0][0]     
__________________________________________________________________________________________________
conv2d_70 (Conv2D)              (None, 13, 13, 75)   76875       leaky_re_lu_64[0][0]             
__________________________________________________________________________________________________
conv2d_72 (Conv2D)              (None, 26, 26, 75)   38475       leaky_re_lu_66[0][0]             
__________________________________________________________________________________________________
conv2d_74 (Conv2D)              (None, 52, 52, 75)   19275       leaky_re_lu_68[0][0]             
__________________________________________________________________________________________________
batch_normalization_65 (BatchNo (None, 13, 13, 75)   300         conv2d_70[0][0]                  
__________________________________________________________________________________________________
batch_normalization_67 (BatchNo (None, 26, 26, 75)   300         conv2d_72[0][0]                  
__________________________________________________________________________________________________
batch_normalization_69 (BatchNo (None, 52, 52, 75)   300         conv2d_74[0][0]                  
__________________________________________________________________________________________________
leaky_re_lu_65 (LeakyReLU)      (None, 13, 13, 75)   0           batch_normalization_65[0][0]     
__________________________________________________________________________________________________
leaky_re_lu_67 (LeakyReLU)      (None, 26, 26, 75)   0           batch_normalization_67[0][0]     
__________________________________________________________________________________________________
leaky_re_lu_69 (LeakyReLU)      (None, 52, 52, 75)   0           batch_normalization_69[0][0]     
==================================================================================================
Total params: 66,416,517
Trainable params: 66,367,427
Non-trainable params: 49,090
__________________________________________________________________________________________________

加上输入层一共 243 层

下一篇: 保姆级 Keras 实现 YOLO v3 二

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/211549.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

「 系统设计 」 为什么要做架构分层?

「 系统设计 」 为什么要做架构分层? 参考&鸣谢 3.设计模式之分层思维:为什么要做代码分层架构? 从零开始学架构(八)分层架构和设计模式 架构模式之分层架构总结 文章目录 「 系统设计 」 为什么要做架构分层&…

【考研】数据结构(更新到循环链表)

声明&#xff1a;所有代码都可以运行&#xff0c;可以直接粘贴运行&#xff08;只有库函数没有声明&#xff09; 线性表的定义和基本操作 基本操作 定义 静态&#xff1a; #include<stdio.h> #include<stdlib.h>#define MaxSize 10//静态 typedef struct{int d…

OpenStack云计算平台-计算服务

目录 一、计算服务概览 二、安装并配置控制节点 1、先决条件 2、安全并配置组件 3、完成安装 三、安装和配置计算节点 1、安全并配置组件 2、完成安装 四、验证操作 一、计算服务概览 使用OpenStack计算服务来托管和管理云计算系统。OpenStack计算服务是基础设施即服务…

【OpenCV实现图像:制作酷炫的动画效果】

文章目录 概要生成背景图添加点动画添加文本显示小结 概要 首先&#xff0c;通过导入必要的库&#xff0c;包括NumPy用于数学运算和Matplotlib库用于数据可视化。随后&#xff0c;创建图形和轴&#xff0c;初始化点的位置&#xff0c;以及编写初始化函数和更新函数。 初始化函…

在PCL视图器中使用随机生成的颜色来可视化一组匹配的点对

std::vector<Eigen::Vector2d> centroids_unknown_motion_underk; std::vector<Eigen::Vector2d> centroids_unknown_motion_k; // 进行数字填充 pcl::visualization::PCLVisualizer viewer("Centroid Visualization");int id 0;// 添加 XY 坐标系doub…

助力跨境黑五!盘点好用的五大海外代理IP,为什么跨境电商必需海外代理IP?

相信跨境电商人近日都为了2023的跨境黑五旺季奋战&#xff0c;而2024也即将来临&#xff0c;对于跨境人的考验一波接着一波&#xff0c;根据Adobe Analytics的数据&#xff0c;2022年黑色星期五的销售额创下91.2亿美元新高&#xff0c;网络星期的销售额同样达到创纪录的113亿美…

Jackson无缝替换Fastjson

目录 文章目录 一&#xff0c;Fastjson到Jackson的替换方案方案代码序列化反序列化通过key获取某种类型的值类型替换 二&#xff0c;Springboot工程中序列化的使用场景三&#xff0c;SpringMVC框架中的Http消息转换器1&#xff0c;原理&#xff1a;2&#xff0c;自定义消息转换…

【尚跑】2023泾阳半程马拉松144 PB完赛

1、赛事背景 来到泾阳&#xff0c;就来到了中国大地原点&#xff1b; 来到泾阳&#xff0c;就来到了陕西的“白菜心心”&#xff1b; 来到泾阳&#xff0c;就来到了具有2000多年的历史长河&#xff1b; 泾河水缓缓流&#xff0c;流过郑国渠&#xff1b; 泾河水缓缓流&…

关键字const的修饰(指针)

A.const修饰变量 变量是可以修改的&#xff0c;如果把变量的地址交给⼀个指针变量&#xff0c;通过指针变量的也可以修改这个变量。 但是如果我们希望⼀个变量加上⼀些限制&#xff0c;不能被修改&#xff0c;怎么做呢&#xff1f;这就是const的作⽤。 #include <stdio.h&…

拼多多商品详情数据接口(Pinduoduo.item_get)

拼多多商品详情数据接口是一种程序化的接口&#xff0c;通过这个接口&#xff0c;商家或开发者可以使用自己的编程技能&#xff0c;对拼多多平台上的商品信息进行查询、获取和更新。这个接口允许商家根据自身的需求&#xff0c;获取商品的详细信息&#xff0c;例如价格、库存、…

不可错过的10个即时通讯软件开发技巧

欢迎来到本文&#xff0c;作为即时通讯软件开发领域的专家&#xff0c;我将为您分享十个不容错过的开发技巧。无论您是新手开发者还是有经验的专业人士&#xff0c;这些技巧都将帮助您实现卓越的即时通讯软件。让我们开始吧&#xff01; 1. 选择适当的开发平台 在开始开发之前…

【UE】用样条线实现测距功能(下)

目录 效果 步骤 一、实现多次测距功能 二、通过控件蓝图来进行测距 在上一篇&#xff08;【UE】用样条线实现测距功能&#xff08;上&#xff09;&#xff09;文章基础上继续实现多次测距和清除功能。 效果 步骤 一、实现多次测距功能 打开蓝图“BP_Spline”&#xff0c…