# Improved Lightweight YOLOv4 Foreign Object Detection Method for Conveyor Belts Combined with CBAM
## 2 Relevant Network Models
### GhostNet Module  
Deep neural network models have been widely used in machine vision tasks, such as image classification and object detection, with great success. However, the storage and computation of neural network models on embedded devices is still a great challenge due to the limitation of storage space and power consumption. Therefore, utilizing an efficient and high-performance lightweight neural network is the key to solving this problem. The core of lightweight networks is to lighten the network in terms of size and speed while maintaining as much accuracy as possible. The SqueezeNet [35] family is a relatively early and classic lightweight network. SqueezeNet uses the Fire module for parameter compression. MobileNetV1 [36] builds lightweight networks using deeply separable convolutions. MobileNetV2 [37] proposes an innovative inverted residual with a linear bottleneck unit, which improves the overall network accuracy and speed although the number of layers often increases. MobileNetV3 [38], on the other hand, combines AutoML techniques with manual fine-tuning for lighter-weight network construction. Based on the analysis of the experimental results, we finally chose GhostNet lightweight network.  
The GhostNet module network [39; 40; 41; 42] structure is shown in Figure 2, which uses the principle of linear transformation first to obtain part of the base feature layer using the standard convolution calculation. Then, it obtains the Ghost feature layer using the GhostNet module, stacks the base feature layer with the Ghost feature layer, and outputs it. This structure significantly reduces the number of parameters and improves computational speed.  
Suppose that the input feature layer size was \(h_{1}\times w_{1}\times n\), and the size of the output feature layer was \(h_{2}\times w_{2}\times m\), the size of the convolution kernel was \(k\times k\), the computation of normal convolution was \(L_{1}\), and the computation volume of the Ghost feature layer convolution was \(L_{2}\). The first convolution kernel of the Ghost feat  
Figure 1: YOLOv4 network structure.  
Figure 2: GhostNet module network structure.  
the second convolution kernel was \(k_{2}\). The number of base feature layers converted into redundant feature layers was \(s\).  
The computational effort of ordinary convolution \(L_{1}\) would be,  
\[L_{1}=h_{2}\times w_{2}\times m\times n\times k\times k \tag{1}\]  
The computational volume of Ghost feature layer convolution \(L_{2}\) would be,  
\[L_{2}=h_{2}\times w_{2}\times\frac{m}{s}\times\text{n}\times k_{1}\times k_{2} +(\text{s}-1)\times h_{2}\times w_{2}\times\frac{m}{s}\times\text{n}\times k_{ 2}\times k_{2} \tag{2}\]  
From Equations (1) and (2), the ratio of the calculated quantities could be deduced,  
\[\frac{L_{1}}{L_{2}}=\frac{h_{2}\times w_{2}\times m\times n\times k\times k}{h_ {2}\times w_{2}\times\frac{m}{s}\times\text{n}\times k_{1}\times k_{2}+\text{ s}-1\times h_{2}\times w_{2}\times\frac{m}{s}\times\text{n}\times k_{2}\times k_{2}} \approx S \tag{3}\]  
From Equation (3), we could obtain the simplified computation using the GhostNet module for feature extraction, which is about 1/s of that when using conventional convolution, greatly improving the operation speed and enhancing the detection speed of the whole model.  
Ghost modules are stacked by bottleneck structures (GhostBottlenecks), which can be divided into two categories as step 1 and step 2, which are as shown in Figure 3. There were two Ghost modules in the bottleneck structure. The first Ghost module was used to increase the number of channels, and the second Ghost module decreased the number of channels to match the channels of the shortcut branch. This structure did not compress the height and width of the incoming feature layer but only deepened the depth of the network. When the step size was 2, a deep convolutional layer with step size 2 was added between the two Ghost modules to adjust and match the number of channels between the input and output.