# Research on Improved Lightweight YOLOv5s for Multi-Scale Ship Target Detection
## 3 Data and Methods
### The Improved Yolov5_ESGW Model
#### 3.3.1 Lightweight  
In order to meet the application of image recognition models on platforms with limited computing resources, existing image recognition models need to be lightweight and deployed. Therefore, in this research, the lightweight EfficientNetV2 [22] network is utilized to improve the backbone network of yolov5s based on the Yolov5s model. As shown in Figure 3, the unique feature of EfficientNetV2 is that it further optimizes the inference speed and training speed by integrating perceptual neural architecture search and scaling strategies. The Fused-MBConv module is introduced into its model, bringing a richer search space to EfficientNetV2. Compared with EfficientNetV1, EfficientNetV2 achieves significant improvements in training speed, achieving up to 6.8 times shorter training time. This means that EfficientNetV2 can utilize computing resources in a more efficient manner, accelerate training, and be more suitable for various application scenarios with limited computing resources.  
Figure 2: Improved model Yolov5s_ESGW (the lightweight Fused-MBConv and MBConv modules were used to improve the backbone network of the model; the C3 Ghost and GhostConv modules were used to improve the neck network; and the Shuffle Attention mechanism was integrated into the model).  
The MBConv block in EfficientNetV2 achieves a model with better detection performance and fewer parameters by using an inverted residual structure and depth-separable convolution. As shown in Figure 3a, MBConv uses 1 \(\times\) 1-dimensional expansion convolution to expand the number of input channels, which helps extract higher-level feature information and gives the network rich expressive capabilities. In order to reduce the amount of calculation, the MBConv module uses depthwise separable convolution and integrates SENet [23], which improves the computational efficiency of the model while ensuring the model detection performance. To improve the computational efficiency and performance of the model, EfficientNetV2 introduces a new module, Fused-MBConv. As shown in Figure 3b, it mainly merges Conv 1 \(\times\) 1 and DWconv in the MBConv module into a 3 \(\times\) 3 convolution. This study draws on the ideas of MBConv and Fused-MBConv modules to reconstruct the feature extraction network of the baseline model, optimize the depth and width of the backbone network, and fully compress the complexity and computational cost of the model. Experiments show that after using the Fused-MBConv module, the number of parameters of the model will increase to a certain extent. However, it avoids memory reading and writing at each stage, thereby reducing the computational burden and making the model's computational efficiency significantly improved compared to before.  
In order to further compress the detection model, the lightweight Ghostnet network is used to improve the neck network of the Yolov5s model. As shown in Figure 4, first, the GhostConv module is used to replace the Conv module in the neck network of the original model. Compared with the Conv module, the GhostConv module mainly uses ordinary convolution operations and grouped convolution to obtain relevant feature maps, which can significantly reduce the number of parameters and calculation costs of the model. Then, the GhostBottleneck module integrated into the GhostConv module is used to replace the bottleneck in the C3 module and obtain a new C3 Ghost module. Through such improvements, feature maps similar to the original model can be obtained at a lower cost, achieving a trade-off between model detection accuracy and complexity.  
Figure 3: (a) MBConv module; (b) Fused-MBConv module.