APP下载

采用机器视觉与自适应卷积神经网络检测花生仁品质

2020-04-10张思雨张秋菊

农业工程学报 2020年4期
关键词:训练样本花生卷积

张思雨,张秋菊,李 可

·农产品加工工程·

采用机器视觉与自适应卷积神经网络检测花生仁品质

张思雨,张秋菊,李 可※

(江南大学机械工程学院,无锡 214122)

该文以花生质量自动化检测为研究目标,提出了一种基于机器视觉与自适应卷积神经网络的花生质量检测方法。构建花生图像数据库用于识别花生的常见缺陷,包括霉变、破碎、干瘪等;然后建立卷积神经网络自动提取花生图像特征。为避免深层网络训练时间过长,分别将二次函数与正态分布模型引入网络损失中,同时从网络的损失与权值2方面提出自适应学习率,并分别结合梯度下降与梯度上升法更新网络。为提高模型的泛化能力,引进迁移学习算法,分别在网络的特征层与分类层后加入领域自适应,实现跨领域与跨任务的检测。试验结果表明,该方法对花生常见缺陷的平均识别率达99.7%,与传统的深度网络相比实现了更高的收敛速度与识别精度。

农产品;机器视觉;无损检测;自适应卷积神经网络;自适应学习率;迁移学习;领域自适应

0 引 言

花生是中国产量丰富、食用广泛的一种坚果,同时也是中国为数不多的具有强劲国际竞争力的出口创汇农产品[1]。收获的花生在存储、运输的过程中由于湿度,温度及其他不可抗力因素的影响,极易发生破碎、干瘪、以及霉变等现象,这些缺陷不仅会影响花生的外观与品质,导致价格与销量下降,甚至会因花生的霉变而产生致癌物质黄曲霉毒素,严重威胁到人们的健康,因此应严格保证花生的质量[2-3]。机器视觉技术提供了一种非接触的自动检测方法,具有实时、高效、客观等优点,且价格相对低廉,已被广泛应用于食品质量检测领域[4]。缺陷特征提取是决定检测精度的关键,也是检测的难点之一,传统的图像识别技术采用手动提取特征的方法,在麦粒、玉米以及花生等食品的质量检测中得到了应用,并取得了令人满意的效果[5-9]。然而手动提取特征依赖于大量的先验知识,需要通过试验不断的对提取的特征进行择优,过程繁琐且易受外界因素影响,很难得到准确、稳定的缺陷特征。

卷积神经网络(convolutional neural network,CNN)是一种具有深层网络结构的模型,与需要手动提取特征的浅层模型相比,可以自动提取最具有代表性的图像特征[10-11]。周云成等在VGGNet的基础上优选出一种8层CNN模型用于番茄的特征提取与表达,从而实现同时对不同成熟度的果和不同花龄的花的有效识别[12];王璨等提出了基于CNN提取多尺度分层特征的方法,用于识别玉米苗与杂草[13]。CNN不仅具有自学习能力和自动提取特征的优点,还具有权值共享以及输入图像与网络结构结合良好等优势[14]。基于这些优越的特性,CNN被成功应用于体积较小的颗粒农产品的质量检测中。赵志衡等提出基于CNN的花生籽粒完整性识别算法,并采用L2范数正则化、指数衰减法和滑动平均模型的方法优化CNN,实现花生破损籽粒的分类[15-16];杜剑等构建了一个6层CNN用于提取夏威夷果的光谱特征,并采用激活函数ReLU与Dropout法预防过拟合现象,实现三种不同品质的夏威夷果的分类[17];Qiu等应用CNN识别4个品种的水稻种子,并在不同训练样本量的条件下与最近邻KNN以及支持向量机SVM方法进行对比,CNN实现了较高的识别精度[18];Han等采用CNN识别带有黄曲霉毒素的花生样品,通过与传统识别模型进行比较得到了更好的性能[19];Przybyło等应用CNN学习橡子的局部特征与全局特征,用于识别健康与变质的橡子[20]。CNN较传统的神经网络和浅层模型存在很多优势,但在实际应用中仍存在许多待解决的问题。当在特定环境下训练好的CNN模型在新环境下运行时,领域的改变会导致模型性能的下降。如果新环境中有足够的带标签的图像重新训练模型,CNN的性能也许会得到提升,但是在新环境中采集大量带标签的图像是昂贵的;即使存在这样的图像集,训练一个性能良好的网络模型也需要花费很长的时间[21]。对此,Zhang等提出CNN结构自适应法,根据不同的样本自适应调整模型结构,有效的减少了模型的训练时间与误差[22];储珺等提出自适应调节学习率和样本训练方式的CNN模型,解决了小样本数据过拟合的问题[23];Abdeljaber等分别对学习率与网络结构进行改进以提高CNN训练与计算的效率,但上述方法依然存在网络泛化能力弱,学习率等关键参数设置困难等问题[24-25]。

迁移学习不仅可以将典型模型中训练好的参数直接迁移到自己的模型中,解决计算量与训练时间的问题,还可以通过域自适应学习(domain adaptation learning,DAL)解决训练样本不足与模型过期的问题[26]。Liang等将在ImageNet数据集上训练好的CNN权重迁移到自己的网络中进行进一步学习[27-28];Paaßen等将迁移学习应用在仿生手领域,使受干扰的数据再次适用于原始模型[29];Salaken等通过域自适应学习将源域信息转换为适合目标域的信息,以实现跨领域的识别[30]。

本文提出一种自适应卷积神经网络模型(domain adaptation learning-adaptive convolutional neural network,DAL-ACNN),在AlexNet[31]的基础上引入自适应学习率,根据网络损失与权值的变化自动调整学习率的大小,以适应模型的训练过程,避免因不合适的学习率引起过慢的收敛速度;同时引入域自适应学习对测试数据与训练数据进行统计分析与变换,提高模型的泛化性,实现跨域和跨任务的检测,并通过试验验证了该模型的识别精度与收敛速度。

1 构建花生图像数据库

搭建图像采集系统如图1,系统采用彩色工业相机获取花生的RGB图像,相机型号为MER-1520-13U3C,1 500万像素,4 608×3 288分辨率,USB3.0接口;镜头选用KOWA LM12JC1MS千万像素定焦镜头,焦距为12 mm,光源选用LED白色光源,所有图像均以BMP格式存储。

1.相机 2.镜头 3.LED照明 4.载物台 5.花生样品 6.图像监视器

本文主要针对花生中存在的典型缺陷进行检测,其中包括霉变、破碎、干瘪。图像采集背景为黑色,采集时随机放置花生样本。通过灰度变换、阈值分割、腐蚀与膨胀等图像处理方法检测花生轮廓,沿轮廓大小向外扩充40个像素对图像进行分割,图2为分割得到的单个花生图像。建立花生图像数据库,共4 000张,其中包括正常粒1 000张,霉变粒1 000张,破碎粒1 000张,干瘪粒1 000张。

图2 花生分割图

2 自适应卷积神经网络的构建

CNN是一种可以实现自动特征提取的模型,特征表示[10-11,14]如下

注:表示基于损失变化的自适应学习率,表示基于权值变化的自适应学习率;表示域分类损失,表示边缘分布自适应损失,表示条件分布自适应损失,表示分类损失。

2.1 自适应学习率

学习率直接关系到模型的收敛速度和识别精度[23-24]。在初始训练阶段应选择较大的学习率,避免模型陷入局部最优解,保证收敛速度。在训练后期网络损失下降缓慢,且在某一定值附近波动,此时模型应选择较小的学习率避免震荡,使网络损失继续下降[32]。本文将二次函数与网络损失相结合如式(4),其中网络损失作为自变量。当=0时存在理想的极小值,此时网络性能达到最佳。

由(6)可知,网络训练初期损失较大,学习率较大,可加速网络收敛,跳出局部极小值。随着迭代次数的增加,网络损失逐渐减小,学习率减小,可避免网络震荡。但在训练后期损失趋近于0,学习率同样趋近于0。为避免学习率为0,提出如下变换方法

2.2 领域自适应

图3中在Softmax层后加入条件分布自适应,通过将源域中学习到的类别分布信息迁移到目标域中,实现跨任务的识别。类别分布是指领域中任一类别与各类别相似的概率,可通过Stmofax层得到每个样本与各类别相似的概率,并对类别中所有样本对应的概率求均值,即可得到类别与每一个类别相似的概率。源域的类别分布如式(11)

2.3 DAL-ACNN参数更新

3 试验结果与分析

3.1 验证DAL-ACNN

本文将第1节建立的图像数据库作为源域,同时选择光照不均匀的白色背景作为目标域,并通过相同的图像处理方法建立目标域数据库。目标域数据库共2 000张图像,其中包括正常粒500张,霉变粒500张,破损粒500张,干瘪粒500张。图4为两领域数据库的部分图像。

图4 部分源域与目标域图像

使用源域训练好的参数初始化DAL-ACNN模型,将目标域数据按照7∶3的比例分为训练集与测试集,并将源域数据与目标域数据共同作为输入数据训练DAL-ACNN模型。通过自适应学习率微调参数更新过程中的步长,并通过反向传播不断优化域自适应损失与分类损失。迭代500次后得到训练好的DAL-ACNN模型,图5为具体算法流程。

本文首先使用目标域的数据训练传统的CNN模型,得到花生质量检测的平均准确率为97.4%,并从图6a中可以看出传统CNN模型的识别错误率较高,模型精度仍然存在上升空间;然后使用源域数据辅助目标域数据训练DAL-ACNN模型,该模型的平均准确率高达99.7%。虽然由于部分特征参数的重叠,无法保证100%的识别精度,但从图6b中可以看出,与传统的CNN模型相比DAL-ACNN模型大大提高了花生的检测精度。表1详细的列出了DAL-ACNN模型对花生各类缺陷的检测结果,其中对于花生霉变粒与破碎粒的识别准确率均达到了100%,而干瘪粒与破碎粒中均仅有一个样本被错误的识别,错误率仅占0.7%。

图5 DAL-ACNN算法

图6 花生检测结果

表1 DAL-ACNN模型的花生检测结果

3.2 DAL-ACNN与固定学习率比较

选择不同数量级的初始学习率验证本文提出的自适应学习率,图7和图8分别为DAL-ACNN与CNN在初始学习率为0.001与0.000 1时的收敛性能。在初始学习率0.001的条件下,虽然CNN产生了较好的收敛性能,但仍低于DAL-ACNN的收敛性能。当选取更小的初始学习率0.000 1时,CNN的收敛性能明显下降,在迭代到100次时模型开始陷入局部极小值,并且很长一段时间都没有跳出,导致模型的最终精度比初始学习率为0.001时的精度下降了10%。而改变初始学习率对DAL-ACNN的收敛性能影响较小,在不同数量级的初始学习率下,DAL-ACNN均获得了较好的收敛性能,并且在初始学习率0.001与0.000 1条件下训练的DAL-ACNN的最终精度仅有2%的差距。

图7 DAL-ACNN 与CNN在学习率0.001时的收敛

图8 DAL-ACNN 与CNN在学习率0.000 1时的收敛

3.3 不同样本量下DAL-ACNN与CNN的比较

为证明DAL-ACNN在小样本条件下的优越性,减少训练样本与测试样本,分别比较DAL-ACNN与CNN在不同样本量下的训练性能与测试性能。本次试验中,DAL-ACNN与CNN的初始学习率均为0.001,目标域的训练样本数量分别选择1 000、500以及200,源域的样本量保持不变。图9展示了DAL-ACNN与CNN在不同训练样本量下的训练性能,可以看出DAL-ACNN的性能均优于CNN,且随着训练样本量的减小,DAL-ACNN与CNN之间的差距不断增加。尤其在训练样本量为200的条件下(图9(c)),CNN陷入局部极小值,直到迭代到250次左右才跳出,而DAL-ACNN虽然有陷入局部值的情况,但是可以很快的跳出局部极小值,保证了网络的收敛速度与识别精度。

图9 不同样本量下DAL-ACNN与CNN的训练精度

图10是在训练样本量分别为1 000、500以及200的条件下DAL-ACNN与CNN的测试精度。测试样本与训练样本保持3∶7的比例不变,对应的测试样本量分别为75、32以及15。DAL-ACNN在训练样本量为200的条件下其测试精度为96%,与训练样本量为2 000时的测试精度相比,仅产生3.5%的差距。而CNN在训练样本量为200的条件下其测试精度为91%,与训练样本量为2 000时的测试精度相比产生了6.4%的差距。且DAL-ACNN在训练样本量为200时的测试精度与CNN在训练样本量为1 000时的测试精度相同。因此,改变训练样本量增加了CNN与DAL-ACNN的精度差距,同时也证明了DAL-ACNN在小训练样本量下的优越性能。

图10 不同样本量下DAL-ACNN与CNN的测试精度

3.4 不同方法的比较

为进一步证明DAL-ACNN模型的优越性能,将其与经典的VGGNet、GoogLeNet、ResNet以及DenseNet模型进行比较,其中VGGNet与ResNet分别选择VGG19与ResNet50结构。所选的4种深度模型拥有不同的层数与结构,比较经典地代表了CNN的不同思路,并且都是在ImageNet数据集上训练好的模型,证明了其优越的分类性能。本文在经典预训练模型的基础上,冻结模型的前几层,微调模型的权重参数,使用目标域中的花生图像对模型进行进一步的训练和学习。试验结果如图11所示,所选的经典模型在本文的花生图像集中均展示出了较高的检测性能。但与DAL-ACNN模型相比,VGGNet模型对花生霉变粒的识别准确率下降了9.3个百分点;GoogLeNet模型对花生干瘪粒与霉变粒的识别准确率分别下降了4.6个百分点与1.3个百分点;ResNet模型对花生干瘪粒与霉变粒的识别准确率分别下降了2.6个百分点与1.3个百分点;DenseNet模型对花生干瘪粒与霉变粒的识别准确率分别下降了2.1个百分点与1个百分点。进一步将4种模型的平均识别精度与本文所提出的DAL-ACNN模型进行对比,结果如表2所示,与4个模型中错误率较高的VGGNet模型相比,DAL-ACNN模型的平均识别精度提高了2.3个百分点,与错误率最低的DenseNet模型相比,DAL-ACNN模型的平均识别精度上升了0.7个百分点。因此,本文的DAL-ACNN模型相较于经典的深度模型实现了最高的识别精度。

图11 不同方法下花生的缺陷检测精度

表2 不同方法的精度对比

4 结 论

本文结合机器视觉技术与DAL-ACNN模型实现花生常见缺陷的检测。首先,该模型采用卷积神经网络自动提取花生的缺陷特征,解决手动提取特征的难题;其次,本文提出自适应学习率,缩短深层网络的训练时间,提高识别精度;然后,引入领域自适应,实现不同应用场景下的检测,并对小样本训练集表现出良好的适应性;最后,将DAL-ACNN用于花生质量检测并与经典的深度模型进行比较。对比试验结果表明,DAL-ACNN具有更高的检测精度,平均识别率高达99.7%,其中对干瘪粒、霉变粒、破碎粒与正常粒的识别率分别达到了99.3%、100%、100%和99.3%。该方法操作简便,不需要经验丰富的人员就能快速实现花生质量的自动化控制,具有一定的商业与工业价值。在今后的工作中,可将DAL-ACNN用于玉米、大豆等不同品种的检测中,增强模型的适用性,同时可进一步研究模型中其他参数的自适应调节,如卷积核尺寸等。

[1]陈翠霞,刘晓帆. 优质出口花生生产中存在的问题与对策[J]. 农业科技通讯,2012 (4):13-14.

[2]李广前. 山东花生产品出口贸易发展研究[D]. 泰安:山东农业大学,2010. Li Guangqian. The Study of the Export Trade Development of Shandong Peanut Products[D]. Taian: Shandong Agricultural University, 2010. (in Chinese with English abstract)

[3]綦亚伟. 山东省花生出口问题研究[D]. 淄博:山东理工大学,2017. Qi Yawei. The Research of Shandong Peanut Exports[D]. Zibo: Shandong University of Technology, 2017. (in Chinese with English abstract)

[4]成芳,应义斌. 机器视觉技术在农作物种子质量检验中的应用研究进展[J]. 农业工程学报,2001,17(6):175-179. Cheng Fang, Ying Yibin. Application of machine vision to quality evaluation of agricultural seed resources[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2001, 17(6): 175-179. (in Chinese with English abstract)

[5]张红涛,毛罕平,剧森,等. 基于胚部区域特征的麦粒姿态自动识别[J]. 农业工程学报,2014,30(14):163-169. Zhang Hongtao, Mao Hanping, Ju Sen, et al. Automatic posture recognition of wheat kernels based on germ features[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2014, 30(14): 163-169. (in Chinese with English abstract)

[6]陈红,熊利荣,胡筱波,等. 基于神经网络与图像处理的花生仁霉变识别方法[J]. 农业工程学报,2007,23(4):158-161. Chen Hong, Xiong Lirong, Hu Xiaobo, et al. Identification method for moldy peanut kernels based on neural network and image processing[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2007, 23(4): 158-161. (in Chinese with English abstract)

[7]高新浩,刘斌. 基于机器视觉的鲜食玉米品质检测分类器设计与试验[J]. 农业工程学报,2016,32(1):298-303. Gao Xinhao, Liu Bin. Design and experiment of fresh corn quality detection classifier based on machine vision[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2016, 32(1): 298-303. (in Chinese with English abstract)

[8]王红军,熊俊涛,黎邹邹,等. 基于机器视觉图像特征参数的马铃薯质量和形状分级方法[J]. 农业工程学报,2016,32(8):272-277. Wang Hongjun, Xiong Juntao, Li Zouzou, et al. Potato grading method of weight and shape based on imaging characteristics parameters in machine vision system[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2016, 32(8): 272-277. (in Chinese with English abstract)

[9]张凯,李振华,郁豹,等. 基于机器视觉的花生米品质分选方法[J]. 食品科技,2019,44(5):297-302. Zhang Kai, Li Zhenhua, Yu Bao, et al. Peanut quality sorting method based on machine vision[J]. Food Science and Technology, 2019, 44(5): 297-302. (in Chinese with English abstract)

[10]杨斌,钟金英. 卷积神经网络的研究进展综述[J]. 南华大学学报:自然科学版,2016,30(3):66-72. Yang Bin, Zhong Jinying. Review of convolution neural network[J]. Journal of University of South China (Science and Technology), 2016, 30(3): 66-72. (in Chinese with English abstract)

[11]卢宏涛,张秦川. 深度卷积神经网络在计算机视觉中的应用研究综述[J]. 数据采集与处理,2016,31(1):1-17. Lu Hongtao, Zhang Qinchuan. Applications of deep convolutional neural network in computer vision[J]. Journal of Data Acquisition and Processing, 2016, 31(1): 1-17. (in Chinese with English abstract)

[12]周云成,许童羽,郑伟,等. 基于深度卷积神经网络的番茄主要器官分类识别方法[J]. 农业工程学报,2017,33(15):219-226. Zhou Yuncheng, Xu Tongyu, Zhen Wei, et al. Classification and recognition approaches of tomato main organs based on DCNN[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2017, 33(15): 219-226. (in Chinese with English abstract)

[13]王璨,武新慧,李志伟. 基于卷积神经网络提取多尺度分层特征识别玉米杂草[J]. 农业工程学报,2018,34(5):144-151. Wang Can, Wu Xinhui, Li Zhiwei. Recognition of maize and weed based on multi-scale hierarchical features extracted by convolutional neural network[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2018, 34(5): 144 -151. (in Chinese with English abstract)

[14]张庆辉,万晨霞. 卷积神经网络综述[J]. 中原工学院学报,2017,28(3):82-90. Zhang Qinghui, Wan Chenxia. Review of convolutional neural networks[J]. Journal of Zhong Yuan University of Technology. 2017, 28(3): 82-90. (in Chinese with English abstract)

[15]赵志衡,宋欢,朱江波,等. 基于卷积神经网络的花生籽粒完整性识别算法及应用[J]. 农业工程学报,2018,34(21):195-201. Zhao Zhiheng, Song Huan, Zhu Jiangbo, et al. Identification algorithm and application of peanut kernel integrity based on convolution neural network[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2018, 34(21): 195-201. (in Chinese with English abstract)

[16]宋欢. 颗粒状农作物彩色色选图像处理算法研究[D]. 哈尔滨:哈尔滨工业大学,2018. Song Huan. Research on Color Sorting Image Processing Algorithm for Cranular Crops[D]. Harbin: Harbin Institute of Technology, 2018. (in Chinese with English abstract)

[17]杜剑,胡炳樑,刘永征,等. 基于卷积神经网络与光谱特征的夏威夷果品质鉴定研究[J]. 光谱学与光谱分析,2018,38(5):1514-1519. Du Jian, Hu Bingliang, Li Yongzheng, et al. Study on quality identification of macadamia nut based on convolutional neural networks and spectral features[J]. Spectroscopy and Spectral Analysis, 2018, 38(5): 1514-1519. (in Chinese with English abstract)

[18]Qiu Zhengjun, Chen Jian, Zhao Yiying, et al. Variety identification of single rice seed using hyperspectral imaging combined with convolutional neural network[J]. Applied Sciences, 2018, 8(2): 212-223.

[19]Han Zhongzhi, Gao Jiyue. Pixel-level aflatoxin detecting based on deep learning and hyperspectral imaging[J]. Computers and Electronics in Agriculture, 2019, 164: 1-8.

[20]Przybyło J, Jabłoński M. Using deep convolutional neural network for oak acorn viability recognition based on color images of their sections[J]. Computers and Electronics in Agriculture, 2019, 156: 490-499.

[21]周飞燕,金林鹏,董军. 卷积神经网络研究综述[J]. 计算机学报,2017,40(6):1229-1251. Zhou Feiyan, Jin Linpeng, Dong Jun. Review of convolutional neural network[J]. Chinese Journal of Computers, 2017, 40(6): 1229-1251. (in Chinese with English abstract)

[22]Zhang Yuanyuan, Zhao Dong, Sun Jiande, et al. Adaptive convolutional neural network and its application in face recognition[J]. Neural Processing Letters, 2016, 43(2): 389-399.

[23]储珺,苏亚伟,王璐. 自适应调节学习率和样本训练方式的场景分类[J]. 模式识别与人工智能,2018,31(7):625-633. Chu Jun, Su Yawei, Wang Lu. Scene classification with adaptive learning rate and sample training mode[J]. Pattern Recognition and Artificial Intelligence, 2018, 31(7): 625-633. (in Chinese with English abstract)

[24]Abdeljaber O, Avci O, Kiranyaz S, et al. Real-Time vibration-based structural damage detection using one-dimensional convolutional neural networks[J]. Journal of Sound and Vibration, 2017, 388: 154-170.

[25]Takase T, Oyama S, Kurihara M. Effective neural network training with adaptive learning rate based on training loss[J]. Neural Networks, 2018, 101: 68-78.

[26]Pan S J, Yang Qiang. A survey on transfer learning[J]. IEEE Transactions on Knowledge and Data Engineering, 2010, 22(10): 1345-1359.

[27]Liang Gaobo, Hong Huichao, Xie Weifang, et al. Combining convolutional neural network with recursive neural network for blood cell image classification[J]. IEEE Access, 2018, 6: 36188-36197.

[28]张鑫鑫,梁星. 基于迁移学习的卷积神经网络应用研究[J]. 电脑知识与技术,2019,15(10):174-177. Zhang Xinxin, Liang Xing. Research and application of transfer learning in convolutional neural network[J]. Computer Knowledge and Technology, 2019, 15(10): 174-177. (in Chinese with English abstract)

[29]Paaßen B, Schulz A, Hahne J, et al. Expectation maximization transfer learning and its application for bionic hand prostheses[J]. Neurocomputing, 2018, 298: 122-133.

[30]Salaken S M, Khosravi A, Thanh N, et al. Seeded transfer learning for regression problems with deep learning[J]. Expert Systems with Applications, 2019, 115: 565-577.

[31]Shanthi T, Sabeenian R S. Modified Alexnet architecture for classification of diabetic retinopathy images[J]. Computers & Electrical Engineering, 2019, 76: 56-64.

[32]郭晓洁,陈良,沈长青,等. 自适应深度卷积神经网络在人脸识别上的应用[J]. 自动化技术与应用,2017,36(7):72-77. Guo Xiaojie, Chen Liang, Shen Changqing, et al. Adaptive deep convolution neural network and its application in human face recognition[J]. Techniques of Automation and Application, 2017, 36(7): 72-77. (in Chinese with English abstract)

[33]张博,史忠植,赵晓非,等. 一种基于跨领域典型相关性分析的迁移学习方法[J]. 计算机学报,2015,38(7):1326-1336. Zhang Bo, Shi Zhongzhi, Zhao Xiaofei, et al. A transfer learning based on canonical correlation analysis across different domains[J]. Chinese Journal of Computers, 2015, 38(7): 1326-1336. (in Chinese with English abstract)

Detection of peanut kernel quality based on machine vision and adaptive convolution neural network

Zhang Siyu, Zhang Qiuju, Li Ke※

(,,214122,)

Aiming at the shortcomings of the traditional image recognition, including low accuracy and relying on experienced staff, a peanut kernel quality detection method based on machine vision and adaptive convolutional neural network (DAL-ACNN) is proposed in this paper. An image acquisition system was built to obtain the color images of peanuts which included normal peanuts, broken peanuts, shriveled peanuts and mildew peanuts, and a black background was selected in the system. Then, a convolutional neural network (CNN) based on Alexnet was selected to automatically extract and detect the peanut defects. To improve the accuracy and generalization of detection, it is necessary to optimize the existed network. Firstly, the key of the stochastic gradient descent is the choice of the learning rate, which directly influences the convergence speed and testing accuracy of the network. In this paper, an adaptive learning rate based on the changes in the loss and the weight was proposed, respectively. A larger learning rate was obtained to accelerate convergence in the initial training stage, and a smaller learning rate produced due to a higher accuracy in the later of network, which can avoid the oscillation. In the process of parameters update, a quadratic function was introduced to the loss to combine with the adaptive learning rate based on loss change for parameters update, and a normal distribution model was introduced to combine with the adaptive learning rate based on weight change to further update parameters. Secondly, to improve the generalization performance of the model, the domain adaption learning (DAL) for transfer learning was joined to the network. A domain classifier was introduced behind the feature layer, which can measure the difference of feature distribution between domains by the domain classification loss, and minimize difference of feature distribution by the marginal distribution adaption loss. A conditional distribution adaptation was introduced behind the Softmax layer, which can measure and adjust the category distribution difference by the conditional distribution adaption loss. These losses for domain adaption learning were optimized by backpropagation, which can locally and globally adjust the distribution to minimize the difference between domains, then the source domain information was migrated to the target domain, so the network trained on source data can also perform well on target data. The loss of marginal distribution adaption and conditional distribution adaption were combined with the classification loss to form the loss of the proposed model. The loss of conditional distribution adaption and classification were used to update the parameters by the adaptive learning rate based on loss change, and the marginal distribution adaption loss was used to further update the feature parameters by the adaptive learning rate based on weight change. The additional domain classifier parameter was updated by the adaptive learning rate based on domain classification loss variation. Finally, to verify the proposed method, the background above was seen as source domain, and a white background was selected as target domain. The parameters trained on source domain were used to initialize the proposed model, the source data and target data were taken as input to train the model. The result showed that the average accuracy for peanut detection in the target domain was 99.7%. And a higher convergence and accuracy generated by comparing with the traditional CNN at different learning rates and training sample sizes. To further prove the performance of the proposed approach, it was compared with the classic VGGNet、GoogLeNet、ResNet and DenseNet, which produced a satisfactory result.

agricultural products; machine vision; nondestructive detection; adaptive convolutional neural network; adaptive learning rate; transfer learning; domain adaption

张思雨,张秋菊,李 可. 采用机器视觉与自适应卷积神经网络检测花生仁品质[J]. 农业工程学报,2020,36(4):269-277. doi:10.11975/j.issn.1002-6819.2020.04.032 http://www.tcsae.org

Zhang Siyu, Zhang Qiuju, Li Ke. Detection of peanut kernel quality based on machine vision and adaptive convolution neural network[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2020, 36(4): 269-277. (in Chinese with English abstract) doi:10.11975/j.issn.1002-6819.2020.04.032 http://www.tcsae.org

2019-10-10

2020-01-10

国家自然科学基金资助项目(51775243);江苏省重点研发计划•产业前瞻与共性关键技术(BE2017002)

张思雨,博士生,研究方向为机器视觉及智能检测技术。Email:1466944512@qq.com

李 可,教授,研究方向为机械系统动态监测与智能故障诊断。Email:like@jiangnan.edu.cn

10.11975/j.issn.1002-6819.2020.04.032

TP391.41;TP274+.3

A

1002-6819(2020)-04-0269-09

猜你喜欢

训练样本花生卷积
基于3D-Winograd的快速卷积算法设计及FPGA实现
人工智能
卷积神经网络的分析与设计
从滤波器理解卷积
基于傅里叶域卷积表示的目标跟踪算法
多少堆花生
基于小波神经网络的网络流量预测研究
宽带光谱成像系统最优训练样本选择方法研究
到底埋在哪棵树下
花生去哪儿了