李小占, 马本学, 喻国威, 陈金成, 李玉洁, 李聪. 基于深度学习与图像处理的哈密瓜表面缺陷检测[J]. 农业工程学报, 2021, 37(1): 223-232. DOI: 10.11975/j.issn.1002-6819.2021.01.027
    引用本文: 李小占, 马本学, 喻国威, 陈金成, 李玉洁, 李聪. 基于深度学习与图像处理的哈密瓜表面缺陷检测[J]. 农业工程学报, 2021, 37(1): 223-232. DOI: 10.11975/j.issn.1002-6819.2021.01.027
    Li Xiaozhan, Ma Benxue, Yu Guowei, Chen Jincheng, Li Yujie, Li Cong. Surface defect detection of Hami melon using deep learning and image processing[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2021, 37(1): 223-232. DOI: 10.11975/j.issn.1002-6819.2021.01.027
    Citation: Li Xiaozhan, Ma Benxue, Yu Guowei, Chen Jincheng, Li Yujie, Li Cong. Surface defect detection of Hami melon using deep learning and image processing[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2021, 37(1): 223-232. DOI: 10.11975/j.issn.1002-6819.2021.01.027

    基于深度学习与图像处理的哈密瓜表面缺陷检测

    Surface defect detection of Hami melon using deep learning and image processing

    • 摘要: 针对传统人工检测哈密瓜表面缺陷效率低等问题,提出利用卷积神经网络(Convolutional Neural Networks, CNN)对哈密瓜表面缺陷进行快速检测。对原始图像进行主成分分析(Principal Components Analysis,PCA)、奇异值分解(Singular Value Decomposition, SVD)和二值化等预处理操作,通过数据扩充得到正常、霉菌、晒伤和裂纹的哈密瓜图像各2 500幅。构建一种改进的类似VGG卷积神经网络模型,将预处理后的图像输入模型,并使用随机梯度下降(Stochastic Gradient Descent, SGD)优化器进行算法优化,为探究CNN模型的特征提取原理,将改进的类似VGG模型每层卷积的特征进行可视化,最后利用开发的哈密瓜表面缺陷检测软件对模型进行试验验证。研究结果表明:图像预处理算法提高了模型的鲁棒性和泛化能力,改进的类似VGG模型优于AlexNet和VGG-16模型,其训练集和测试集准确率分别为100.00%和97.14%;对比预处理前后4类哈密瓜卷积特征可视化结果表明,随着卷积层层数的增加,哈密瓜表面缺陷特征越来越明显,图像预处理后卷积层特征提取效果优于原始图像提取效果。软件测试结果表明:静态下哈密瓜缺陷检测速率达到0.7 s/幅,识别准确率达到93.50%。研究结果可为哈密瓜表面缺陷在线检测技术提供理论依据和技术参考。

       

      Abstract: An improved Convolutional Neural Network (CNN) was proposed to solve the time-consuming and inefficient detection for the surface defect on the Hami melon in recent years. The Hami melons were purchased from 103 Regiment, 6th Agricultural Division, the Xinjiang Production and Construction Corps, China. A total of 200 images of normal Hami melons were taken by a camera in a black box. 100 images of Hami melons were collected with the various surface defects, such as mildew, sunburn and crack. Since it is difficult to collect samples with three defect types, the data enhancement technique was used to expand the dataset. A total of 10 000 sample images were obtained, and then divided into a training and test dataset, according to the proportion of 4:1. A VGG-like model was improved by adding a convolutional layer and a pooling layer at the beginning. As such, the improved VGG-like model included three convolutional layers, three max-pooling layers, a flatten layer, and two fully-connected layers. The softmax classifier was used in the last fully-connected layer. The Rectified Linear Unit (ReLU) function was chosen as the activation function. The Stochastic Gradient Descent (SGD) was chosen as the optimizer. The improved VGG-like model was used to identify four-class defect samples. The optimal hyperparameters in the CNN models were determined via the performance under the different learning rates and epochs. In all established CNN models, the test data showed that the AlexNet model outperformed other VGG-16 models, with the learning rate of 0.001 and the epochs of 500. Moreover, the AlexNet model can achieve the best performance with the accuracy of 99.69% and 96.62% in the training and test dataset, respectively. Three image processing techniques were compared to evaluate the preprocessing impact, including the Principal Components Analysis (PCA), Singular Value Decomposition (SVD), and binarization. The results indicated that the preprocessing provided a better detection performance on the various surface features of Hami melon in image preprocessing. The improved VGG-like model was the optimal to detect four-class defect on the Hami melon surface, indicating the learning rate of 0.001 and the epochs of 500. The prediction accuracy of improved VGG-like model in test set reached 97.14%. A visualization technique was used to analyze the features of convolutional layers, particularly on feature extraction in a CNN model. The visualization results showed that the defect features became more and more obvious with the increase of the convolutional layers. The defect features were the clearest in the captured images by the last convolutional layer. In addition, the convolutional features with the input as the preprocessing images were clearer than before. Finally, the improved VGG-like model was verified by the developed software on the plateform of PyQt5. The developed software functions included Open Camera, Read Image, Image Processing (Gray, PCA, SVD and Binarization), and Image Identification. The detection time of a single image was less than 0.7 s. In each type, 50 images were captured under the same environment. A total of 200 test images were collected. The test results showed that none of normal samples was predicted as defect samples. Only 8 crack Hami melons was incorrectly identified, due mainly to the unobvious feature. The average prediction accuracy of 200 samples was 93.5%. The improved VGG-like model with the preprocessing can be expected to apply for the detection of defects on the Hami melon surface, and other on-line nondestructive detection in the future.

       

    /

    返回文章
    返回