Feature extraction network part (darknet53) Sketch Map :
* Conv2D What is it? ? A special convolution algorithm , There is mainly one L2 Regularization # Single convolution #
#--------------------------------------------------# @wraps(Conv2D) def
DarknetConv2D(*args, **kwargs): darknet_conv_kwargs = {'kernel_regularizer': l2(
5e-4)} #L2 Regularization helps improve performance # darknet_conv_kwargs['padding'] = 'valid' if kwargs.get(
'strides')==(2,2) else 'same' darknet_conv_kwargs.update(kwargs) return Conv2D(*
args, **darknet_conv_kwargs)
#---------------------------------------------------# # Convolution block # DarknetConv2D +
BatchNormalization( Standardization ) + LeakyReLU( Activation function )
#---------------------------------------------------# def DarknetConv2D_BN_Leaky
(*args, **kwargs): no_bias_kwargs = {'use_bias': False} no_bias_kwargs.update(
kwargs) return compose( DarknetConv2D(*args, **no_bias_kwargs),
BatchNormalization(), LeakyReLU(alpha=0.1))
#---------------------------------------------------# # Convolution block # DarknetConv2D +
BatchNormalization ( Standardization )+ LeakyReLU( Activation function )
#---------------------------------------------------# def resblock_body(x,
num_filters, num_blocks): # Residual structure x = ZeroPadding2D(((1,0),(1,0)))(x) x =
DarknetConv2D_BN_Leaky(num_filters, (3,3), strides=(2,2))(x) # The step size is 2, So it's half the length and half the width
for i in range(num_blocks): # Repeat times y = DarknetConv2D_BN_Leaky(num_filters//2, (1,
1))(x) # The main part for the first time 1*1 convolution , Compress the number of channels by half y = DarknetConv2D_BN_Leaky(num_filters, (3,3))(y
) # The second time of the main part 3*3 convolution , Expand the number of channels back x = Add()([x,y]) # Connect the residuals to the main body , The number of runs is the number of repetitions return x
#---------------------------------------------------# # darknet53 The main part of
#---------------------------------------------------# def darknet_body(x):
#416,416,3 x = DarknetConv2D_BN_Leaky(32, (3,3))(x) # Length and width unchanged , The number of channels becomes 32, Corresponding diagram Step1#
#208, 208, 64 x = resblock_body(x, 64, 1) #( Input feature layer , Number of output channels , Repeat times ) concrete r , b For explanation, see the definition section above
#104 ,104, 128 x = resblock_body(x, 128, 2) #52, 52, 256 x = resblock_body(x,
256, 8) feat1 = x #26, 26, 512 x = resblock_body(x, 512, 8) feat2 = x #13 , 13,
1024 x = resblock_body(x, 1024, 4) feat3 = x return feat1,feat2,feat3
#---------------------------------------------------#
* Residual Block
: Residual convolution block , Compared with ordinary convolution , There will be one more residual line , The feature layer of the previous layer can be mapped directly to the feature layer of the next layer without convolution , The function is helpful for training and feature extraction . The last three feature layers can be reserved for entry YOLOV3 Feature processing network , It turns out to be a prediction
Technology