胡廣銳,周建國,陳 超,李傳林,孫麗娟,陳 雨,張 碩,陳 軍
融合輕量化網(wǎng)絡與注意力機制的果園環(huán)境下蘋果檢測方法
胡廣銳,周建國,陳 超,李傳林,孫麗娟,陳 雨,張 碩,陳 軍※
(西北農(nóng)林科技大學機械與電子工程學院,楊凌 712100)
為提高復雜果園環(huán)境下蘋果檢測的綜合性能,降低檢測模型大小,通過對單階段檢測網(wǎng)絡YOLOX-Tiny的拓撲結構進行了優(yōu)化與改進,提出了一種適用于復雜果園環(huán)境下輕量化蘋果檢測模型(Lightweight Apple Detection YOLOX-Tiny Network,Lad-YXNet)。該模型引入高效通道注意力(Efficient Channel Attention,ECA)和混洗注意力(Shuffle Attention,SA)兩種輕量化視覺注意力模塊,構建了混洗注意力與雙卷積層(Shuffle Attention and Double Convolution Layer,SDCLayer)模塊,提高了檢測模型對背景與果實特征的提取能力,并通過測試確定Swish與帶泄露修正線性單元(Leaky Rectified Linear Unit,Leaky-ReLU)作為主干與特征融合網(wǎng)絡的激活函數(shù)。通過消融試驗探究了Mosaic增強方法對模型訓練的有效性,結果表明圖像長寬隨機扭曲對提高模型綜合檢測性能貢獻較高,但圖像隨機色域變換由于改變訓練集中蘋果的顏色,使模型檢測綜合性能下降。為提高模型檢測蘋果的可解釋性,采用特征可視化技術提取了Lad-YXNet模型的主干、特征融合網(wǎng)絡和檢測網(wǎng)絡的主要特征圖,探究了Lad-YXNet模型在復雜自然環(huán)境下檢測蘋果的過程。Lad-YXNet經(jīng)過訓練在測試集下的平均精度為94.88%,分別比SSD、YOLOV4-Tiny、YOLOV5-Lite和YOLOX-Tiny模型提高了3.10個百分點、2.02個百分點、2.00個百分點和0.51個百分點。Lad-YXNet檢測一幅圖像的時間為10.06 ms,模型大小為16.6 MB,分別比YOLOX-Tiny減少了20.03%與18.23%。該研究為蘋果收獲機器人在復雜果園環(huán)境下準確、快速地檢測蘋果提供了理論基礎。
圖像處理;可視化;蘋果檢測;收獲機器人;卷積網(wǎng)絡;視覺注意力機制
蘋果收獲是季節(jié)性強、勞動密集型的農(nóng)業(yè)活動?,F(xiàn)階段,鮮食果實采收作業(yè)仍為人工采收,效率低,且勞動強度大[1-2]。Verbiest等[3]調查表明每年紡錘形蘋果園人工采摘勞動時間為466 h/hm2,約占總人工勞動時間的67%。越來越高的勞動力成本、較低的市場價格和缺乏合格的勞動力給果業(yè)經(jīng)濟收益帶來了越來越大的壓力[4]。蘋果收獲機器人技術作為提高蘋果生產(chǎn)效率與質量、解放果園勞動力的關鍵要素,對降低勞動成本、緩解果園勞動力短缺具有重要意義[2, 5]。果實檢測是蘋果收獲機器人實現(xiàn)自動化采收的重要步驟之一,精度高、速度快、適應性強的檢測方法更有利于提高蘋果收獲機器人的整體性能[6-7]。
視覺傳感器作為主要的感知設備被廣泛應用在收獲機器人系統(tǒng)中[7-8]。國內(nèi)外眾多學者針對果園環(huán)境中果實檢測問題,運用視覺技術展開研究工作,開發(fā)了針對不同水果的檢測算法,如柑橘[9]、番茄[10-11]、獼猴桃[12-13]、芒果[14]、蘋果[15-18]等。目標果實檢測方法根據(jù)驅動類型可分為基于目標果實特征驅動的檢測方法和基于數(shù)據(jù)驅動的檢測方法[19]。基于特征驅動的檢測方法主要依靠人類經(jīng)驗提取RGB圖像中目標果實的顏色、幾何形狀、紋理信息等特征以實現(xiàn)目標果實的檢測[8]。Wu等[20]使用 SVM(Support Vector Machine)融合HSV果實顏色和3D幾何特征識別果實,試驗表明該方法的果實識別精度為80.1%。孫建桐等[11]針對番茄識別不準確的問題,提出了一種融合幾何形態(tài)學與迭代隨機圓的番茄識別方法,識別正確率為85.1%。基于特征驅動的檢測方法易于實現(xiàn)且具有較快的檢測速度,但收獲機器人在園間作業(yè)時基于特征的檢測方法精度不足,且易受光照變化的影響。
為增強視覺檢測方法對環(huán)境的適應性,基于數(shù)據(jù)驅動的深度學習目標檢測方法受到越來越多研究者的關注[19,21-24]。其實現(xiàn)的基本步驟:1)獲取大量圖像,標注目標制作數(shù)據(jù)集;2)構建卷積網(wǎng)絡模型;3)配置模型參數(shù);4)反向傳播,訓練模型;5)前向推理,測試網(wǎng)絡,實現(xiàn)應用[25-26]。卷積神經(jīng)網(wǎng)絡(Convolutional Neural Networks, CNN)在訓練階段從大量圖像中自動提取目標果實特征,實現(xiàn)果實檢測,具有適應性強、魯棒性好、精度高等優(yōu)點[27-28]。以Faster-RCNN[29-30]等為代表的兩階段目標檢測方法,檢測精度較高,但會消耗大量計算資源,檢測時間較長。Gao等[29]基于Faster-RCNN(VGG16)提出了一種適用SNAP(Simple, Narrow, Accessible, Productive)蘋果園的多類蘋果檢測方法,平均精度為87.9%,模型大小為533 MB,檢測一幅圖像時間為0.241 s。針對果園環(huán)境下果實快速檢測問題,研究學者基于YOLO系列[12,31]、FCOS[32-33]等單階段檢測模型在保持檢測精度的同時,提高了檢測速度。趙德安等[34]基于YOLOV3(You Only Look Once Version 3)模型實現(xiàn)了復雜環(huán)境下對套袋、未成熟、成熟蘋果的檢測,平均檢測精度為87.71%,檢測一幅圖像時間為16.69 ms。為進一步提高單階段檢測模型的檢測精度,研究人員基于YOLO系列模型引入了卷積塊注意模塊(Convolutional Block Attention Module,CBAM)、擠壓激發(fā)模塊(Squeeze-and- Excitation block)、非局部塊(Non-Local block)等視覺注意力機制[15,35-36]。改進后的模型在檢測精度上均有所提升,但模型大小有所增加。收獲機器人面向復雜果園等非結構化環(huán)境,其檢測方法不僅需適應天氣與光照的變化、枝葉遮擋、背景復雜等因素的干擾,還受到有限的計算資源與存儲資源的限制。上述研究多注重模型精度與速度平衡,對模型大小考慮較少,不利于其部署在資源有限的收獲機器人上。
綜上,蘋果采摘機器人在果園環(huán)境下進行蘋果檢測時,模型應能適應復雜、多變的果園環(huán)境,準確、快速地檢測目標蘋果,且檢測模型規(guī)模要盡可能小,以方便在嵌入式設備中部署。然而目前蘋果檢測模型多是不同部分的交叉引用組合,缺少對模型的可解釋性與綜合性能考慮,因此本研究為提高復雜果園環(huán)境下蘋果檢測性能并降低模型大小,對單階段檢測網(wǎng)絡YOLOX-Tiny的拓撲結構進行了優(yōu)化與改進,引入輕量化視覺注意力模塊,并應用特征可視化技術提高模型的可解釋性,提出一種適用復雜果園環(huán)境下輕量化蘋果檢測網(wǎng)絡Lad-YXNet(Lightweight apple detection YOLOX-Tiny Network),為蘋果采摘機器人在果園環(huán)境下檢測蘋果提供參考。
本研究獲取了“煙富”和“蜜脆”兩個品種的蘋果圖像,拍攝時間為2021年9月蘋果收獲季節(jié),拍攝地點為中國陜西寶雞鳳翔區(qū)雨嘉果業(yè)果園(34°35′N 107°23′E)。兩種果樹的種植模式為紡錘形,種植行距約為3.5 m,株距約為1.2 m,具有相同的水肥管理條件。這兩個品種的樹冠與果實具有明顯的差異,“煙富”蘋果樹冠較大,枝葉更豐茂,果形適中,“蜜脆”蘋果樹冠較小,枝葉較少,果形較大。圖像使用手機進行拍攝,獲取圖像的寬高比統(tǒng)一裁剪為1∶1,像素大小為1 024×1 024像素。根據(jù)收獲機器人視覺傳感器安裝位置,選擇拍照距離為距果樹為1~2 m,面向果樹直立拍攝,以模擬收獲場景。光線變化會對蘋果檢測結果造成較大影響,陰天或使用照明裝置輔助的夜間具有較為穩(wěn)定的光照條件,降低了蘋果檢測的難度,但晴天不同時間段的光照條件差異較大,對穩(wěn)定、快速檢測蘋果提出了更高的要求。因此本研究在晴朗天氣下,拍攝全天的順光與逆光圖像。從采集的圖像中選取了1 200張圖像制作數(shù)據(jù)集,其中順光與逆光圖像各600張,如圖1所示。數(shù)據(jù)集中包括枝葉遮擋的果實、果實簇、不同光照強度的果實、運動模糊和高密集的果實。每幅圖像中包括一個或多個干擾因素,以驗證本研究模型的抗干擾能力。
a. 逆光環(huán)境下蜜脆蘋果a. Micui apple in backlightb. 順光環(huán)境下蜜脆蘋果b. Micui apple in nature lightc. 逆光環(huán)境下煙富蘋果c. Yanfu apple in backlightd. 順光環(huán)境下煙富蘋果d. Yanfu apple in nature light
本研究提出的蘋果檢測模型主要服務于蘋果收獲機器人,蘋果收獲機器人在采收過程中會根據(jù)果實的位置選擇可采摘的果實,隔行果樹上的果實因距收獲機器人較遠將不會被采摘,因此標注圖像時隔行果樹上的蘋果將不會被標注。使用LabelImg對蘋果圖像進行標注,按照PASCAL VOC數(shù)據(jù)集格式保存圖像類別和目標矩形框,生成XML格式的標注文件。選取水果暴露面積的最小外接矩形來標注蘋果,以減少背景像素。模型訓練集和測試集的樣本數(shù)比為8∶2。
在線Mosaic增強方法是在訓練過程中隨機將圖像進行增強變換后送入網(wǎng)絡進行訓練。該方法廣泛應用在深度卷積模型訓練中,以增強模型的檢測精度與泛化性能。在線Mosaic包含的增強方法有:1)隨機翻轉圖像;2)圖像隨機色域變換;3)圖像長寬隨機扭曲;4)圖像隨機組合,在訓練集中隨機選取4張圖像組合成1張圖像。在訓練蘋果數(shù)據(jù)集中采用在線Mosaic增強方式進行訓練。但由于Mosaic增強的圖像脫離自然,因此在訓練中前280 epoch使用在線Mosaic增強方法,隨后關閉Mosaic增強方法。為了驗證在線Mosaic增強方法是否對檢測結果有影響,本研究在保證訓練集數(shù)量一致的前提下對Mosaic增強方法進行了消融試驗。依次去除在線Mosaic中一種的增強方法,訓練YOLOX-Tiny與Lad-YXNet模型,以驗證增強方法的效果。通過在線增強的圖像如圖2所示。
a. 原始的在線Mosaica. Original online Mosaic b. 取消隨機圖像翻轉b. Removing random image flipc. 取消圖像隨機色域變換c. Removing image random color gamut transformd. 取消圖像長寬隨機扭曲d. Removing random distortion of image length and widthe. 取消圖像隨機組合e. Removing random image combinations
YOLO(You Only Look Once)網(wǎng)絡是典型的單階段目標檢測模型,該模型根據(jù)輸入圖像的目標特征來預測每個目標的邊界框。經(jīng)典的YOLO網(wǎng)絡,如YOLOV3、YOLOV4、YOLOV5,采用基于先驗框的方法檢測目標。該種網(wǎng)絡將輸入圖像劃分為具有3種不同網(wǎng)格尺寸的特征圖,每個特征圖又具有3個用于預測目標邊界框的先驗框,預測信息由5部分組成:邊界框中心偏離特征圖網(wǎng)格點的橫縱坐標、邊界框的寬高和置信度。
YOLOX是基于YOLOV3-SPP和YOLOV5的改進網(wǎng)絡[31]。該網(wǎng)絡模型打破了傳統(tǒng)YOLO系列基于先驗框的檢測方式,采用SimOTA(Simplified Optimal Transport Assignment)為不同大小的目標動態(tài)匹配正樣本的方式,構建了基于無先驗框的目標檢測網(wǎng)絡。網(wǎng)絡輸出預測結果的總參數(shù)如式(1)所示。
式中out為網(wǎng)絡輸出的預測總參數(shù);,為輸入圖像的寬與高;F1、F2、F3為3個特征圖的下采樣倍數(shù);reg為確定目標框位置和大小的參數(shù)個數(shù),reg=4;obj為目標框中含有目標的置信度分數(shù)的個數(shù),obj=1;cls為目標框預測目標的類別個數(shù);arc為每個特征圖的先驗框個數(shù),基于先驗框的經(jīng)典YOLO網(wǎng)絡中arc=3,YOLOX網(wǎng)絡中arc=1。YOLOX輸出預測結果的總參數(shù)是經(jīng)典YOLO網(wǎng)絡的三分之一,使YOLOX具有更快的檢測速度。
YOLOX網(wǎng)絡共包含了4個標準網(wǎng)絡和兩個輕量化網(wǎng)絡。輕量化網(wǎng)絡結構的YOLOX很好地平衡了檢測速度與精度,具有應用在田間收獲機器人上的潛力。因此,本研究綜合考慮模型大小、檢測精度和檢測速度,基于輕量化模型對田間復雜環(huán)境下蘋果目標檢測網(wǎng)絡進行了改進設計。
YOLOX-Tiny網(wǎng)絡拓撲結構主要由主干網(wǎng)絡、特征融合網(wǎng)絡和預測網(wǎng)絡組成。主干網(wǎng)絡和特征融合網(wǎng)絡借鑒了YOLOV5網(wǎng)絡拓撲結構,采用CSPDarknet作為骨干網(wǎng)絡提取圖像特征;使用PANet(Path Aggregation Network)對輸入特征進一步融合,輸出3個不同尺寸(80×80、40×40和20×20)的特征圖,特征圖通道數(shù)依次為96,192,384。預測網(wǎng)絡采用3個解耦頭對輸入特征圖進行預測,每個解耦頭輸出一個6通道(1類別分數(shù)+1置信度分數(shù)+4個預測框參數(shù))張量,整合3個不同尺寸特征圖后,最終輸出8 400×6的預測信息。
蘋果檢測網(wǎng)絡需要在保證檢測速度和精度的前提下盡量減少模型參數(shù),以便模型移植到嵌入式設備中。改進的Lad-YXNet的結構如圖3所示。主干網(wǎng)絡主要是提取目標特征。蘋果的淺層特征主要是顏色、大小、紋理等,因此將原CSPDarknet主干的Focus結構改進為Stem結構。Stem結構中使用兩個分支,一個分支采用6×6的卷積核擴大卷積的感受野,1×1和3×3的卷積核調整通道數(shù)增加網(wǎng)絡非線性;另一個分支加入最大池化操作,有利于提取蘋果的淺層特征,然后將兩個分支在通道維度上進行融合。隨著主干網(wǎng)絡的加深,提取圖像的抽象特征,但深層網(wǎng)絡結構參數(shù)增多,不利于提高模型的檢測速度與降低模型大小。因此,Lad-YXNet的主干網(wǎng)絡中僅使用3次CSPLayer,且每層CSPLayer中殘差單元(Residual Unit)僅重復一次,從而降低網(wǎng)絡整體參數(shù)與深度。在主干網(wǎng)絡的尾部引入了快速空間金字塔池化(Spatial Pyramid Pooling Fast,SPPF)模塊[37]。SPPF結構繼承了空間金字塔池化(Spatial Pyramid Pooling,SPP)的優(yōu)點,通過SPPF模塊實現(xiàn)了局部特征和全局特征融合,豐富了特征圖的表達能力,有利于檢測圖像中不同大小目標,且具有更快計算速度。
注:CBS為卷積、BN層和Swish激活函數(shù)的組合;ECA為高效通道注意力;SA為混洗注意力;SPPF為快速空間金字塔池化;CBL為卷積、BN層和Leaky-ReLU激活函數(shù)的組合。
考慮到蘋果特征與圖像背景(天空、地面、樹干、枝葉)的不同,加入視覺注意力機制讓網(wǎng)絡更好地提取蘋果特征。本研究提出的Lad-YXNet模型在主干網(wǎng)絡中第一個CSPLayer前引入高效通道注意力(Efficient Channel Attention,ECA)模塊[38],第三個CSPLayer后引入混洗注意力(Shuffle Attention,SA)模塊[39]。ECA是一種輕量化通道注意力模塊,其結構如圖4a所示。
ECA模塊將輸入特征通過平均池化操作得到通道維度的統(tǒng)計值。通道的統(tǒng)計值經(jīng)過一層自適應卷積和Sigmod函數(shù)操作后與原通道相乘,以增強貢獻多的通道,弱化貢獻少的通道。其中自適應卷積核大小的計算方法如式(2)所示。
式中ksize為自適應卷積核的大小;Cin為輸入特征的通道數(shù);| |odd表示取最接近的奇數(shù)。
SA是一種輕量化通道與空間注意力模塊,其結構如圖4b所示。注意力函數(shù)如式(3)所示。
式中in為函數(shù)輸入;為注意力函數(shù)的權重,維度為1×in×1×1;bias為注意力函數(shù)的偏置,維度為1×in×1×1;in為in的通道數(shù)。
本研究應用SA模塊將輸入特征進行分組計算,從而降低整體計算量。每組分割成兩個分支,每個分支的通道數(shù)降為原通道的十六分之一。一個分支通過平均池化與注意力函數(shù)得到通道統(tǒng)計值,通道統(tǒng)計值與原通道相乘后得到通道注意力特征;另一個分支通過組正則化與注意力函數(shù)得到空間統(tǒng)計值,空間統(tǒng)計值與原通道相乘后得到空間注意力特征;將兩個分支的結果在通道維度上進行拼接,再聚合所有組的特征,最后采用通道混洗操作實現(xiàn)不同組間的信息流通,增強卷積網(wǎng)絡的特征提取能力。
淺層網(wǎng)絡感受野較小,提取的細節(jié)特征豐富,但提取抽象特征能力弱,去噪能力差。隨著網(wǎng)絡的加深能更好地提取圖像的抽象特征,但會降低圖像的分辨率,導致圖像細節(jié)特征越來越模糊。為了解決這個問題,借鑒路徑聚合網(wǎng)絡(Pyramid Attention Networks,PANet)和特征金字塔網(wǎng)絡(Feature Pyramid Networks,F(xiàn)PN)結構構建特征融合模塊,融合來自淺層、中間層和深層的信息,構建了CSPLayer-2和SDCLayer(Shuffle attention and double convolution layer)模塊對PANet和PFN進行輕量化改進,其結構如圖3所示。CSPLayer-2將輸入特征分為兩部分,并通過短接操作增加了輸入特征的復用。SDCLayer包含一個SA模塊和兩個1×1的卷積,以增加特征融合模塊的非線性。SA模塊使卷積網(wǎng)絡更關注待檢測目標的特征,1×1卷積等效于跨通道池化操作,跨通道操作可以增強網(wǎng)絡學習圖像復雜特征的能力。CSPLayer-2和SDCLayer改善了特征融合流程,有助于加強特征提取能力,并提高模型的檢測速度。
激活函數(shù)的選擇對提高卷積網(wǎng)絡模型的準確性與速度至關重要。激活函數(shù)如ReLU(Rectified Linear Unit)、Leaky-ReLU(Leaky Rectified Linear Unit)、Swish和Hard-Swish等已廣泛使用在各種目標檢測模型中。Leaky-ReLU激活函數(shù)是在ReLU的基礎上引入修正項,使得輸出負值的信息不會全部丟失,緩解了深度神經(jīng)網(wǎng)絡梯度為0的現(xiàn)象。Leaky-ReLU激活函數(shù)的表達式如式(4)所示。
式中l(wèi)為修正參數(shù),取l=0.01。
相關研究表明使用Swish函數(shù)代替ReLU、Leaky-ReLU等激活函數(shù)將顯著提高卷積網(wǎng)絡的性能,但Swish函數(shù)存在次冪運算增加了計算成本,其表達式如式(5)所示。
式中s為修正系數(shù),取s=1。
為平衡網(wǎng)絡性能與檢測速度,主干網(wǎng)絡中使用Swish激活函數(shù)以保證主干網(wǎng)絡具有良好的特征提取性能,特征融合網(wǎng)絡中使用Leaky-ReLU激活函數(shù)以提高網(wǎng)絡檢測速度。
試驗硬件平臺為Dell工作站,處理器型號為英特爾Xeon E5-1620,內(nèi)存32GB,顯卡型號為Nvidia GeForce RTX 2080Ti。操作系統(tǒng)為Ubuntu18.04,深度學習框架采用Pytorch1.2,Python3.6。
本研究在網(wǎng)絡訓練中采用自適應動量估計法更新參數(shù),輸入圖像為640×640像素,權重衰減設為5×10-4,動量因子設為0.937,學習率衰減采用預熱訓練與余弦退火組合的方式,更新公式如式(6)所示。
式中t為訓練總輪數(shù),取t=400;warm為預熱訓練總輪數(shù),取warm=3;cos為使用余弦退火方法訓練總輪數(shù),取cos=385;cur為當前訓練輪數(shù),每完成一個周期的訓練自增1;t為當前訓練輪數(shù)的學習率;max為學習率最大值,取max=2.5×10-4;min為學習率最小值,取min=2.5×10-6;為預熱訓練衰減率,取=0.1。
為了評價Lad-YXNet的準確性、魯棒性和穩(wěn)定性,在相同的數(shù)據(jù)集下訓練了其他四種目標檢測網(wǎng)絡,包括SSD,YOLOV4-Tiny,YOLOV5-Lite,YOLOX-Tiny。
本研究通過平均精度AP、1值、召回率、精度和檢測速度對模型檢測效果進行評估,計算公式如式(7)~(10)所示。檢測速度為模型檢測單張圖像需要消耗的時間。
式中P表示模型正確檢測蘋果的數(shù)量,P表示模型將背景檢測成蘋果的數(shù)量,N表示模型未檢測出蘋果的數(shù)量,AP表示以召回率為橫坐標,精度為縱坐標繪制的-曲線與坐標軸間的面積,能綜合反映模型性能。
訓練過程中,Lad-YXNet與YOLOX-Tiny模型在訓練集與驗證集上的損失曲線如圖5所示。
圖5 Lad-YXNet與YOLOX-Tiny模型訓練損失曲線
由損失曲線可知,兩種模型的損失值均能快速收斂,Lad-YXNet的在訓練集與測試集上的收斂速度更快,且在測試集上的損失較低。這表明Lad-YXNet比YOLOX-Tiny模型具有更強的學習蘋果特征的能力。訓練完成后,Lad-YXNet與YOLOX-Tiny模型的-曲線如圖6所示,Lad-YXNet的-曲線與坐標軸間的面積比YOLOX-Tiny模型更大,表明Lad-YXNet較YOLOX-Tiny具有更好的綜合性能。
圖6 Lad-YXNet與YOLOX-Tiny模型P-R曲線
本研究在相同的數(shù)據(jù)集下訓練了SSD、YOLOV4-Tiny、YOLOV5-Lite、YOLOX-Tiny和Lad-YXNet模型。在測試模型檢測時間時,SSD模型輸入圖像為512×512像素,其余模型輸入圖像均采用640×640像素,結果如表1所示。
表1 5種模型蘋果檢測性能對比
注:P表示模型正確檢測蘋果的數(shù)量,P表示模型將背景檢測成蘋果的數(shù)量,N表示模型未檢測出蘋果的數(shù)量。
Note:Pis the number of apples correctly detected by the model.Pis the number of apples that model background errors.Nis the number of apples missed by the model.
由表1可知,Lad-YXNet的平均精度AP、1值和召回率均高于其他模型。Lad-YXNet的平均精度AP、1值和召回率較SSD、YOLOV4-Tiny、YOLOV5-Lite和YOLOX-Tiny模型均有提升,其中平均精度AP分別提高了3.10個百分點、2.02個百分點、2.00個百分點和0.51個百分點。SSD模型的檢測精度最高,為93.45%,但模型漏檢蘋果個數(shù)最高,約為Lad-YXNet的2倍,且模型大小為95 MB,不利于部署到嵌入式設備中;YOLOV4-Tiny模型檢測一張圖像的時間最短,為6.87 ms,但檢測精度最低,為89.62%,將背景誤檢測成蘋果的個數(shù)最高,較Lad-YXNet多117。Lad-YXNet檢測一幅圖像的時間為10.06 ms,較YOLOX-Tiny提高了20.03%,Lad-YXNet模型大小為16.6 MB,較YOLOX-Tiny減少了18.23%。這表明Lad-YXNet很好地平衡了模型大小、檢測精度和檢測速度,為部署在嵌入式設備中提供了基礎。
5種模型在兩種光照環(huán)境下(逆光與順光)對兩種蘋果(煙富與蜜脆)的檢測結果如圖7所示。由圖7可知SSD模型在逆光和順光環(huán)境下漏檢蘋果數(shù)(模型未檢測出目標蘋果的個數(shù))最多,表明在面對密集的檢測目標和光照變化的環(huán)境,SSD模型易產(chǎn)生漏檢情況。YOLOV4-Tiny模型對密集目標檢測能力有所提升,但不易檢測出被枝葉嚴重遮擋的小目標。YOLOX-Tiny模型在逆光環(huán)境下漏檢蘋果數(shù)為7,誤檢蘋果數(shù)(模型將背景錯誤檢測成蘋果)為1,在順光環(huán)境下漏檢蘋果數(shù)少于YOLOV5-Lite,相較于SSD、YOLOV4-Tiny模型能很好地適應不同光照條件,同時能檢測出相互遮擋的果實與被枝葉遮擋的果實。Lad-YXNet模型繼承了YOLOX-Tiny的優(yōu)點并減少了漏檢與誤檢,在逆光和順光環(huán)境下漏檢蘋果數(shù)分別為4與1,進一步提升了蘋果的檢測性能。
本研究根據(jù)光照環(huán)境將測試集圖像分為逆光圖像與順光圖像,其中逆光圖像114張,蘋果數(shù)為1 578;順光圖像126張,蘋果數(shù)為3 948。根據(jù)果實品種分為“煙富”與“蜜脆”,其中“煙富”72張,蘋果數(shù)為1 546;“蜜脆”168張,蘋果數(shù)為3 980。順光圖像中“富士”約占38.10%,逆光圖像中“富士”約占21.05%。Lad-YXNet模型在兩種光照環(huán)境下(逆光與順光)對兩種蘋果(煙富與蜜脆)的檢測結果如表2所示。
注:藍色框為5種模型的檢測框,黃色方框與圓框分別為手動標注的漏檢框與誤檢框。
表2 Lad-YXNet模型在不同圖像上的檢測結果
由表2可知,“蜜脆”的1值較“煙富”高2.33個百分點。“煙富”蘋果樹冠較大,枝葉更豐茂,果實受遮擋嚴重,導致“煙富”更不易被檢測。在逆光環(huán)境的1值較順光環(huán)境高1.64個百分點,這與“富士”在順光圖像占比較高有關。
激活函數(shù)是增加卷積網(wǎng)絡非線性能力的重要組成部分,本研究選擇3種激活函數(shù)(Swish,Hard-Swish,Leaky-ReLU)探究主干和特征融合網(wǎng)絡采用不同激活函數(shù)時對蘋果檢測模型性能的影響,試驗結果如表3所示。
由表3可知,不同激活函數(shù)的組合方式對檢測模型的檢測精度與速度均有較大的影響。與Swish激活函數(shù)相比,當主干網(wǎng)絡采用Leaky-ReLU激活函數(shù)時,檢測模型的平均精度偏低;而當Leaky-ReLU作為特征融合網(wǎng)絡的激活函數(shù)時,檢測模型都具有較高的平均檢測精度。當主干采用Swish激活函數(shù),檢測模型的1值均高于Hard-Swish激活函數(shù),特征融合網(wǎng)絡采用Leaky-ReLU激活函數(shù)具有最高的平均檢測精度為94.88%和最高的1值為90.40%。與Leaky-ReLU相比,主干或特征融合層采用Hard-Swish激活函數(shù)時雖能將檢測精度提升至92.38%,但會明顯降低模型檢測速度與召回率,當主干和特征融合都采用Hard-Swish激活函數(shù)時,模型的檢測時間最長,為12.51 ms。由此可見,本研究所提出的蘋果檢測模型Lad-YXNet主干采用Swish激活函數(shù),特征融合網(wǎng)絡采用Leaky-ReLU激活函數(shù),檢測模型具有較好綜合性能與檢測速度。
表3 不同激活函數(shù)的蘋果檢測模型性能對比
YOLOX-Tiny與Lad-YXNet模型在相同的數(shù)據(jù)集和不同在線增強方法上進行訓練,在測試集上檢測結果如圖8所示。
注:①取消圖像隨機翻轉;②取消圖像隨機色域變換;③取消圖像長寬隨機扭曲;④取消圖像隨機組合;⑤原始的在線Mosaic增強處理。
由圖8可知,與完整的在線Mosaic增強方法相比,去除圖像隨機翻轉與圖像長寬隨機扭曲后,Lad-YXNet模型的平均檢測精度AP分別下降了0.89個百分點與3.81個百分點;1值分別下降了0.91個百分點和1.95個百分點;精度分別下降2.21個百分點和2.99個百分點。YOLOX-Tiny模型具有類似的規(guī)律性,其中去除圖像長寬隨機扭曲對兩種模型的綜合性能影響較大,表明了圖像長寬隨機扭曲對提高模型綜合檢測性能貢獻較高。與在線Mosaic增強方法相比,去除隨機圖像組合后Lad-YXNet與YOLOX-Tiny模型的檢測精度雖有提升,但平均精度AP分別下降了0.56個百分點和0.07個百分點,1值分別下降了0.68個百分點和1.15個百分點,召回率分別下降了2.35個百分點和4.49個百分點,表明訓練過程中使用隨機圖像組合有助于提升模型泛化能力;去除圖像隨機色域變換后Lad-YXNet與YOLOX-Tiny模型的平均精度AP分別增加了0.38個百分點與0.10個百分點;精度分別增加了0.85個百分點與0.84個百分點,表明在線Mosaic增強方法中的圖像隨機色域變換不利于兩個模型的訓練。顏色是蘋果的主要特征之一,圖像隨機色域變換會改變圖像中蘋果的顏色,模型不易提取蘋果的顏色特征,導致兩個的模型的綜合檢測性能下降。因此,在訓練蘋果檢測模型時,去除圖像隨機色域變換有利于提取蘋果的顏色特征。
為進一步探究視覺注意力機制在卷積網(wǎng)絡中的有效性,本研究進行了去除Lad-YXNet中兩種視覺注意力模塊和交換Lad-YXNet中兩種視覺注意力模塊位置的試驗。試驗結果如表4所示。
表4 不同視覺注意力模塊的蘋果檢測模型對比
由表4可知,與Lad-YXNet模型相比,交換了兩種注意力機制位置的模型精度僅提高了0.04個百分點,而、1、AP分別降低了0.78個百分點、0.39個百分點和0.13個百分點。不使用注意力模塊的模型比Lad-YXNet的、、1、AP值分別降低了1.15個百分點、0.64個百分點、0.89個百分點和0.46個百分點。當交換兩種注意力模塊的位置時,模型的綜合性能指標下降,表明Lad-YXNet模型中兩種注意力模塊的位置設計合理。當不使用注意力模塊時,模型的檢測時間降低為9.41 ms,但檢測精度與綜合性能均有不同程度的下降,其中檢測精度降低最為明顯。與不使用注意力模塊相比,僅使用SA模塊與僅使用ECA模塊的、、1、AP值均有所提升,其中僅使用ECA模塊的1與AP值分別提高了0.75個百分點與0.24個百分點,表明引入SA與ECA兩種注意力模塊增強了Lad-YXNet提取蘋果特征的能力,有利于提升模型的綜合檢測精度。
目前,CNN檢測物體的過程缺乏相應的解釋,對卷積網(wǎng)絡學習的物體特征的理解有限,這阻礙了模型結構的進一步優(yōu)化。有研究者采用特征可視化技術來提高模型的可解釋性,即將不同卷積層輸出的特征轉換為可視化圖像,通過可視化圖像展現(xiàn)出不同卷積層提取的特征[21,40]。本研究采用特征圖可視化技術提取了Lad-YXNet的主干、特征融合網(wǎng)絡和檢測網(wǎng)絡的特征圖,探究Lad-YXNet檢測蘋果的過程。將主干網(wǎng)絡與特征融合網(wǎng)絡3個尺寸(80×80、40×40和20×20)的輸出特征映射為相同尺寸(640×640)的偽彩圖,并與原圖像進行疊加,即得到輸出特征的可視化圖像,其可視化示例如圖9所示。
注:顏色越紅表示卷積層的輸出值越大,下同。
由圖9可知,主干網(wǎng)絡80×80的淺層特征圖提取細粒度強,提取到雜亂的背景信息。隨著網(wǎng)絡的加深,主干網(wǎng)絡40×40的特征圖中的特征逐漸變得模糊和抽象。由主干網(wǎng)絡20×20的特征圖可知,深層網(wǎng)絡更注重提取果實所在的圖像區(qū)域。主干提取的特征送入特征融合網(wǎng)絡將圖像特征進一步融合,以增強模型的特征提取性能。特征融合網(wǎng)絡的特征圖如圖9所示。經(jīng)過特征融合網(wǎng)絡,80×80和40×40的特征圖中分別突出顯示了蘋果背景區(qū)域與蘋果所在區(qū)域。由特征融合網(wǎng)絡20×20的特征圖可知,隨著特征融合的加強,提取的特征包括平滑的背景信息與果實抽象特征,這有助于在檢測階段過濾背景信息,突顯目標果實。
檢測網(wǎng)絡輸出的特征圖可視化如圖10所示。由圖10可知,大量背景信息已被去除,并在特征圖中顯現(xiàn)出蘋果形態(tài)。由此可見,Lad-YXNet模型的主干網(wǎng)絡提取果實與背景的顏色與紋理等特征,并確定果實和背景所在區(qū)域;隨著網(wǎng)絡深度的增加與特征的融合,進一步提取果實的抽象特征并平滑背景信息;最終在檢測網(wǎng)絡中融合所有特征信息,去除背景信息并顯現(xiàn)蘋果形態(tài)。本研究從特征提取的角度,展現(xiàn)了Lad-YXNet在復雜自然環(huán)境下檢測蘋果所提取的特征,解釋了卷積網(wǎng)絡檢測果實的過程。
圖10 Lad-YXNet的檢測網(wǎng)絡特征圖可視化示例
本研究為提高復雜果園環(huán)境下蘋果檢測性能、速度并降低模型大小,引入ECA(Efficient Channel Attention)和SA(Shuffle Attention)兩種輕量化視覺注意力模塊,提出一種適用復雜果園環(huán)境下輕量化蘋果檢測網(wǎng)絡Lad-YXNet(Lightweight apple detection YOLOX-Tiny Network),較好地平衡了蘋果檢測模型的檢測速度、精度和模型大小。本研究主要結論如下:
1)Lad-YXNet的平均精度AP為94.88%,與SSD、YOLOV4-Tiny、YOLOV5-Lite和YOLOX-Tiny模型相比,分別提高了3.10個百分點、2.02個百分點、2.00個百分點和0.51個百分點。Lad-YXNet檢測一幅圖像的時間為10.06 ms,較YOLOX-Tiny減少了20.03%,Lad-YXNet模型大小為16.6 MB,較YOLOX-Tiny減少了18.23%,為部署在嵌入式設備中提供了基礎。
2)為探究在線Mosaic增強方法對模型訓練的有效性,本研究設計了消融試驗。消融試驗結果表明,圖像長寬隨機扭曲對提高模型綜合檢測性能貢獻較高,圖像隨機色域變換由于改變訓練集中蘋果的顏色,使模型檢測綜合性能下降。因此使用在線Mosaic增強方法時,去除圖像隨機色域變換更有利于模型的訓練。
[1] 王丹丹,宋懷波,何東健. 蘋果采摘機器人視覺系統(tǒng)研究進展[J]. 農(nóng)業(yè)工程學報,2017,33(10):59-69.
Wang Dandan, Song Huaibo, He Dongjian. Research advance on vision system of apple picking robot[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2017, 33(10): 59-69. (in Chinese with English abstract)
[2] 苑進. 選擇性收獲機器人技術研究進展與分析[J]. 農(nóng)業(yè)機械學報,2020,51(9):1-17.
Yuan Jin. Research progress analysis of robotics selective harvesting technologies[J]. Transactions of the Chinese Society for Agricultural Machinery, 2020, 51(9): 1-17. (in Chinese with English abstract)
[3] Verbiest R, Ruysen K, Vanwalleghem T, et al. Automation and robotics in the cultivation of pome fruit: Where do we stand today?[J]. Journal of Field Robotics, 2020, 38(4): 513-531.
[4] Wang Z, Xun Y, Wang Y, et al. Review of smart robots for fruit and vegetable picking in agriculture[J]. International Journal of Agricultural and Biological Engineering, 2022, 15(1): 33-54.
[5] 楊睿,王應寬,王寶濟. 基于Web of Science文獻計量學和知識圖譜的農(nóng)業(yè)機器人進展與趨勢[J]. 農(nóng)業(yè)工程學報,2021,38(1):53-62.
Yang Rui, Wang Yingkuan, Wang Baoji. Progress and trend of agricultural robots based on WoS bibliometrics and knowledge graph[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2021, 38(1): 53-62. (in Chinese with English abstract)
[6] Montoya-Cavero L-E, Díaz De León Torres R, Gómez-Espinosa A, et al. Vision systems for harvesting robots: Produce detection and localization[J]. Computers and Electronics in Agriculture, 2022, 192: 106562.
[7] 鄭太雄,江明哲,馮明馳. 基于視覺的采摘機器人目標識別與定位方法研究綜述[J]. 儀器儀表學報,2021,42(9):28-51.
Zheng Taixiong, Jiang Mingzhe, Feng Mingchi. Vision based target recognition and location for picking robot: A review[J]. Chinese Journal of Scientific Instrument, 2021, 42(9): 28-51. (in Chinese with English abstract)
[8] Fu L, Gao F, Wu J, et al. Application of consumer RGB-D cameras for fruit detection and localization in field: A critical review[J]. Computers and Electronics in Agriculture, 2020, 177: 105687.
[9] 呂石磊,盧思華,李震,等. 基于改進YOLOv3-LITE輕量級神經(jīng)網(wǎng)絡的柑橘識別方法[J]. 農(nóng)業(yè)工程學報,2019,35(17):205-214.
Lü Shilei, Lu Sihua, Li Zhen, et al. Orange recognition method using 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)
[10] 龍潔花,趙春江,林森,等. 改進Mask R-CNN的溫室環(huán)境下不同成熟度番茄果實分割方法[J]. 農(nóng)業(yè)工程學報,2021,37(18):100-108.
Long Jiehua, Zhao Chunjiang, Lin Sen, et al. Segmentation method of the tomato fruits with different maturities under greenhouse environment based on improved Mask R-CNN[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2021, 37(18): 100-108. (in Chinese with English abstract)
[11] 孫建桐,孫意凡,趙然,等. 基于幾何形態(tài)學與迭代隨機圓的番茄識別方法[J]. 農(nóng)業(yè)機械學報,2019,50(S1):22-26,61.
Sun Jiantong, Sun Yifan, Zhao Ran, et al. Tomato recognition method based on iterative random circle and geometric morphology[J]. Transactions of the Chinese Society for Agricultural Machinery, 2019, 50(S1): 22-26, 61. (in Chinese with English abstract)
[12] Fu L, Feng Y, Wu J, et al. Fast and accurate detection of kiwifruit in orchard using improved YOLOv3-tiny model[J]. Precision Agriculture, 2021, 22(3): 754-776.
[13] 傅隆生,馮亞利,Elkamil T,等. 基于卷積神經(jīng)網(wǎng)絡的田間多簇獼猴桃圖像識別方法[J]. 農(nóng)業(yè)工程學報,2018,34(2):205-211.
Fu Longsheng, Feng Yali, Elkamil T, et al. Image recognition method of multi-cluster kiwifruit in field based on convolutional neural networks[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2018, 34(2): 205-211. (in Chinese with English abstract)
[14] Zheng C, Chen P, Pang J, et al. A mango picking vision algorithm on instance segmentation and key point detection from RGB images in an open orchard[J]. Biosystems Engineering, 2021, 206: 32-54.
[15] Lu S, Chen W, Zhang X, et al. Canopy-attention- YOLOv4-based immature/mature apple fruit detection on dense-foliage tree architectures for early crop load estimation[J]. Computers and Electronics in Agriculture, 2022, 193: 106696.
[16] 劉天真,滕桂法,苑迎春,等. 基于改進YOLO v3的自然場景下冬棗果實識別方法[J]. 農(nóng)業(yè)機械學報,2021,52(5):17-25.
Liu Tianzhen, Teng Guifa, Yuan Yingchun, et al. Winter jujube fruit recognition method based on improved YOLO v3 under natural scene[J]. Transactions of the Chinese Society for Agricultural Machinery, 2021, 52(5): 17-25. (in Chinese with English abstract)
[17] Kang H, Chen C. Fast implementation of real-time fruit detection in apple orchards using deep learning [J]. Computers and Electronics in Agriculture, 2020, 168: 105108.
[18] Jiang M, Song L, Wang Y, et al. Fusion of the YOLOv4 network model and visual attention mechanism to detect low-quality young apples in a complex environment[J]. Precision Agriculture, 2022, 23(2): 559-577.
[19] Wang X, Tang J, Whitty M. Data-centric analysis of on-tree fruit detection: Experiments with deep learning[J]. Computers and Electronics in Agriculture, 2022, 194: 106748.
[20] Wu G, Li B, Zhu Q, et al. Using color and 3D geometry features to segment fruit point cloud and improve fruit recognition accuracy[J]. Computers and Electronics in Agriculture, 2020, 174: 105475.
[21] Bai Y, Guo Y, Zhang Q, et al. Multi-network fusion algorithm with transfer learning for green cucumber segmentation and recognition under complex natural environment[J]. Computers and Electronics in Agriculture, 2022, 194: 106789.
[22] Wang Z, Jin L, Wang S, et al. Apple stem/calyx real-time recognition using YOLO-v5 algorithm for fruit automatic loading system[J]. Postharvest Biology and Technology, 2022, 185: 111808.
[23] Wang D, He D. Channel pruned YOLO V5s-based deep learning approach for rapid and accurate apple fruitlet detection before fruit thinning[J]. Biosystems Engineering, 2021, 210: 271-281.
[24] Roy A M, Bose R, Bhaduri J. A fast accurate fine-grain object detection model based on YOLOv4 deep neural network[J]. Neural Computing and Applications, 2022, 34(5): 3895-3921.
[25] 張政馗,龐為光,謝文靜,等. 面向實時應用的深度學習研究綜述[J]. 軟件學報,2020,31(9):2654-2677.
Zhang Zhengkui, Pang Weiguang, Xie Wenjing, et al. Deep learning for real-time applications: A survey[J]. Journal of Software, 2020, 31(9): 2654-2677. (in Chinese with English abstract)
[26] 葛道輝,李洪升,張亮,等. 輕量級神經(jīng)網(wǎng)絡架構綜述[J]. 軟件學報,2020,31(9):2627-2653.
Ge Daohui, Li Hongsheng, Zhang Liang, et al. Survey of lightweight neural network[J]. Journal of Software, 2020, 31(9): 2627-2653. (in Chinese with English abstract)
[27] Tian H, Wang T, Liu Y, et al. Computer vision technology in agricultural automation: A review[J]. Information Processing in Agriculture, 2020, 7(1): 1-19.
[28] Tang Y, Chen M, Wang C, et al. Recognition and localization methods for vision-based fruit picking robots: A Review[J]. Frontiers in Plant Science, 2020, 11(510): 1-17.
[29] Gao F, Fu L, Zhang X, et al. Multi-class fruit-on-plant detection for apple in SNAP system using Faster R-CNN[J]. Computers and Electronics in Agriculture, 2020, 176: 105634.
[30] 閆建偉,趙源,張樂偉,等. 改進Faster-RCNN自然環(huán)境下識別刺梨果實[J]. 農(nóng)業(yè)工程學報,2019,35(18):143-150.
Yan Jianwei, Zhao Yuan, Zhang Lewei, et al. Recognition of Rosa roxbunghii in natural environment based on improved Faster RCNN[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2019, 35(18): 143-150. (in Chinese with English abstract)
[31] Ge Z, Liu S, Wang F, et al. YOLOX: Exceeding YOLO series in 2021[C]//Kuala Lumpur: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2021.
[32] Tian Z, Shen C, Chen H, et al. Fully convolutional one-stage object detection[C]//Seoul: Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2019: 9626-9635.
[33] 龍燕,李南南,高研,等. 基于改進FCOS網(wǎng)絡的自然環(huán)境下蘋果檢測[J]. 農(nóng)業(yè)工程學報,2021,37(12):307-313.
Long Yan, Li Nannan, Gao Yan, et al. Apple fruit detection under natural condition using improved FCOS network[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2021, 37(12): 307-313. (in Chinese with English abstract)
[34] 趙德安,吳任迪,劉曉洋,等. 基于YOLO深度卷積神經(jīng)網(wǎng)絡的復雜背景下機器人采摘蘋果定位[J]. 農(nóng)業(yè)工程學報,2019,35(3):164-173.
Zhao Dean, Wu Rendi, Liu Xiaoyang, et al. Apple positioning based on YOLO deep convolutional neural network for picking robot in complex background[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2019, 35(3): 164-173. (in Chinese with English abstract)
[35] Yan B, Fan P, Lei X, et al. A Real-time apple targets detection method for picking robot based on improved YOLOv5[J]. Remote Sensing, 2021, 13(9): 1619.
[36] 宋懷波,江梅,王云飛,等. 融合卷積神經(jīng)網(wǎng)絡與視覺注意機制的蘋果幼果高效檢測方法[J]. 農(nóng)業(yè)工程學報,2021,37(9):297-303.
Song Huaibo, Jiang Mei, Wang Yunfei, et al. Efficient detection method for young apples based on the fusion of convolutional neural network and visual attention mechanism[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2021, 37(9): 297-303. (in Chinese with English abstract)
[37] Jocher G. YOLOV5[EB/OL]. (2020-06-26) [2022-03-10]. https://github.com/ultralytics/yolov5.
[38] Wang Q, Wu B, Zhu P, et al. ECA-Net: Efficient channel attention for deep convolutional neural networks[C]// Seattle: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2020.
[39] Zhang Q, Yang Y. SA-Net: Shuffle attention for deep convolutional neural networks[C]// Toronto: Proceedings of the IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2021: 2235-2239.
[40] Selvaraju R R, Cogswell M, Das A, et al. Grad-CAM: Visual explanations from deep networks via gradient-based localization[C]//Venice: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2019.
Fusion of the lightweight network and visual attention mechanism to detect apples in orchard environment
Hu Guangrui, Zhou Jianguo, Chen Chao, Li Chuanlin, Sun Lijuan, Chen Yu, Zhang Shuo, Chen Jun※
(,,712100)
Apple harvesting is a highly seasonal and labor-intensive activity in modern agriculture. Fortunately, a harvesting robot is of great significance to improve the productivity and quality of apples, further alleviating the labor shortage in orchards. Among them, the detection model of the harvesting robot is also required to accurately and rapidly detect the target apples in the complex and changing orchard environment. It is a high demand for the small size to be deployed in the embedded device. This study aims to improve the speed and comprehensive performance of apple detection in a complex orchard environment. A Lightweight apple detection YOLOX-Tiny Network (Lad-YXNet) model was proposed to reduce the size of the original model. Some images of “Yanfu” and “Micui” apples were obtained during the apple harvest season in 2021. The images were uniformly clipped to the 1024×1024 pixels. As such, 1 200 images were selected to make the dataset, including the fruits with shaded branches and leaves, fruit clusters, varying degrees of illumination, blurred motion, and high density. This model was then used to optimize the topology of the single-stage detection network YOLOX-Tiny. Two lightweight visual attention modules were added to the model, including Efficient Channel Attention (ECA), and Shuffle Attention (SA). The Shuffle attention and double convolution layer (SDCLayer) was constructed to extract the background and fruit features. Swish and Leaky Rectified Linear Unit (Leaky-ReLU) was identified as the activation functions for the backbone and feature fusion network. A series of ablation experiments were carried out to evaluate the effectiveness of Mosaic enhancement in the model training. The average precision of the Lad-YXNet model decreased by 0.89 percent and 3.81 percent, respectively, after removing random image flipping and random image length width distortion. The1-socre also decreased by 0.91 percent and 1.95 percent, respectively, where the precision decreased by 2.21 percent and 2.99 percent, respectively. There was a similar regularity of the YOLOX-Tiny model. After removing the image random combination, the average precision of the Lad-YXNet and the YOLOX-Tiny model decreased by 0.56 percent and 0.07 percent, the1-socre decreased by 0.68 percent and 1.15 percent, as well as the recall rate decreased by 2.35 percent and 4.49 percent, respectively. The results showed that the random distortion of image length and width greatly contributed to the performance of model detection. But the random color gamut transformation of the image decreased the performance of model detection, due to the change of apple color in the training set. Two specific tests were conducted to explore the effectiveness of visual attention mechanisms in convolution networks. Specifically, one was to remove the visual attention modules from the Lad-YXNet, and another was to exchange the position of visual attention modules from the Lad-YXNet. Compared with the Lad-YXNet, the precision of the improved model to exchange the position of the visual attention modules only increased by 0.04 percent, while the recall,1-socre, and average precision decreased by 0.78 percent, 0.39 percent, and 0.13 percent, respectively. The precision, recall,1-socre, and average precision of the models without the attention module were reduced by 1.15 percent, 0.64 percent, 0.89 percent, and 0.46 percent, respectively, compared with the Lad-YXNet. Consequently, the SA and ECA enhanced the ability of the Lad-YXNet to extract the apple features, in order to improve the comprehensive detection accuracy of the model. The main feature maps of Lad-YXNet's backbone, feature fusion, and detection network were extracted by the feature visualization technology. A systematic investigation was made to determine the process of detecting apples with the Lad-YXNet in the complex natural environment, particularly from the point of feature extraction. As such, improved interpretability was achieved in the apple detection with the Lad-YXNet model. The Lad-YXNet was trained to be an average accuracy of 94.88% in the test set, which was 3.10 percent, 2.02 percent, 2.00 percent, and 0.51 percent higher than SSD, YOLOV4-Tiny, YOLOV5-Lite, and YOLOX-Tiny models, respectively. The detection time of an image was achieved in 10.06 ms with a model size of 16.6 MB, which was 20.03% and 18.23% less than YOLOX-Tiny, respectively. Therefore, the Lad-YXNet was well balanced with the size, precision, and speed of the apple detection model. The finding can provide a theoretical basis to accurately and quickly detect the apples for the harvesting robot in the complex orchard environment.
image processing; visualization; apple detection; harvesting robot; convolutional network; visual attention mechanism
10.11975/j.issn.1002-6819.2022.19.015
TP691.4
A
1002-6819(2022)-19-0131-12
胡廣銳,周建國,陳超,等. 融合輕量化網(wǎng)絡與注意力機制的果園環(huán)境下蘋果檢測方法[J]. 農(nóng)業(yè)工程學報,2022,38(19):131-142.doi:10.11975/j.issn.1002-6819.2022.19.015 http://www.tcsae.org
Hu Guangrui, Zhou Jianguo, Chen Chao, et al.Fusion of the lightweight network and visual attention mechanism to detect apples in orchard environment[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2022, 38(19): 131-142. (in Chinese with English abstract) doi:10.11975/j.issn.1002-6819.2022.19.015 http://www.tcsae.org
2022-06-01
2022-09-29
國家自然科學基金項目(No. 32272001);國家重點研發(fā)計劃項目(No. 2018YFD0701102);國家自然科學基金項目(No. 32001428)
胡廣銳,博士生,研究方向為智能化果園裝備。Email:2017050952@nwsuaf.edu.cn
陳軍,博士,教授,博士生導師,研究方向為智能化農(nóng)業(yè)裝備。Email:chenjun_jdxy@nwsuaf.edu.cn