Abstract:The existing traditional semantic segmentation methods of crop diseases have low accuracy and poor robustness. In order to address these problems, an improved UNet semantic segmentation model of strawberry diseases based on an attention mechanism is proposed. Firstly, a CNN-Transformer hybrid structure is added to the encoder to improve the feature extraction ability of global information and local detail information. Secondly, the traditional up-sampling is replaced by a dual up-sample module in the decoder to enhance the feature extraction ability and segmentation accuracy. Thirdly, the hard-swish activation function is employed to replace the ReLU activation function, and the smoother curve helps to improve generalization and nonlinear feature extraction ability and prevent gradient disappearance. Finally, the segmentation accuracy is further improved by using a combined cross-entropy Dice loss function to strengthen the model’s constraints on the segmentation results. A dataset consisting of 2 500 images of seven strawberry diseases is used to segment strawberry diseases in a complex background. The semantic segmentation pixel accuracy reaches 92.56%, and the average cross-merge ratio reaches 84.97%. The experimental results show that the improved UNet in this study can achieve better segmentation results and outperform most segmentation models in the semantic segmentation of strawberry diseases.