王立舒,秦銘霞,雷潔雅,王小飛,譚克竹
基于改進YOLOv4-Tiny的藍莓成熟度識別方法
王立舒,秦銘霞,雷潔雅,王小飛,譚克竹※
(東北農(nóng)業(yè)大學電氣與信息學院,哈爾濱 150030)
為實現(xiàn)自然環(huán)境下藍莓果實成熟度的精確快速識別,該研究對YOLOv4-Tiny網(wǎng)絡(luò)結(jié)構(gòu)進行改進,提出一種含有注意力模塊的目標檢測網(wǎng)絡(luò)(I-YOLOv4-Tiny)。該檢測網(wǎng)絡(luò)采用CSPDarknet53-Tiny網(wǎng)絡(luò)模型作為主干網(wǎng)絡(luò),將卷積注意力模塊(Convolution Block Attention Module,CBAM)加入到Y(jié)OLOv4-Tiny網(wǎng)絡(luò)結(jié)構(gòu)的特征金字塔(Feature Pyramid Network,F(xiàn)PN)中,通過對每個通道的特征進行權(quán)重分配來學習不同通道間特征的相關(guān)性,加強網(wǎng)絡(luò)結(jié)構(gòu)深層信息的傳遞,從而降低復(fù)雜背景對目標識別的干擾,且該檢測網(wǎng)絡(luò)的網(wǎng)絡(luò)層數(shù)較少,占用內(nèi)存低,以此提升藍莓果實檢測的精度與速度。對該研究識別方法進行性能評估與對比試驗的結(jié)果表明,經(jīng)過訓(xùn)練的I-YOLOv4-Tiny目標檢測網(wǎng)絡(luò)在驗證集下的平均精度達到97.30%,能有效地利用自然環(huán)境中的彩色圖像識別藍莓果實并檢測果實成熟度。對比YOLOv4-Tiny、YOLOv4、SSD-MobileNet、Faster R-CNN目標檢測網(wǎng)絡(luò),該研究在遮擋與光照不均等復(fù)雜場景中,平均精度能達到96.24%。平均檢測時間為5.723 ms,可以同時滿足藍莓果實識別精度與速度的需求。I-YOLOv4-Tiny網(wǎng)絡(luò)結(jié)構(gòu)占用內(nèi)存僅為24.20 M,為采摘機器人與早期產(chǎn)量預(yù)估提供快速精準的目標識別指導(dǎo)。
機器視覺;圖像識別;目標檢測網(wǎng)絡(luò);深度學習;藍莓;卷積注意力塊
中國自21世紀初開始規(guī)模化種植藍莓,是亞太地區(qū)的主要藍莓種植地[1],目前國內(nèi)藍莓栽培總面積達5.59萬hm2,產(chǎn)量高達19萬t。藍莓種植附加值高,但由于藍莓果實成熟度不統(tǒng)一導(dǎo)致藍莓收獲成本較高[2]。快速準確地識別藍莓果實,提供藍莓不同成熟度分布信息成為合理安排勞動力以及適時采摘的必要條件[3]。
目前國內(nèi)外的果實精準識別和果實成熟度分類等研究已取得了一定進展。為了能夠?qū)︻悎A果實進行檢測,謝忠紅等[4]提出了一種基于改進圓形隨機Hough變換的快速類圓果實目標檢測算法,但該方法檢測精度較低,易出現(xiàn)誤檢。Aquino等[5]使用數(shù)學形態(tài)學與像素分類的方法對葡萄樹單叢漿果數(shù)進行估算,該方法雖具有較高的穩(wěn)定性但圖像的檢測時間過長。Zhang等[6]針對石榴果實分類及識別過程受到樹枝遮擋影響的問題,提出了一種基于多特征融合與支持向量機的方法對果實進行計數(shù),準確率達到78.15%。Liu等[7]對柚子果實成熟度進行識別,應(yīng)用橢圓邊界模型的機器視覺算法,將圖像從RGB空間轉(zhuǎn)換至Y′CbCr空間,引入最小二乘法(Ordinary Least Squares,OLS)擬合橢圓邊界模型的隱式二階多項式,識別準確率為93.5%,但該方法對于未成熟綠色果實的檢測效果較差。Liu等[8]提出了一種基于顏色與形狀特征的蘋果果實檢測算法,召回率達到85%以上,但該方法魯棒性較差。Tan等[9]探討了一種基于區(qū)域不同成熟度藍莓果實識別與計數(shù)方法,應(yīng)用方向梯度直方圖(Histogram of Oriented Gradient,HOG)特征與顏色特征對藍莓果實進行檢測,但該方法存在對于遮擋果實不能有效識別的問題且耗時較長。
上述基于機器視覺進行果實檢測的方法均存在精確度低,檢測時間長等問題,與傳統(tǒng)的機器學習方法相比,深度卷積神經(jīng)網(wǎng)絡(luò)技術(shù)在目標檢測領(lǐng)域有巨大的優(yōu)勢[10-12],由于其對目標高維特征的高度提取,使復(fù)雜情況下不同成熟度的果實識別成為可能。劉芳等[13]構(gòu)建了一種復(fù)雜環(huán)境下番茄果實快速識別網(wǎng)絡(luò)模型。在Darknet-20主干網(wǎng)絡(luò)中引入殘差網(wǎng)絡(luò)的同時融合多尺度檢測模塊,能夠保證番茄果實檢測的精度與速度,并在番茄采摘試驗中驗證了模型的可行性。趙德安等[14]提出了基于YOLOv3深度卷積神經(jīng)網(wǎng)絡(luò)的蘋果定位方法,但該網(wǎng)絡(luò)模型過于復(fù)雜,難以在實際的機器上運行試驗并且難以實現(xiàn)實時檢測。唐熔釵等[15]針對目標檢測網(wǎng)絡(luò)對自然環(huán)境中百香果識別效果不佳的情況改進了YOLOv3網(wǎng)絡(luò)結(jié)構(gòu),將網(wǎng)絡(luò)結(jié)構(gòu)精簡并加強網(wǎng)絡(luò)特征傳播,得到實時效果較好的目標檢測網(wǎng)絡(luò),但該方法對多種不同成熟度的百香果檢測效果欠佳。
綜上,本研究在原始YOLOv4-Tiny深度卷積檢測網(wǎng)絡(luò)結(jié)構(gòu)的基礎(chǔ)上進行改進,在不顯著增加網(wǎng)絡(luò)結(jié)構(gòu)內(nèi)存的基礎(chǔ)上,引入卷積注意力模塊(Convolution Block Attention Module,CBAM),通過試驗測試其運用在自然環(huán)境下對藍莓果實檢測識別上的效果。在預(yù)測藍莓果實產(chǎn)量的同時劃分成熟藍莓果實的分布區(qū)域,為實現(xiàn)合理分配勞動力及準確鎖定目標進行果實機械自動采摘工作提供參考依據(jù)。
藍莓果實的檢測是基于深度學習算法在復(fù)雜的自然環(huán)境下完成對不同成熟度藍莓果實的分類,自然環(huán)境下的藍莓果實圖像存在土壤、雜草、枝葉等外界干擾。藍莓分批次成熟,通常每簇中有1~3種成熟度藍莓,即成熟果實、半成熟果實與未成熟果實。未成熟果實與枝葉顏色接近,成熟果實與土壤顏色接近。
藍莓圖像的采集地點位于美國佛羅里達州的斯特拉恩農(nóng)場,在自然光照條件下,采用設(shè)置為全自動模式18~55 mm鏡頭的佳能200DⅡ單反相機拍攝距離1 m左右的藍莓果實簇圖像,總共采集原始圖像數(shù)據(jù)876張,圖像以.jpeg格式保存,分辨率為3 648×2 736像素,對應(yīng)于約13 cm×10 cm的實際場景,壓縮率為10∶1。數(shù)據(jù)集中包含不同遮擋程度與光照程度等情況下的藍莓果實圖像樣本,其中輕度遮擋圖像樣本287幅,每幅圖像包含5~10顆藍莓果實;重度遮擋圖像樣本391幅,每幅圖像包含10~25顆藍莓果實;逆光圖像樣本198幅,每幅圖像包含3~15顆藍莓果實。
使用標注工具labelImg按Pascal voc數(shù)據(jù)集的標注格式對圖像進行標注,生成.xml類型的標注文件。訓(xùn)練深度神經(jīng)網(wǎng)絡(luò)需要大量數(shù)據(jù),過小的數(shù)據(jù)集會導(dǎo)致神經(jīng)網(wǎng)絡(luò)過擬合,因此需要對采集到的數(shù)據(jù)進行數(shù)據(jù)增強[16]。本研究使用翻轉(zhuǎn)、縮放、平移、旋轉(zhuǎn)、增加噪聲等方法隨機組合對采集到的圖像進行數(shù)據(jù)增強,并對每幅圖像對應(yīng)的標注文件進行同步變換,擴增樣本集圖像至7 005幅,按照7∶1∶2比例隨機分為訓(xùn)練集(4 904幅)、驗證集(696幅)、測試集(1 405幅)。數(shù)據(jù)集分布如表 1所示。
表1 數(shù)據(jù)增強后的藍莓數(shù)據(jù)集分布
基于深度學習的目標檢測方法主要有兩類:第一類是基于區(qū)域建議的二階段(Two-Stage)目標檢測算法,如:R-CNN[17]、Fast R-CNN[18]、Faster R-CNN[19];第二類是基于回歸的一階段(One-Stage)目標檢測算法,如:YOLO[20-22]、RetinaNet[23]、EfficientDet[24]。自2016年Redmon[21]提出首個基于回歸的目標檢測YOLOv1起便受到了研究人員的廣泛關(guān)注,截止2020年,YOLO系列網(wǎng)絡(luò)已經(jīng)更新到第四代,經(jīng)過在標準數(shù)據(jù)集上的驗證,YOLOv4[25]有著良好的性能,但在檢測速度上仍然達不到實時要求且網(wǎng)絡(luò)結(jié)構(gòu)占用內(nèi)存較大,不適宜于在農(nóng)業(yè)采摘機器人所搭載的嵌入式系統(tǒng)上部署。
YOLOv4-Tiny在YOLOv4的基礎(chǔ)上進行簡化,省略空間金字塔池化(Spatial Pyramid Pooling,SPP)和路徑增強網(wǎng)絡(luò)(Path Aggregation Network,PAN),減少網(wǎng)絡(luò)計算量,網(wǎng)絡(luò)結(jié)構(gòu)占用內(nèi)存不到Y(jié)OLOv4網(wǎng)絡(luò)結(jié)構(gòu)的十分之一。YOLOv4-Tiny采用CSPDarknet53-Tiny作為主干提取網(wǎng)絡(luò),將YOLOv4中的激活函數(shù)Mish修改為LeakyRelu激活函數(shù),使網(wǎng)絡(luò)結(jié)構(gòu)更簡單,速度更快,其次YOLOv4-Tiny利用特征金字塔(Feature Pyramid Network,F(xiàn)PN)[26]思想對相鄰尺度的特征圖通過串聯(lián)操作進行特征融合,能較好的自適應(yīng)提取圖像中隱藏的特征信息,但缺點在于并沒有充分學習輸入特征向量通道與空間之間的重要程度關(guān)系。在藍莓果實識別試驗中發(fā)現(xiàn),YOLOv4-Tiny檢測網(wǎng)絡(luò)容易受到復(fù)雜自然環(huán)境的干擾,存在漏檢的風險,檢測精度有待提高。
為了進一步提高目標檢測網(wǎng)絡(luò)的性能與檢測精度,本研究提出改進型輕量級目標檢測網(wǎng)絡(luò)(I-YOLOv4-Tiny),通過在YOLOv4-Tiny目標檢測網(wǎng)絡(luò)的FPN中引入卷積注意力模塊(Convolution Block Attention Module,CBAM)[27],對不同通道的特征圖進行權(quán)重的重新分配,加強網(wǎng)絡(luò)結(jié)構(gòu)深層信息的提取。
神經(jīng)網(wǎng)絡(luò)中可以存儲的信息量稱為網(wǎng)絡(luò)容量,網(wǎng)絡(luò)容量和網(wǎng)絡(luò)的復(fù)雜度成正比。人腦在計算資源有限的情況下,不能同時處理每一位置的視覺圖像信息,需要通過視覺的注意力機制進行處理。Woo等[27]于2018年提出CBAM卷積注意力模塊,分別在目標檢測網(wǎng)絡(luò)的特征通道維度及特征空間維度上進行了特征壓縮與生成權(quán)重并重新加權(quán)的操作。
為了得到復(fù)雜環(huán)境下精準的藍莓果實位置和類別信息,需要優(yōu)化損失函數(shù)[28],使預(yù)測框、置信度、類別的訓(xùn)練誤差達到平衡。
本研究采用完全交并比(Complete Intersection over Union,CIoU)作為損失函數(shù),與傳統(tǒng)的損失函數(shù)交并比(Intersection over Union,IoU)[29]相比,CIoU可以避免預(yù)測框與真實框不相交而導(dǎo)致的損失函數(shù)IoU的值為0以及IoU無法精確反映預(yù)測框與真實框重合度大小的問題。采用CIoU度量目標框和預(yù)測框的距離與重合程度,協(xié)調(diào)目標與錨框(anchor)之間的距離,重疊率、尺度以及懲罰項,使目標框回歸變得更加穩(wěn)定,不會像IoU和全面交并比(Generalized Intersection over Union,GIoU)[30]一樣出現(xiàn)訓(xùn)練過程中發(fā)散等問題,并將預(yù)測框長和寬的比值作為懲罰項,使預(yù)測框的效果更加穩(wěn)定。
考慮到模擬試驗中建?;貧w關(guān)系的幾何因素,損失函數(shù)應(yīng)考慮3個幾何因素,即重疊面積、距離與縱橫比。完全損失值如式(3)所示
采用歸一化中心點距離來測量2個預(yù)測框的距離,如式(5)所示。
縱橫比的一致性實現(xiàn),如式(6)所示
最后,得到完整IoU的損失函數(shù)CIoU,如式(7)所示
CIoU損失可以迅速縮短2個預(yù)測框的距離,因此收斂速度比GIoU損失要快得多。對于包含2個預(yù)測框或具有極端縱橫比的情況,CIoU損失會使回歸非??欤鳪IoU損失幾乎退化為IoU損失。
YOLOv4-Tiny目標檢測網(wǎng)絡(luò)中錨框的尺寸是經(jīng)過Coco數(shù)據(jù)集與Pascal voc數(shù)據(jù)集訓(xùn)練時聚類得到的,在Pascal voc數(shù)據(jù)集中有20類目標,在Coco數(shù)據(jù)集中有80類目標,這些目標物體尺寸不一,因此聚類出來的錨框形狀不一,而本研究目標檢測網(wǎng)絡(luò)主要的檢測目標只是藍莓果實,針對藍莓目標數(shù)據(jù)集,多數(shù)的錨框的形狀應(yīng)該是偏正方形的,即錨框的寬度約等于高度。為了使I-YOLOv4-Tiny目標檢測網(wǎng)絡(luò)更準確地預(yù)測目標的位置,利用K-means算法針對藍莓目標數(shù)據(jù)集重新聚類,得到更精確、更具代表性的錨框。K-means算法隨機選取個初始的聚類中心,然后計算其他目標與聚類中心的距離,并分配給最近的聚類中心成為個群,通過迭代調(diào)整使群中各個目標之間的距離越來越小,群間距離變大。在K-means算法中通常以歐式距離作為計算的度量距離,但在目標檢測網(wǎng)絡(luò)中更適合采用預(yù)測框與錨框的面積重疊度IOU(,)作為度量距離,則新的度量標準計算公式為
在保證目標檢測網(wǎng)絡(luò)實時性的同時,應(yīng)盡可能滿足并提高目標檢測網(wǎng)絡(luò)對藍莓果實識別的精準性。相比YOLOv4-Tiny的輕量,I-YOLOv4-Tiny則是在保證實時性的基礎(chǔ)上追求更高的性能。將CBAM模塊與YOLOv4-Tiny檢測網(wǎng)絡(luò)相結(jié)合,構(gòu)建I-YOLOv4-Tiny目標檢測網(wǎng)絡(luò),主要包含4個部分:輸入層、主干特征提取網(wǎng)絡(luò)、加強特征提取網(wǎng)絡(luò)和輸出層,其網(wǎng)絡(luò)結(jié)構(gòu)圖如圖2a所示。輸入層接受尺寸為416×416像素的圖像經(jīng)過CSPDarknet53-Tiny主干特征提取網(wǎng)絡(luò)后送入加強特征提取網(wǎng)絡(luò)進行特征聚合,最后在輸出層輸出2種不同尺度的預(yù)測錨框(YOLO head)。
CSPDarknet53-Tiny主干特征提取網(wǎng)絡(luò)主要由CBL模塊和跨階段殘差結(jié)構(gòu)(Cross Stage Partial,CSP)模塊2個部分構(gòu)成。CBL模塊由一個卷積層連接一個批量正則化(BatchNorm,BN)再連接一個LeakyRelu激活函數(shù)組成,用于控制拼接和采樣等工作,如圖2c。CSP模塊是跨階段殘差模塊,對殘差單元的結(jié)構(gòu)進行了改進,加入了一條跨殘差旁路,形成跨階段局部連接,能夠?qū)⑻卣鲌D一分為二,對原來的殘差塊堆疊進行拆分,拆成左右2個部分:主干部分繼續(xù)進行殘差塊堆疊;另一部分則與殘差邊類似,經(jīng)過少量處理直接連接到最后進行串聯(lián)結(jié)合,有效減少了梯度消失的危險,泛化了學習能力,如圖2b。在殘差模塊中,對輸入的特征層進行一次3×3卷積的特征整合,在構(gòu)建完一條殘差邊后,另一部分對輸入的特征層進行通道分割,分成2個等同大小部分,取第二部分進行殘差模塊的構(gòu)建,如圖2d。通過CSPdarknet53-Tiny主干特征提取網(wǎng)絡(luò),獲得2個有效特征層,將其傳入加強特征提取網(wǎng)絡(luò)中進行FPN的構(gòu)建,F(xiàn)PN把經(jīng)由主干特征網(wǎng)絡(luò)后獲得的2個有效特征層進行融合,然后將最后一個有效特征層卷積后進行上采樣,與前一個有效特征層進行堆疊并卷積。在預(yù)測輸出的部分,首先將經(jīng)由加強特征提取網(wǎng)絡(luò)的2個有效特征層送入CBAM模塊自動學習特征通道之間的相關(guān)性和重要性,輸出2個尺度的檢測結(jié)果,在前向傳播過程中,重要特征通道將逐漸占有更大的比重,在最終呈現(xiàn)的輸出圖像中也能更加明顯地展現(xiàn)出檢測網(wǎng)絡(luò)所重點關(guān)注的部分,使I-YOLOv4-Tiny目標檢測網(wǎng)絡(luò)相對于背景可以更高效的聚集圖像特征信息的提取。最后將獲得到的特征進行預(yù)測。當多個邊界框檢測到同一個對象,I-YOLOv4-Tiny使用非極大抑制(Non-Maximum Suppression,NMS)來保持最佳邊界框。
2.6.1 試驗平臺
本研究中的訓(xùn)練與測試在一臺配置為PC Inter Core(TM) i7-1075HCPU@2.60 GHZ 2.59GHZ、6GB的GPU GeForce GTX 1660Ti與16GB運行內(nèi)存的計算機上運行,安裝有Cuda10.0.130版本的并行計算機框架和Cudnn7.6.5版本的深度學習加速庫,在Keras深度學習框架上,采用python3.7作為編程語言實現(xiàn)本研究。
2.6.2 網(wǎng)絡(luò)訓(xùn)練參數(shù)設(shè)置
模型超參數(shù)設(shè)置為每批量樣本數(shù)為32,遍歷1次全部訓(xùn)練集數(shù)據(jù)稱為1次迭代,批量設(shè)置為100。采用自適應(yīng)矩陣估計算法(Adam)優(yōu)化模型,初始學習率設(shè)置為0.001,動量因子為0.9,每經(jīng)過3 000次迭代訓(xùn)練,將學習率降低10倍,模型每訓(xùn)練500次保存一次權(quán)重。
2.6.3 評價指標
對于自然復(fù)雜環(huán)境下藍莓目標的識別,需考慮檢測網(wǎng)絡(luò)的精度與實時性。本研究采用平均精度(Mean Average Precision,mAP,%)作為模型檢測精度的評價指標,mAP與準確率(Precision,,%)、召回率(Recall,%)有關(guān),其計算如下式(10)~(13)所示
式中,TP為被正確劃分到正樣本的數(shù)量,F(xiàn)P為被錯誤劃分到正樣本的數(shù)量,F(xiàn)N為被錯誤劃分到負樣本的數(shù)量,為類別總數(shù),AP()為第類AP值。
F1得分是一種用來衡量二分類模型精確度的指標。F1得分可以看作是模型精確率與召回率的一種加權(quán)平均,最大值為1,最小值為0,如式(14)所示。
檢測時間使用目標檢測網(wǎng)絡(luò)檢測一幅圖所消耗的平均時間為標準,單位為ms。
由于本研究I-YOLOv4-Tiny網(wǎng)絡(luò)結(jié)構(gòu)是基于YOLOv4-Tiny主干網(wǎng)絡(luò),同時融合了CBAM模塊進行改進的,為證明基于YOLOv4-Tiny為基礎(chǔ)網(wǎng)絡(luò)的改進網(wǎng)絡(luò)I-YOLOv4-Tiny的有效性,需要對改進前后檢測網(wǎng)絡(luò)性能進行對比分析。在藍莓數(shù)據(jù)集下對YOLOv4-Tiny與I-YOLOv4-Tiny分別在單簇藍莓果實和雙簇藍莓果實圖像上對不同成熟度的藍莓進行識別試驗如圖3,由于枝葉和藍莓果實的遮擋,YOLOv4-Tiny無論是在單簇藍莓識別還是雙簇藍莓識別上都有未識別出的藍莓果實,而本研究的I-YOLOv4-Tiny網(wǎng)絡(luò)結(jié)構(gòu)則能識別出被遮擋的藍莓。檢測藍莓目標的準確率、召回率、平均精度、檢測時間如表2所示。
表2 改進前后檢測網(wǎng)絡(luò)試驗結(jié)果對比
由表2可知,本研究提出的I-YOLOv4-Tiny目標檢測網(wǎng)絡(luò),在檢測時間相差0.078 ms的情況下,平均精度高于改進前的YOLOv4-Tiny目標檢測網(wǎng)絡(luò)2.58個百分點,F(xiàn)1得分相應(yīng)也提升了2.13個百分點,能夠檢測出藍莓并準確分辨出藍莓的成熟程度。由表3可知,增加CBAM模塊后,網(wǎng)絡(luò)結(jié)構(gòu)內(nèi)存大小雖略有增加,但目標檢測網(wǎng)絡(luò)的性能均有不同程度提升,說明I-YOLOv4-Tiny對目標檢測網(wǎng)絡(luò)性能具有促進作用。引入CBAM模塊在很大程度上提升了對不同成熟度藍莓檢測的準確率。通道注意力可對特征圖的不同通道賦予不同特征,選擇性增大包含藍莓果實通道的權(quán)重值,空間注意力對同一特征圖不同位置特征點給予不同權(quán)重,區(qū)別對待特征圖內(nèi)部像素點。兩者結(jié)合可總體提升檢測準確率,表明了CBAM模塊對于不同成熟度藍莓果實檢測的有效性。
表3 網(wǎng)絡(luò)結(jié)構(gòu)占用內(nèi)存大小對比
使用本研究所用數(shù)據(jù)集分別訓(xùn)練I-YOLOv4-Tiny、YOLOv4-Tiny、Faster R-CNN、YOLOv4、SSD-MobileNet[31]5種目標檢測網(wǎng)絡(luò),對輕度遮擋、重度遮擋與逆光情況下不同成熟度的藍莓進行識別。
不同目標檢測網(wǎng)絡(luò)對不同自然環(huán)境下的藍莓果實識別效果如圖4所示,綜合對比可以看到藍莓果實在數(shù)量不同、稠密程度不同、光照不同、枝葉果實遮擋等情況下,I-YOLOv4-Tiny目標檢測算法能準確框出未成熟、半成熟和成熟的藍莓果實,具有很高的識別準確率,而其他4種目標檢測網(wǎng)絡(luò)出現(xiàn)了誤檢和漏檢情況。因此,本研究算法具有較強的魯棒性,可以適應(yīng)自然環(huán)境下的不同情況。
5種目標檢測網(wǎng)絡(luò)檢測對比結(jié)果如表4,在果實輕度遮擋的情況下,5種目標檢測網(wǎng)絡(luò)的平均精度都達到90%以上,其中I-YOLOv4-Tiny網(wǎng)絡(luò)結(jié)構(gòu)的平均精度、準確率、召回率、F1得分均高于其他4種網(wǎng)絡(luò)結(jié)構(gòu),分別為96.77%、97.63%、96.85%、97.24%,證明其比其他4種目標檢測網(wǎng)絡(luò)在檢測精度上有明顯的提升。在重度遮擋的情況下,本研究提出的I-YOLOv4-Tiny目標檢測網(wǎng)絡(luò)平均精度和F1得分分別為96.15%和95.91%,都能達到95%以上,其平均精度和F1得分比Faster R-CNN分別高出5.09與5.98個百分點,比YOLOv4分別高出2.99與3.40個百分點,且在檢測速度方面有明顯的提升。與檢測速度相差不太明顯的SSD-Mobilenet相比,在平均精度和F1得分上都分別提升了近13個百分點。與檢測時間相差不到0.2 ms的YOLOv4-Tiny相比,平均精度和F1得分也分別提高了1.53與2.67個百分點。在逆光情況下,I-YOLOv4-Tiny、YOLOv4-Tiny、Faster R-CNN和YOLOv4四種網(wǎng)絡(luò)結(jié)構(gòu)的平均精度均達到90%以上,可Faster R-CNN與YOLOv4兩種目標檢測網(wǎng)絡(luò)在檢測時間上遠大于本研究目標檢測網(wǎng)絡(luò)I-YOLOv4-Tiny,I-YOLOv4-Tiny目標檢測網(wǎng)絡(luò)檢測時間僅需5.349 ms,對比可知,I-YOLOv4-Tiny比Faster R-CNN檢測速度提升近5倍,比YOLOv4檢測速度提升近4倍。雖然在檢測時間上,I-YOLOv4-Tiny比YOLOv4-Tiny多0.176 ms,但I-YOLOv4-Tiny在平均精度與F1得分上比YOLOv4-Tiny分別提高2.28與1.58個百分點。綜合以上3種場景,本研究提出的I-YOLOv4-Tiny目標檢測網(wǎng)絡(luò)的平均精度和F1得分分別為96.24%和95.91%。
表4 5種目標檢測網(wǎng)絡(luò)的檢測結(jié)果
P-R曲線是一條以準確率為縱軸和召回率為橫軸的曲線,可以反映出目標檢測網(wǎng)絡(luò)的綜合性能在藍莓測試集下5種目標檢測網(wǎng)絡(luò)構(gòu)的P-R曲線如圖5a,I-YOLOv4-Tiny目標檢測網(wǎng)絡(luò)的曲線在其他4種目標檢測網(wǎng)絡(luò)曲線的外側(cè),且在平衡點(準確率=召回率時的取值)的位置更接近于坐標(1,1),證明本研究提出的I-YOLOv4-Tiny檢測精度高于其他4種目標檢測網(wǎng)絡(luò)。I-YOLOv4-Tiny目標檢測網(wǎng)絡(luò)在訓(xùn)練時的平均損失值隨迭代次數(shù)的變化曲線如圖5b所示,從圖中可以看出,當?shù)螖?shù)超過4 000次后,損失值基本趨于平穩(wěn),大約為0.2左右,此后網(wǎng)絡(luò)結(jié)構(gòu)收斂。
雖然本研究目標檢測網(wǎng)絡(luò)I-YOLOv4-Tiny在藍莓果實識別過程中所受干擾較多,但對于3類不同成熟度藍莓果實的平均精度均高于95%,其中成熟藍莓果實的平均精度最高,由于未成熟果實顏色與背景色較為相似,未成熟藍莓果實的檢測精度相對較差??梢钥闯觯狙芯磕繕藱z測網(wǎng)絡(luò)整體性能表現(xiàn)最佳,可以同時滿足識別精度與速度的需求。
1)本研究提出了一種改進的YOLOv4-Tiny輕量級神經(jīng)網(wǎng)絡(luò)目標檢測結(jié)構(gòu)(I-YOLOv4-Tiny),用于對不同成熟度藍莓果實的識別與檢測。在YOLOv4-Tiny目標檢測網(wǎng)絡(luò)的基礎(chǔ)上,融合卷積注意力模塊(Convolution Block Attention Module,CBAM),提升網(wǎng)絡(luò)結(jié)構(gòu)的精度,且占用內(nèi)存結(jié)構(gòu)僅為24.20 M,利于農(nóng)業(yè)嵌入式移動設(shè)備的部署,可以為農(nóng)業(yè)采摘機器人早期產(chǎn)量預(yù)估提供精準的定位指導(dǎo)。
2)根據(jù)自然環(huán)境下場景的不同,制作了輕度遮擋、重度遮擋、逆光這3種場景下的藍莓圖像數(shù)據(jù)集,分別用于改進前后的YOLOv4-Tiny目標檢測網(wǎng)絡(luò)的訓(xùn)練和測試,并將改進前后的目標檢測網(wǎng)絡(luò)與Faster R-CNN、YOLOv4、SSD-MobileNet目標檢測網(wǎng)絡(luò)進行對比試驗。結(jié)果表明,改進后的目標檢測網(wǎng)絡(luò)(I-YOLOv4-Tiny)平均精度和F1得分分別達到96.24%和95.91%,在網(wǎng)絡(luò)結(jié)構(gòu)大小方面本研究網(wǎng)絡(luò)結(jié)構(gòu)大小不到Y(jié)OLOv4的十分之一,對3種不同成熟度藍莓的檢測,I-YOLOv4-Tiny目標檢測網(wǎng)絡(luò)表現(xiàn)最好,能夠在達到實時性的基礎(chǔ)上,提供更高的識別精度。
[1] 李亞東,裴嘉博,孫海悅. 全球藍莓產(chǎn)業(yè)發(fā)展現(xiàn)狀及展望[J].吉林農(nóng)業(yè)大學學報,2018,40(4):421-432.
Li Yadong, Pei Jiabo, Sun Haiyue. Status and prospect of global blueberry industry[J]. Journal of Jilin Agricultural University, 2018, 40(4): 421-432. (in Chinese with English abstract)
[2] 蔣小銘,吳林,李麗敏. 中國藍莓產(chǎn)業(yè)理性投資與可持續(xù)發(fā)展戰(zhàn)略研究[J]. 中國園藝文摘,2015,24(8):81-82.
Jiang Xiaoming, Wu Lin, Li Limin. Studies on ratinal investment and sustainable development strategy of blueberry[J]. Chinese Horticulture Abstract, 2015, 24(8): 81-82. (in Chinese with English abstract)
[3] Ren D, Yang S X. Intelligent automation with applications to agriculture[J]. Intelligent Automation & Soft Computing, 2016, 22(2): 227-228.
[4] 謝忠紅,姬長英,郭小清,等. 基于改進Hough變換的類圓果實目標檢測[J]. 農(nóng)業(yè)工程學報,2010,26(7):157-162.
Xie Zhonghong, Ji Changying, Guo Xiaoqing, et al. Round like fruit target detection based on improved Hough transform[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2010, 26(7): 157-162 (in Chinese with English abstract)
[5] Aquino A, Diago M P, B Millán, et al. A new methodology for estimating the grapevine-berry number per cluster using image analysis-ScienceDirect[J]. Biosystems Engineering, 2017, 156(13): 80-95.
[6] Zhang C, Zhang K, Ge L, et al. A method for organs classification and fruit counting on pomegranate trees based on multi-features fusion and support vector machine by 3D point cloud[J]. Scientia Horticulturae, 2020, 278: 109791
[7] Liu T H, Ehsani R, Toudeshki A, et al. Identifying immature and mature pomelo fruits in trees by elliptical model fitting in the Cr–Cb color space[J]. Precision Agriculture, 2018, 20(1): 138-156
[8] Liu X, Zhao D, Jia W, et al. A detection method for apple fruits based on color and shape features[J]. IEEE Access, 2019, 5(99): 1-1.
[9] Tan K, Lee W S, Gan H, et al. Recognising blueberry fruit of different maturity using histogram oriented gradients and colour features in outdoor scenes[J]. Biosystems Engineering, 2018, 176(12): 59-72.
[10] 薛月菊,黃寧,涂淑琴,等. 未成熟芒果的改進 YOLOv2識別方法[J]. 農(nóng)業(yè)工程學報,2018,34(7):173-179.
Xue Yueju, Huang Ning, Tu Shuqin, et al. Immature mango detection based on improved YOLOv2[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2018, 34(7): 173-179. (in Chinese with English abstract)
[11] 趙春江,文朝武,林森,等. 基于級聯(lián)卷積神經(jīng)網(wǎng)絡(luò)的西紅柿花期識別檢測方法[J]. 農(nóng)業(yè)工程學報,2020,36(24):143-152.
Zhao Chunjiang, Wen Chaowu, Lin Sen, et al. Tomato florescence recognition and detection method based on cascaded neural network[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2020, 36(24): 143-152. (in Chinese with English abstract)
[12] 呂石磊,盧思華,李震,等. 基于改進YOLOv3-LITE輕量級神經(jīng)網(wǎng)絡(luò)的柑橘識別方法[J]. 農(nóng)業(yè)工程學報,2019,35(17):205-214.
Lv Shilei, Lu Sihua, Li Zheng, et al. Citrus recognition method based on improved YOLOv3-LITE lightweight neural network[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2019, 35 (17): 205-214. (in Chinese with English abstract)
[13] 劉芳,劉玉坤,林森,等. 基于改進型YOLO的復(fù)雜環(huán)境下番茄果實快速識別方法[J]. 農(nóng)業(yè)機械學報,2020,51(6):236-244.
Liu Fang, Liu Yukun, Lin Seng, et al. Fast recognition method of tomato fruit in complex environment based on improved YOLO[J] Transactions of the Chinese Society for Agricultural Machinery, 2020, 51(6): 236-244. (in Chinese with English abstract)
[14] 趙德安,吳任迪,劉曉洋,等. 基于YOLO深度卷積神經(jīng)網(wǎng)絡(luò)的復(fù)雜背景下機器人采摘蘋果定位[J]. 農(nóng)業(yè)工程學報,2019,35(3):172-181.
Zhao Dean, Wu Rendi, Liu Xiaoyang, et al. Localization of apple picking robot in complex background based on YOLO deep convolution neural network[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2019, 35(3): 172-181. (in Chinese with English abstract)
[15] 唐熔釵,伍錫如. 基于改進YOLO-V3網(wǎng)絡(luò)的百香果實時檢測[J]. 廣西師范大學學報:自然科學版,2020,38(6):35-42.
Tang Rongchai, Wu Xiru. Real time detection of passion fruit based on improved YOLO-V3 network[J]. Journal of Guangxi Normal University: Natural Science Edition, 2020, 38(6): 35-42. (in Chinese with English abstract)
[16] 高友文,周本君,胡曉飛. 基于數(shù)據(jù)增強的卷積神經(jīng)網(wǎng)絡(luò)圖像識別研究[J]. 計算機技術(shù)與發(fā)展,2018,28(8):62-65.
Gao Youwen, Zhou Benjun, Hu Xiaofei, Image recognition based on convolution neural network based on data enhancement[J]. Computer Technology and Development 2018, 28(8): 62-65. (in Chinese with English abstract)
[17] He Kaiming, Gkioxari Georgia, Dollar Piotr, et al. Mask R-CNN[C]. IEEE International Conference on Computer Vision, Venice, Italy, 2017: 2980-2988.
[18] Girshick R. Fast r-cnn[C]//IEEE International Conference on Computer Vision. Santiago: IEEE, 2015: 1440-1448
[19] Ren S, He K, Girshick R, et al. Faster r-cnn: Towards real-time object detection with region proposal networks[C]//Advances in neural information processing systems. 2015: 91-99.
[20] Redmon J, Divvala S, Girshick R, et al. You only look once: Unified, real-time object detection[C]//IEEE conference on Computer Vision and Pattern Recognition. Las Vegas: IEEE, 2016: 779-788.
[21] Redmon J, Farhadi A. YOLO9000: Better, faster, stronger[C]//IEEE Conference on Computer Visionand Pattern Recognition. Honolulu: IEEE. 2017: 7263-7271.
[22] Redmon J, Farhadi A. YOLOv3: An incremental improvement[J]. 2018, arXiv: 1804. 02767v1.
[23] Lin T, Goyal P, Girshick R, et al. Focal loss for dense object detection[C]//IEEE International Conference on Computer Vision (ICCV). Venice, Italy: IEEE, 2017.
[24] Tan M, Pang R, Le Q. Efficientdet: Scalable and efficient object detection[C]//2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Seattle, WA, USA: IEEE, 2020.
[25] Bochkovskiy A, Wang C Y, Liao H Y M. YOLOv4: Optimal speed and accuracy of object detection[J]. arXiv preprint arXiv: 2004. 10934, 2020.
[26] Lin T, Dollar P, Girshick R, et al. Feature pyramid networks for object detection[C]//IEEE Conference on Computer Vision and Pattern Recognition, Honolulu, Hawaii, USA, 2017: 936-944.
[27] Woo S , Park J , Lee J Y , et al. CBAM: Convolutional Block Attention Module[J]. Springer, Cham, 2018.
[28] 楊斌,李成華,江小平,等. 一種用于提升深度學習分類模型準確率的正則化損失函數(shù)[J]. 中南民族大學學報:自然科學版,2020,39(1):74-78. Yang Bin, Li Chenghua, Jiang Xiaoping, et al. A regularized loss function for improving the regularized loss function for improving the accuracy of deep learning classification model[J]. Journal of South Central University for Nationalities: Natural Science Edition, 2020, 39(1): 74-78. (in Chinese with English abstract)
[29] 景亮,王瑞,劉慧. 基于雙目相機與改進YOLOv3算法的果園行人檢測與定位[J]. 農(nóng)業(yè)機械學報,2020,51(9):34-39,25.
Jing Liang, Wang Rui, Liu Hui. Orchard pedestrian detection and location based on binocular camera and improved YOLOv3 algorithm[J]. Transactions of the Chinese Society for Agricultural Machinery, 2020, 51(9): 34-39, 25. (in Chinese with English abstract)
[30] 蔡逢煌,張岳鑫,黃捷. 基于YOLOv3與注意力機制的橋梁表面裂痕檢測算法[J]. 模式識別與人工智能,2020,33(10):926-933.
Cai Fenghuang, Zhang Yuexin, Huang Jie. bridge surface crack detection algorithm based on YOLOv3 and attention mechanism[J]. Pattern Recognition and Artificial Intelligence, 2020, 33(10): 926-933. (in Chinese with English abstract)
[31] Liu W, Anguelov D, Erhan D, et al. SSD: Single shot multibox detector[C]//European conference on computer vision. 2016: 21-37.
Blueberry maturity recognition method based on improved YOLOv4-Tiny
Wang Lishu, Qin Mingxia, Lei Jieya, Wang Xiaofei, Tan Kezhu※
(,,150030,)
The accurate identification of blueberry fruit maturity is very important for modern automatic picking and early yield estimation. To realize the accurate and rapid identification of blueberry fruit in the natural environment, by improving the structure of YOLOv4-Tiny network, a target detection network with attention module (I-YOLOv4-Tiny) was proposed. The detection network used CSPDarknet53-Tiny network model as the backbone network, and the convolution block attention module (CBAM) was added to the feature pyramid network (FPN) model. Feature compression, weight generation and reweighting were carried out on the feature channel dimension and feature space dimension of the target detection network, The two dimensions of channel attention and spatial attention selectively integrated the deep and shallow features. High order features guided low-order features for channel attention acquisition, and low-order features reversed guide high-order features for spatial attention screening, which could improve the feature extraction ability of network structure without significantly increasing the amount of calculation and parameters, and realized the real-time detection performance of network structure, the correlation of features between different channels was learned by weight allocation of features of each channel, and the transmission of deep information of network structure was strengthened, to reduce the interference of complex background on target recognition. Moreover, the detection network has fewer network layers and low memory consumption, to significantly improve the accuracy and speed of blueberry fruit detection. The performance evaluation and comparative test results of the research recognition method showed that the Mean Average Precision (mAP) of the trained I-YOLOv4-Tiny target detection network under the verification set was 97.30%, which could effectively use the color images in the natural environment to identify blueberry fruits and detect fruit maturity. The average accuracy and F1 score of I-YOLOv4-Tiny detection network were 97.30% and 96.79% respectively, which were 2.58 percentage points and 2.13 percentage points higher than that of YOLOv4-Tiny target detection network respectively. In terms of the memory occupied by the network structure, I-YOLOv4-Tiny was 1.05 M larger than that of YOLOv4-Tiny, and the detection time was 5.723 ms, which was only 0.078 ms more than that of YOLOv4-Tiny target detection network, which did not affect the real-time detection, However, many indicators have been improved significantly. Compared with I-YOLOv4-Tiny, YOLOv4-Tiny, YOLOv4, SSD-MobileNet and Faster R-CNN target detection networks in different scenes, the average accuracy of I-YOLOv4-Tiny target detection network was the highest, reaching 96.24%, 1.51 percentage points higher than YOLOv4-Tiny, 4.84 percentage points higher than Faster R-CNN, 1.54 percentage points higher than YOLOv4 and 10.74 percentage points higher than SSD-MobileNet. In terms of network structure size, this study was less than one tenth of the size of YOLOv4 network structure, only 24.20 M. In terms of the detection of three blueberries with different maturity, the I-YOLOv4-Tiny target detection network performed best, which could provide accurate positioning guidance for picking robots and early yield estimation. In this study, the target detection network I-YOLOv4-Tiny suffered more interference in the process of blueberry fruit recognition, but the average accuracy of three types blueberry fruits with different maturity was higher than 95%, of which the average accuracy of mature blueberry fruits was the highest. Due to the similar color of immature fruits and background color, the detection accuracy of immature blueberry fruits was relatively poor. It could be seen that the overall performance of the target detection network in this study was the best, which could meet the needs of recognition accuracy and speed at the same time.
machine vision; image recognition; target detection network; deep learning; blueberries; convolutional attention block
王立舒,秦銘霞,雷潔雅,等. 基于改進YOLOv4-Tiny的藍莓成熟度識別方法[J]. 農(nóng)業(yè)工程學報,2021,37(18):170-178.doi:10.11975/j.issn.1002-6819.2021.18.020 http://www.tcsae.org
Wang Lishu, Qin Mingxia, Lei Jieya, et al. Blueberry maturity recognition method based on improved YOLOv4-Tiny[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2021, 37(18): 170-178. (in Chinese with English abstract) doi:10.11975/j.issn.1002-6819.2021.18.020 http://www.tcsae.org
2021-01-04
2021-08-09
黑龍江省教育廳科技課題(12521038);黑龍江省自然科學基金聯(lián)合引導(dǎo)項目(LH2020C003)
王立舒,博士,教授,博士生導(dǎo)師,研究方向為農(nóng)業(yè)電氣化與自動化、電力新能源開發(fā)與利用。Email:wanglishu@neau.edu.cn
譚克竹,博士,副教授,研究方向為農(nóng)業(yè)信息感知及處理。Email:kztan@neau.edu.cn
10.11975/j.issn.1002-6819.2021.18.020
TP391.4
A
1002-6819(2021)-18-0170-09