Abstract:In recent years, fruit freshness detection based on machine vision and deep learning has become one of the mainstream methods. This study explores the application of deep learning technologies, particularly convolutional neural networks(CNNs), in feature extraction for fruit freshness identification. This paper introduces the CBAM (Convolutional block attention module) attention mechanism module into the ResNet34 (34-layer residual network) backbone network to achieve fruit freshness detection. Class activation mapping(CAM) techniques are employed to visualize the heatmaps of pixels that reflect the critical features in the images. On a public fruit dataset, the classification accuracy of the ResNet34 network before and after introducing the attention mechanism is 96.80% and 99.71%, respectively. The CAM heatmaps show that the attention model can more accurately capture the regions of interest in the fruit images, indicating that the proposed model improves the feature extraction capability of deep learning, not only enhancing the model's generalization ability but also increasing its interpretability.