# A Pineapple Target Detection Method in a Field Environment Based on Improved YOLOv7
## 1 Introduction
[PERSON] [26] improved the YOLOX network, replacing the original backbone with ShufflenetV2 and adding a convolutional block attention module (CBAM). [PERSON] [27] successfully proposed a lightweight target detection network by applying leanNet, which solves the problems of similar color and background, fruit overlap, and branch and leaf blocking. In order to achieve the aim of the real-time detection of apple, [PERSON] [28] improved the YOLOv5 network model. The method improved the BottleneckCSP module into the BottleneckCSP-2 module, adding the squeeze and excitation (SE) module and modifying the initial settings of the anchor box size. [PERSON] [29] proposed a neural network model, DasNet-V2, which could realize both detection and segmentation functions. [PERSON] et al. [30] proposed an improved YOLOv5 algorithm to detect the dense citrus in the orchard. By adding the attention mechanism coordinate attention (CA) and applying the bidirectional feature pyramid network (BiFPN) structure, the efficient detection of citrus was realized. [PERSON] et al. [31] provided a pineapple detection method based on SSD, which used MobileNet as the backbone to optimize the detection speed, but the model is limited only to the detection of a single mature pineapple and cannot distinguish the maturity of the pineapple. This method does not directly test the detection performance of pineapple in the field. [PERSON] et al. [32] used the improved YOLOv3 model to detect pineapple and verified its improved effectiveness under inclusion conditions, but the model can only distinguish ripe and unripe pineapple. In addition, this paper did not analyze the detection performance of the dense multiple pineapple scene. The performances in some related works are shown in Table 1.  
Although the above researchers have made certain research achievements in the field of fruit detection by applying advanced target detection algorithms, most of the research directions focus on improving the detection performance of fruits with single maturity and less on improving the detection performance of fruits with different maturities in a natural environment. There are few studies on the target detection of pineapple in a natural environment in the field. Therefore, this paper presents an efficient and stable pineapple target detection algorithm based on the improved YOLOv7, which provides technical support for the efficient automatic pineapple picking robot in a complex field environment. The main contributions of this paper are as follows:  
1. A lightweight and efficient pineapple target-detection model was designed by introducing the attention mechanism SimAM for the original YOLOv7, modifying the the max-pooling convolution (MPConv) structure and replacing the non-maximum suppression (NMS) algorithm with the soft-NMS algorithm. The detection model takes into account the detection accuracy and speed on the premise that it can distinguish the three maturities of pineapples. 2. Through comparative tests, the differences in the detection performance between the model proposed in this paper and other advanced models were verified, and it is proved that the model proposed in this paper is more suitable for the detection of pineapples in a field environment. At the same time, the classification performances of different models for pineapple with different maturities and the detection performances in different field environments were explored.