## 2 Materials and Methods
### Three-Channel Attention Mechanism  
In HFFN, although YOLO-chili can effectively enhance the detection ability of the model for different layers of targets, it also brings a large amount of environmental noise to the model's detection, which makes the final detection results receive interference. Therefore, to address the above problems, this paper proposes a three-channel attention mechanism model. Because the three-channel attention mechanism consists of CBAM attention mechanism and CA attention mechanism, it is abbreviated as CBCA module. In this paper, it is added before the feature processing layer of the model and combined with the model, so that the feature information processed by the model is the feature processed by the attention mechanism. In this way, the features processed by the model are enhanced and effective features, and the three-channel attention mechanism module also suppresses the information interference from the complex background in the process, which improves the model performance. The three-channel attention mechanism module, shown in Figure 4, includes a spatial attention module, a channel attention module, and a coordinate attention module, and is a product of the linkage between the three. The channel attention mechanism is an adaptive spatially selective attention module for dynamically learning and adjusting the importance of different channels (feature maps). It helps the model to effectively interact and transfer information between different channels of the feature map to enhance the model's representation of the input data. It mainly realizes the deep information representation of pepper targets in images by weighting the convolutional features of the channels. In channel attention, the input feature map F (input) is firstly subjected to global max pooling and global average pooling based on width and height, respectively, to obtain two 1 \(\times\) 1 \(\times\) C feature maps. Then, they are  
Figure 4: Diagram of the Three-Channel Attention Mechanism Structure. Figure 3: HFFN Structure. fed into a two-layer neural network (MLP) with the number of neurons in the first layer as C/r (r is the reduction rate) and the activation function as Relu, and the number of neurons in the second layer as C. This two-layer neural network is shared. And then, the MLP output features are subjected to element-wise based sum operation and then sigmoid activation operation to generate the final channel attention feature. Finally, the element-wise multiplication operation is performed between the channel attention feature and the input feature map F to generate the input features required by the Spatial attention module. See Figure 5 for details. The spatial attention mechanism is used to dynamically learn and adjust the importance of different spatial locations. It helps the model to effectively interact and transfer information between different spatial locations of the feature map to enhance the model's representation of the input data. Specifically, spatial attention is a channel compression technique that performs average pooling and maximum pooling in channel dimensions, respectively. In spatial attention, the feature map output from the Channel attention module is used as the input feature map of this module. Firstly, we perform a channel-based global max pooling and global average pooling to obtain two H \(\times\) W \(\times\) 1 feature maps, and then we perform a concat operation (channel splicing) based on the two feature maps. Then we perform a 7 \(\times\) 7 convolution (7 \(\times\) 7 is better than 3 \(\times\) 3) to reduce the dimensionality to 1 channel, i.e., H \(\times\) W \(\times\) 1. Then we generate a spatial attention feature, through sigmoid, and finally, we multiply the feature with the input feature of the module to obtain the final generated feature. The detailed structure is shown in Figure 6.  
Figure 5: Channel Attention Module. Figure 6: Spatial Attention Module.