2.4.2. Introduction of Attention Mechanism

The attention mechanism can make the network pay more attention to the bud target. It was found that the attention mechanism modules, such as SE Block, ECA Block, CBAM Block and CA Block, play a significant role in improving the model recognition effect. For the input features, CBAM module first learns the weight information of each channel through a shared multilayer perceptron (MLP) and sigmoid function, and then, through a hollow convolution [20] with convolution kernel of 3 × 3 and expansion coefficient of 2 and sigmoid function, learns the weight information of each point in the space. SE Block obtains the channel weight information after passing through the full connection layer twice and sigmoid function. The ECA block changes the two fully connected layers into one-dimensional convolution, and obtains the channel weight information after passing the sigmoid function, which has a good ability to obtain cross-channel information. The CA block divides channel attention into two 1-dimensional feature coding processes, which aggregates features along two spatial directions, respectively. In this way, remote dependencies can be captured along one spatial direction. At the same time, accurate location information can be retained along the other spatial direction, and then, the generated feature map was encoded into a pair of direction-aware and position-sensitive attention maps, which can be applied complementary to the input feature map to enhance the representation of the object of attention. The schematic diagram of the network structure of the four modules is shown in Figure 8.

**Figure 8.** Attention mechanism module.

In order to better adapt to the complex scene of the tea garden, four attention mechanism modules were added to the front and back positions of the enhanced feature extraction network, named Attention Block1 (AB1) and Attention Block2 (AB2), as shown in Figure 7. In the experiment, we compared the recognition effects of adding four attention modules in the above position.
