Lightweight YOLO v5s Blueberry Detection Algorithm Based on Attention Mechanism
To achieve precise and rapid detection of blueberries in natural environments,an improved algorithm combining lightweight networks and attention mechanisms was proposed based on YOLO v5s.Firstly,the structure of the maximum object detection layer was removed at the positions of the backbone network and detection heads,thereby reducing the number of model parameters and enhancing the model's ability to detect small targets.Secondly,MHSA(Multi-head self-attention)was used to replace the C3 module before SPPF(Spatial pyramid pooling-fast),enabling the model to learn more comprehensive feature representations and enhancing its understanding of complex spatial relationships and contextual information in blueberry images.Finally,S-PSA(Sequential polarized self-attention)was added to the C3 module to better capture the contextual dependencies between adjacent regions in the feature map.The experimental results showed that the improved YOLO v5s algorithm improved the detection accuracy of mature blueberries,semi mature blueberries,and immature blueberries by 1.2,4.4,2.6 percentage points,respectively,with average accuracy increase of 2.7 percentage points and 76%reduction in model parameter count.Compared with the current mainstream lightweight object detection models,the improved model has superior performance and can provide an effective solution for the visual system of blueberry picking robots in natural environments.