涂淑琴,黃 磊,梁 云,黃正鑫,李承桀,劉曉龍
基于JDE模型的群養生豬多目標跟蹤
涂淑琴,黃 磊,梁 云※,黃正鑫,李承桀,劉曉龍
(華南農業大學數學與信息學院,廣州 510642)
為實現群養生豬在不同場景下(白天與黑夜,豬只稀疏與稠密)的豬只個體準確檢測與實時跟蹤,該研究提出一種聯合檢測與跟蹤(Joint Detection and Embedding,JDE)模型。首先利用特征提取模塊對輸入視頻序列提取不同尺度的圖像特征,產生3個預測頭,預測頭通過多任務協同學習輸出3個分支,分別為分類信息、邊界框回歸信息和外觀信息。3種信息在數據關聯模塊進行處理,其中分類信息和邊界框回歸信息輸出檢測框的位置,結合外觀信息,通過包含卡爾曼濾波和匈牙利算法的數據關聯算法輸出視頻序列。試驗結果表明,本文JDE模型在公開數據集和自建數據集的總體檢測平均精度均值(mean Average Precision,mAP)為92.9%,多目標跟蹤精度(Multiple Object Tracking Accuracy,MOTA)為83.9%,IDF1得分為79.6%,每秒傳輸幀數(Frames Per Second,FPS)為73.9幀/s。在公開數據集中,對比目標檢測和跟蹤模塊分離(Separate Detection and Embedding,SDE)模型,本文JDE模型在MOTA提升0.5個百分點的基礎上,FPS提升340%,解決了采用SDE模型多目標跟蹤實時性不足問題。對比TransTrack模型,本文JDE模型的MOTA和IDF1分別提升10.4個百分點和6.6個百分點,FPS提升324%。實現養殖環境下的群養生豬多目標實時跟蹤,可為大規模生豬養殖的精準管理提供技術支持。
目標檢測;目標跟蹤;聯合檢測與跟蹤;數據關聯;群養生豬
生豬產業一直是國內畜牧業的支柱產業,其發展關系到國家食物安全、社會穩定及國民經濟的協調發展。生豬養殖業正朝著規模化、專業化、智能化和精細化發展。目前,在勞動力短缺的情況下,智能與精準畜牧業對幫助農戶實現畜牧業規模化生產具有重要作用[1]。通過視頻攝像頭,采用計算機視覺技術獲取每頭豬每天的體重變化、運動軌跡、飲食情況和行為變化等數據,監測豬只行為和健康,預測豬只個體異常情況,實現生豬生產過程的精確控制[2],對提高生豬的福利具有重要價值[3]。因此,采用多目標跟蹤技術,準確跟蹤群養生豬中的個體,識別豬只行為變化,對提高農場的智能化管理水平和生產力具有重要意義。
目前,國內外研究者在禽畜跟蹤的方面進行很多研究。有些研究者通過給禽畜穿戴自動跟蹤設備實現跟蹤禽畜。如Zambelis等[4]使用耳標加速計對飼養奶牛的喂養和活動行為進行觀察。Giovanetti等[5]將三軸加速度計傳感器安裝在羊的身體上,然后測量羊在牧場的行為。Krista等[6]將運動能耗儀安裝在母羊的項圈上,以此評估綿羊行為活動水平。這些方法在某些情況下對于禽畜的觀察是可行的,但是,使用可穿戴自動跟蹤設備會影響禽畜的行為,嚴重情況下會影響其自由活動,降低動物福利。另外,大量可穿戴自動跟蹤設備會增加生產的成本。
近年來,使用計算機視覺技術進行豬只日常行為監控取得了多方面的研究成果,例如豬的攻擊行為[7-10]、飲食飲水行為[11-15]、母豬行為檢測[16]、攀爬和玩耍行為[17-18],豬只姿態識別[11,19-22],早期發現呼吸道疾病[23-24]。
多目標跟蹤的性能在很大程度上取決于其檢測目標的性能。傳統的目標檢測算法,如Zhao等[25]使用背景減法來檢測移動奶牛目標,Zhang等[26]提出了一種基于光流估計的運動目標檢測方法,于欣等[27]提出一種基于光流法與特征統計的魚群異常行為檢測方法,這些算法在速度和準確性方面不能滿足實際場景要求。目前,基于深度學習的目標檢測算法不斷完善,其準確性和速度都有顯著提升,能夠滿足實際應用。深度學習的目標檢測算法主要分為一階段和二階段算法。二階段算法在檢測時首先生成候選區域,之后對候選區域進行分類和校準,準確率相對較高,典型的有R-CNN(Region Convolution Neural Network)算法[28],Fast R-CNN算法[29],Faster R-CNN算法[30]。如王浩等[31]利用改進的Faster R-CNN算法定位群養生豬的圈內位置,識別準確率可達96.7%。一階段算法在檢測時無需生成候選區域,直接對目標類別和邊界進行回歸,如YOLO系列算法[32-35]。如金耀等[36]利用YOLOv3算法[32]對生豬個體進行識別,對母豬的識別精度均值達95.16%。相較于二階段算法,一階段算法的檢測速度更快。
在多目標跟蹤方面,現有多目標跟蹤算法的應用大多是基于檢測跟蹤(Tracking by Detection,TBD)范式,即SDE(Separate Detection and Embedding)模型,先用檢測器輸出檢測結果,再用基于卡爾曼濾波和匈牙利算法的后端追蹤優化算法進行跟蹤,如使用SORT(Simple Online and Realtime Tracking)[37]、DeepSORT[38]算法來提取目標的表觀特征進行多目標重識別進行跟蹤,其中DeepSORT算法在SORT算法的基礎上,通過提取深度表觀特征提高了多目標的跟蹤效果。如張宏鳴等[39]利用改進YOLOv3算法結合DeepSORT算法進行肉牛多目標跟蹤,張偉等[40]利用基于CenterNet結合優化DeepSORT算法進行斷奶仔豬目標跟蹤。上述研究的算法是兩階段過程,先檢測再跟蹤,目標檢測和跟蹤模塊分離導致跟蹤速度慢,達不到實時跟蹤效果。
本研究將目標檢測與跟蹤融合在一個過程中,提出一種實時、非接觸的群養生豬多目標跟蹤JDE(Joint Detection and Embedding)算法,通過一個端對端網絡同時輸出多目標的分類信息、邊界框回歸信息和外觀信息,以減少算法的運行時間,達到實時跟蹤的效果。在相同的公開試驗數據集中將JDE算法與SDE算法進行對比,以驗證本文算法的速度,同時與TransTrack算法[41]對比,進一步驗證本文算法的準確性與實時性。
基于JDE的群養生豬多目標跟蹤算法如圖1所示。該算法以群養生豬視頻序列為輸入;采用特征提取模塊提取不同尺度的圖像特征,得到3個不同尺度特征圖的預測頭,輸入數據關聯模塊;預測頭的分類信息和邊界框回歸信息用于得到檢測框的位置結果,在跟蹤部分,利用外觀信息結合檢測框,通過包含卡爾曼濾波和匈牙利算法的數據關聯算法,輸出檢測與跟蹤的視頻序列結果。

圖1 基于JDE的群養生豬多目標跟蹤算法
特征提取模塊由Darknet-53網絡和多尺度模塊特征金字塔構成,如圖2所示。Darknet-53網絡包括6個卷積層和5個殘差層,其中卷積層和殘差層的大小和數量見表1。卷積層由卷積層、批量歸一化層和激活函數層共同構成,殘差層由一個1×1大小的卷積層和3×3大小的卷積層構成。
特征金字塔采用同一圖像的不同尺度來檢測目標,有助于檢測小目標。本文特征金字塔利用Darknet-53網絡中的第3、4和5個殘差塊進行特征融合,產生3個輸出預測頭,分別輸出分類信息、邊界框回歸信息和外觀信息。

圖2 特征提取網絡結構

表1 Darknet-53網絡結構參數
本文JDE算法的學習目標為多任務協同學習,其總體損失L為分類損失、邊界框回歸損失和外觀信息學習損失之和,如式(1)所示。

式中ω、ω、ω分別為分類、邊界框回歸和外觀信息學習的權重值,L為分類損失,L為外觀信息學習損失,其中損失均為交叉熵損失,計算公式如式(2)所示。

式中為類別的數量,為樣本數,y為符號函數(0或1),為類別數。如果樣本的真實類別等于,則y=1,否則y=0。p為觀測樣本屬于類別的預測概率。
L為邊界框回歸損失,為smooth-L1損失,計算公式如式(3)所示。

式中為輸入樣本。
算法采用基于任務的不確定性計算加權系數,最終自動加權的損失L如式(4)所示。

式中、、為每個個體損失的任務依賴的不確定性,為可學習參數。
模型通過分類損失和回歸損失學習到的分類信息和回歸信息生成檢測框對視頻幀中每個豬只進行定位,外觀學習損失得到的外觀信息包括每個豬只的外觀特征,二者通過數據關聯,對每頭豬分配ID,實現多目標跟蹤。豬只多目標跟蹤的具體實現流程如圖3所示,具體步驟如下:
1)創建初始跟蹤軌跡。對于給定的視頻幀序列,第一幀將根據視頻幀序列的檢測結果利用卡爾曼濾波對軌跡進行初始化,并維護一個跟蹤軌跡池,包含所有可能與預測值相關聯的軌跡。
2)數據關聯。對于下一幀的輸出結果,利用卡爾曼濾波進行軌跡預測,計算出預測值與軌跡池之間的運動親和信息和外觀親和信息,其中外觀親和信息采用余弦相似度計算,運動親和信息采用馬氏距離計算,然后利用匈牙利算法的代價矩陣進行軌跡分配。
3)更新軌跡。如果出現在2幀內的預測值沒有被分配給任何一個軌跡池中的軌跡,那么這條軌跡將被初始化為新的軌跡,然后根據卡爾曼濾波進行所有匹配軌跡狀態的更新,如果某條軌跡在連續30幀內沒有被更新,則終止該軌跡,所有視頻幀處理完畢后,輸出視頻幀序列。

圖3 卡爾曼濾波結合匈牙利算法的豬只目標跟蹤流程
本試驗采用的數據集包括2部分:一部分為Psota等[42]提供的公開數據集,包含不同日齡、大小、數量和不同環境的豬只視頻,其中,視頻1、2、4、5為保育豬(3~10周齡),視頻6、7、8、9、10為早期育成豬(11~18周齡),視頻12、15為晚期育成豬(19~26周齡)。根據時間段的不同將豬只的活動水平分為3類:白天的高活動、白天(或夜晚)的中等活動、白天(或夜晚)的低活動,詳表2。同時,根據人工觀察,將豬只個數較多且黏連遮擋情況較為嚴重的視頻定義為稠密視頻,反之為稀疏視頻,見表2。另外一部分為自建數據集[43]。兩部分數據集均為俯拍視頻片段,由于攝像頭高度及焦距的影響,不可避免拍攝到豬圈外的物品,因此,在試驗中采用視頻裁剪方法將視角固定為豬圈內,以減少外部環境的影響。

表2 公開數據集
首先,利用FFmpeg軟件完成視頻剪輯,從中截取稠密、稀疏、白天、黑夜的視頻,2部分數據集共21個視頻。然后利用DarkLabel軟件對數據進行標注,其中,公開數據集11個視頻,共3 300張圖像,自建數據集10個視頻,共1 000張圖像。部分數據集如圖4所示。為對比不同場景下模型的檢測和跟蹤能力,選取不同的視頻進行模型訓練和測試,參與訓練的視頻不參與測試。本文共設計3個試驗,其中試驗1以視頻4、6、12為測試集,這些視頻均為白天稠密,其余視頻為訓練集。試驗2以視頻2、5、8為測試集,其中視頻5、8分別為夜晚稀疏與夜晚稠密,視頻2為白天稀疏,其余視頻為訓練集。試驗3以自建數據集的7個視頻為測試集(視頻3、11、14、16、18、19、21),另外3個視頻為測試集(視頻13、17、20)。其中豬只活動水平定義如下:根據視頻的人工觀察結果,在白天(10:00-12:30)豬只的飲食和玩耍等行為較頻繁,此時間段定義為豬只白天的高活動水平。在白天(12:30-17:00)或夜晚(17:00-20:00)豬只的飲食和玩耍等行為沒有白天(10:00-12:30)高,此時間段定義為白天或夜晚的中等活動水平。在白天(7:00-10:00)或夜晚(20:00-7:00)豬只的飲食和玩耍等行為較少,躺臥行為較多,此時間段定義為白天或夜晚的低活動水平。

圖4 部分數據集
本文所有試驗在同一計算機上完成,硬件配置為12th Gen Intel(R) i9-12900KF CPU,NVIDIA GeForce RTX 3090 GPU,32GB內存,64位Linux操作系統,Pytorch版本1.7.1,Python版本3.8,CUDA版本11.0。
訓練過程中設置圖片尺寸為416×416(像素),批處理大小(Batchsize)設置為32,初始學習率(Learning Rate)為0.01,動量(Momentum)設置為0.9,共訓練30個時期(Epoch),使用隨機梯度下降法(Stochastic Gradient Descent, SGD)進行優化,保存訓練過程中精度最高的模型參數進行模型測試。
選擇精確率(Precision,),召回率(Recall,)和平均精度均值(mean Average Precision,mAP)3個指標評判模型的檢測性能。精確率衡量模型對豬只目標檢測的精確程度,如式(5),其中DTP是檢測正確的目標數量,DFP是檢測錯誤的目標數量。

召回率衡量模型對豬只目標檢測的覆蓋能力,如式(6),其中DFN是漏檢的目標數量。

平均精度均值是對檢測的類別對應的精度均值取平均,如式(7),其中()是以召回率為自變量,精確率為因變量的函數。

選擇多目標跟蹤精度(Multiple Object Tracking Accuracy,MOTA)和IDF1得分(ID F1 Score)作為多目標跟蹤的主要評價指標。MOTA衡量跟蹤器檢測目標和保持軌跡跟蹤的性能。IDF1為引入跟蹤目標標號ID的F1值,由于引入了跟蹤目標標號ID,IDF1更重視目標的軌跡跟蹤能力。MOTA計算公式如式(8)所示。

式中FP為在第幀中目標誤報總數(假陽性);FN為在第幀目標丟失總數(假陰性);IDS為在第幀中跟蹤目標標號ID發生切換的次數;g是時刻觀測到的目標數量。
IDF1計算公式如式(9)所示。

式中IDTP為ID保持不變的情況下正確跟蹤到的目標總數,IDFP為ID保持不變的情況下跟蹤錯誤的目標總數,IDFN為ID保持不變的情況下跟蹤目標丟失總數。
此外,其他相關指標還有碎片數(Fragmentation,FM)、主要跟蹤到的目標(Mostly Tracked Target,MT)(被跟蹤到的軌跡比例大于80%)、主要丟失目標(Mostly Lost Target,ML)(被跟蹤到的軌跡比例小于20%)、部分跟蹤到的目標(Partially Tracked Target,PT)(被跟蹤到的軌跡比例不大于80%且不小于20%)、一條跟蹤軌跡改變目標標號ID的次數(Identity Switches,IDS)以及平均每秒傳輸幀數(Frames Per Second,FPS)。
本文對群養生豬目標跟蹤模型性能的分析選擇MOTA、IDF1和FPS作為主要評價指標,輔助以FP、FN、FM、IDS、MT、ML等指標進行模型的性能評估。其中MOTA、IDF1、MT和FPS數值越高模型性能越好,FP、FN、FM、IDS和ML數值越低模型性能越好。
JDE模型的檢測結果見表3。可以發現,本文算法在公開數據集中的mAP平均值達到92.5%,測試集2、4、6、8、12視頻的mAP分別為96.2%、95.6%、96.1%、98.0%、92.2%。對于視頻5,其mAP為77.0%,主要原因是該視頻的場景與其他視頻相比差異較大,增加了目標檢測的難度;在自建數據集中的mAP平均值達到93.8%,總體平均mAP達到92.9%,表明本文JDE算法對于不同復雜場景具有較好的檢測能力。

表3 JDE模型的目標檢測試驗結果
JDE模型的跟蹤結果如表4所示。可以發現,在公開數據集中,視頻2、4、5、6、8、12的MOTA分別為91.4%、82.5%、59.2%、90.8%、94.2%、74.4%,平均MOTA為82.1%,在自建數據集中,視頻13、17、20的MOTA分別為84.4%、88.1%、90.2%,平均MOTA為87.6%,總體平均MOTA為83.9%。不同視頻的MOTA產生差別的主要原因是每個視頻的環境不同,如視頻背景、白天、黑夜、稀疏、稠密和豬只的活動狀態,在視頻背景干擾嚴重、豬只活動較為頻繁(如飲食,玩耍等行為)情況下,MOTA相對較低,在夜晚視頻8中,豬只活動較少且背景對豬只的干擾較小,MOTA最高,為94.2%。在夜晚視頻5中,視頻背景干擾嚴重,MOTA較低,為59.2%,根據IDF1和FPS可以看出,本文JDE模型在公開數據集中的IDF1平均值為77.7%,FPS平均值為74.26幀/s,在自建數據集中的IDF1平均值為83.5%,FPS平均值為73.19幀/s,總體平均IDF1值為79.6%,總體平均FPS值為73.9幀/s。可以發現,本文JDE模型對豬只目標的ID跟蹤精度和FPS均達到較高水平,能夠實現實際養殖環境下的群養豬多目標快速實時跟蹤,為實際群養豬養殖場的精準管理提供技術支持。

表4 JDE模型的多目標跟蹤試驗結果
豬只白天稀疏和稠密2種分布情況的可視化分析結果如圖5所示。

注:圖中數字表示豬只ID號,算法中第一幀圖像的檢測會對每頭豬只分配一個從1遞增的ID號,例如(1、2、3…),對后續幀進行檢測和跟蹤時,由于豬只的移動,可能會對某個豬只的ID識別錯誤,此時把這個豬只識別為新的豬只,則該豬只的ID號就變為錯誤的ID號,直至所有視頻幀處理完畢。下同。
對于豬只白天稀疏的視頻2,本文算法可以準確地檢測和跟蹤每一只豬,如圖5a。但是,對豬只白天稠密且豬只粘連遮擋情況較為嚴重的視頻4存在漏檢,如圖5b中箭頭標識的豬。這說明在豬只白天稠密的環境下,由于豬只目標出現漏檢,從而影響了算法的跟蹤性能。
對豬只白天和夜晚情況下的可視化分析如圖6所示,可以發現,在豬只白天稠密且有遮擋的情況下,本文JDE模型可以很好地跟蹤到每一只豬,如圖6a。在夜晚視頻背景比較黑暗且豬只密集有遮擋的情況下,JDE模型也可以準確地跟蹤每一只豬,如圖6b。但在豬只夜晚稀疏的視頻5中,由于所有豬只都分布于豬圈的左方,且視頻背景和豬只顏色相似,這使得檢測器和跟蹤器較難檢測和跟蹤這些豬只目標,出現豬只漏檢的情況,如圖6c所示。總體上,本文JDE模型對于不同場景下的群養生豬多目標跟蹤達到較好水平。

圖6 豬只白天和夜晚不同分布情況的的可視化分析結果
為驗證本文JDE模型的多目標跟蹤性能,與經典的SDE模型進行對比試驗。SDE檢測器與本文JDE模型相同,跟蹤器使用DeepSORT,采用相同的公開數據集進行訓練和測試,試驗結果如表5所示。可以發現,SDE模型的MOTA和IDF1平均值分別為81.6%和78.2%,對比表4,本文JDE模型的MOTA提升了0.5個百分點。從總體性能指標來看,本文JDE模型的MT、PT、ML、FN、MOTA和FPS指標均優于SDE模型。在速度方面,SDE模型的FPS均值為16.88幀/s,本文JDE模型的FPS均值達到74.26幀/s。總體來說,二者在跟蹤準確度和跟蹤精度接近情況下,本文JDE模型的視頻處理速度比SDE模型提升了340%,這對于實現養殖場長時間群養生豬視頻的實時多目標跟蹤有重要意義。

表5 SDE模型的多目標跟蹤試驗結果
選取部分數據集進行可視化分析,結果如圖7所示,在豬只夜晚稠密的視頻8中,SDE模型存在錯檢情況,如圖7b左下角第二頭豬出現2個跟蹤框,而本文JDE模型沒有錯檢情況,如圖7a所示。在豬只白天稠密的視頻12中,由于豬只密集躺在一起,檢測器較容易發生漏檢,如圖7a、7b,JDE模型漏檢2頭豬,SDE模型漏檢3頭豬,JDE比SDE模型具有更好的檢測跟蹤結果。

圖7 JDE與SDE模型對豬只不同分布情況的可視化結果對比
此外,文獻[40]采用基于SDE模型對豬只目標檢測的平均精度均值達99.0%,多目標跟蹤精度MOTA為96.8%,但文獻[40]的數據場景單一,無法應對其他場景。盡管包括白天和黑夜(光照變化),但訓練和測試場景相同。本文數據集包含不同情況下的場景,共有11個視頻場景,各個場景環境不同,豬只大小也不同,訓練和測試場景完全不相同。
為進一步驗證本文算法在群養豬多目標跟蹤方面的性能,與TransTrack模型在相同的公開數據集上進行對比試驗,試驗結果如表6所示。TransTrack模型的平均MOTA、IDF1和FPS分別為71.7%、71.1%和17.53幀/s,與表4結果比較發現,本文JDE模型比TransTrack模型的MOTA和IDF1分別提升10.4和6.6個百分點,同時FPS提升324%。從性能指標MT、PT、ML、FP、FN、IDS、FM、MOTA、IDF1和FPS的數值對比可以發現,本文JDE模型性能均優于TransTrack模型。

表6 TransTrack模型的試驗結果
對2種模型的跟蹤結果選取部分數據進行可視化分析,結果如圖8所示。對比發現,相較于TransTrack模型,JDE模型對豬只嚴重遮擋情況有更好的檢測和跟蹤能力,如圖8a。而TransTrack模型在豬只嚴重遮擋情況下,會出現豬只的漏檢或者是豬只追蹤的缺失,如圖8b。可以看出,本文算法在不同場景中,檢測框更加貼合豬只目標,對于嚴重遮擋的豬只目標具有更強的檢測跟蹤能力。

圖8 JDE與TransTrack模型的可視化結果對比
1)本文JDE模型在二階段目標檢測和跟蹤分離框架的基礎上進行改進,在輸出檢測框的同時,給網絡增加目標外觀信息學習損失對應的輸出分支,實現檢測和跟蹤的多任務協同學習,實現聯合目標檢測和跟蹤。
2)本文制作了2個數據集,分別為公開數據集和自建數據集。其數據場景復雜多樣,各個場景的豬只大小、數量、日齡和光照條件都不同,并在公開數據集中與SDE模型和TransTrack模型進行了對比。
3)試驗結果表明,本文JDE模型在2個數據集的總體平均精度均值mAP為92.9%,平均多目標跟蹤精度MOTA為83.9%,平均IDF1得分為79.6%,平均每秒檢測幀數FPS為73.9。在公開數據集中與TransTrack模型進行對比,本文JDE模型的MOTA和IDF1分別提升10.4和6.6個百分點,FPS提升324%。在公開數據集中與SDE模型進行對比,本文JDE模型在MOTA和IDF1的數值接近下,FPS提升340%,解決了SDE模型目標檢測和跟蹤模塊分離導致目標跟蹤速度慢的問題,這對于養殖場群養生豬長時間視頻的實時多目標跟蹤具有重要意義。
[1] Rowe E, Dawkins M S, Gebhardt-Henrich S G A. Systematic review of precision livestock farming in the poultry sector: Is Technology focussed on improving bird welfare?[J]. Animals (Basel), 2019, 9(9): 614.
[2] Cowton J, Kyriazakis I, Plotz T , et al. A combined deep learning GRU-autoencoder for the early detection of respiratory disease in pigs using multiple environmental sensors[J]. Sensors (Basel), 2018, 18(8): 2521.
[3] Sébastien F, Alain N R, Benoit L. Rethinking environment control strategy of confined animal housing systems through precision livestock farming[J]. Biosystems Engineering, 2017, 155: 96-123.
[4] Zambelis A, Wolfe T, Vasseur E. Technical note: Validation of an ear-tag accelerometer to identify feeding and activity behaviors of tiestall-housed dairy cattle[J]. Journal of Dairy Science, 2019, 102(5): 4536-4540.
[5] Giovanetti V, Decandia M, Molle G, et al. Automatic classification system for grazing, ruminating and resting behaviour of dairy sheep using a tri-axial accelerometer[J]. Livestock Science, 2017, 196: 42-48.
[6] Krista M M, Elizabeth A S, Carlos J B R, et al. Technical note: Validation of an automatic recording system to assess behavioural activity level in sheep (Ovis aries)[J]. Small Ruminant Research, 2015, 127: 92-96.
[7] Chen C, Zhu W X, Ma C H, et al. Image motion feature extraction for recognition of aggressive behaviors among group-housed pigs[J]. Computers and Electronics in Agriculture, 2017, 142: 380-387.
[8] Chen C, Zhu W X, Guo Y Z, et al. A kinetic energy model based on machine vision for recognition of aggressive behaviours among group-housed pigs[J]. Livestock Science, 2018, 218: 70-78.
[9] Chen C, Zhu W X, Liu D, et al. Detection of aggressive behaviours in pigs using a RealSence depth sensor[J]. Computers and Electronics in Agriculture, 2019, 166: 105003.
[10] Chen C, Zhu W X, Steibel J, et al. Recognition of aggressive episodes of pigs based on convolutional neural network and long short-term memory[J]. Computers and Electronics in Agriculture, 2020, 169: 105166.
[11] Alameer A, Kyriazakis I, Bacardit J. Automated recognition of postures and drinking behaviour for the detection of compromised health in pigs[J]. Scientific Reports, 2020, 10(1): 13665.
[12] Lao F, Brown B, Stinn J P, et al. Automatic recognition of lactating sow behaviors through depth image processing[J]. Computers and Electronics in Agriculture, 2016, 125: 56-62.
[13] Zhu W X, Guo Y Z, Jiao P P, et al. Recognition and drinking behaviour analysis of individual pigs based on machine vision[J]. Livestock Science, 2017, 205: 129-136.
[14] Leonard S M, Xin H, Brown-Brandl T M, et al. Development and application of an image acquisition system for characterizing sow behaviors in farrowing stalls[J]. Computers and Electronics in Agriculture, 2019, 163: 104866.
[15] Yang A Q, Huang H S, Zheng B, et al. An automatic recognition framework for sow daily behaviours based on motion and image analyses[J]. Biosystems Engineering, 2020, 192: 56-71.
[16] Zhang Y Q, Cai J H, Xiao D Q, et al. Real-time sow behavior detection based on deep learning[J]. Computers and Electronics in Agriculture, 2019, 163: 104884.
[17] Nasirahmadi A, Hensel O, Edwards S, et al. Automatic detection of mounting behaviours among pigs using image analysis[J]. Computers and Electronics in Agriculture, 2016, 124: 295-302.
[18] Li D, Chen Y F, Zhang K F, et al. Mounting beaviour recognition for pigs based on deep learning[J]. Sensors (Basel), 2019, 19(22): 4924.
[19] Nasirahmadi A, Sturm B, Olsson A, et al. Automatic scoring of lateral and sternal lying posture in grouped pigs using image processing and support vector machine[J]. Computers and Electronics in Agriculture, 2019, 156: 475-481.
[20] Zheng C, Zhu X M, Yang X F, et al. Automatic recognition of lactating sow postures from depth images by deep learning detector[J]. Computers and Electronics in Agriculture, 2018, 147: 51-63.
[21] Zhu X M, Chen C X, Zheng B, et al. Automatic recognition of lactating sow postures by refined two-stream RGB-D faster R-CNN[J]. Biosystems Engineering, 2020, 189: 116-132.
[22] Zheng C, Yang X F, Zhu X M, et al. Automatic posture change analysis of lactating sows by action localisation and tube optimisation from untrimmed depth videos[J]. Biosystems Engineering, 2020, 194: 227-250.
[23] Jorquera-Chavez M, Fuentes S, Dunshea F R, et al. Remotely sensed imagery for early detection of respiratory disease in pigs: A pilot study[J]. Animals (Basel), 2020, 10(3): 451.
[24] Jorquera-Chavez M, Fuentes S, Dunshea F R, et al. Using imagery and computer vision as remote monitoring methods for early detection of respiratory disease in pigs[J]. Computers and Electronics in Agriculture, 2021, 187: 106283.
[25] Zhao K X, He D J. Target detection method for moving cows based on background subtraction[J]. International Journal of Agricultural and Biological Engineering, 2015, 8(1): 42-49.
[26] Zhang Y G, Zheng J, Zhang C, et al. An effective motion object detection method using optical flow estimation under a moving camera[J]. Journal of Visual Communication and Image Representation, 2018, 55: 215-228.
[27] 于欣,侯曉嬌,盧煥達,等. 基于光流法與特征統計的魚群異常行為檢測[J]. 農業工程學報,2014,30(2):162-168.
Yu Xin, Hou Xiaojiao, Lu Huanda, et al. Anomaly detection of fish school behavior based on features statistical and optical flow methods[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2014, 30(2): 162-168. (in Chinese with English abstract)
[28] Girshick R, Donahue J, Darrell T, et al. Rich feature hierarchies for accurate object detection and semantic segmentation[C]//Columbus, OH, USA, IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2014: 580-587.
[29] Girshick R. Fast R-CNN[C]// Santiago, Chile, IEEE International Conference on Computer Vision (ICCV), 2015: 1440-1448.
[30] Ren S Q, He K M, Girshick R, et al. Faster R-CNN: Towards real-time object detection with region proposal networks [J]. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2017, 39(6): 1137-1149.
[31] 王浩,曾雅瓊,裴宏亮,等. 改進 Faster R-CNN 的群養豬只圈內位置識別與應用[J]. 農業工程學報,2020,36(21):201-209.
Wang Hao, Zeng Yaqiong , Pei Hongliang, et al. Recognition and application of pigs’position in group pens based on improved Faster R-CNN[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2020, 36(21): 201-209. (in Chinese with English abstract)
[32] Redmon J, Farhadia A. YOLOv3: An incremental improvement [EB/OL]. 2018-04-08, https://pjreddie.com/media/files/papers/ YOLOv3.pdf.
[33] Redmon J, Divvala S, Girshick R, et al. You only look once: Unified, real-time object detection[C]//Las Vegas, NV, USA, Conference on Computer Vision and Pattern Recognition (CVPR), 2016: 779-788.
[34] Redmon J, Farhadi A. YOLO9000: Better,faster,stronger[C]//Honolulu, HI, USA, IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017: 7263-7271.
[35] Bochkovskiy A, Wang C Y, Liao H Y M. YOLOv4: Optimal speed and accuracy of object detection[EB/OL]. 2020-04-23, https://arxiv.org/pdf/2004.10934.pdf.
[36] 金耀,何秀文,萬世主,等. 基于YOLO v3的生豬個體識別方法[J]. 中國農機化學報,2021,42(2):178-183.
Jin Yao, He Xiuwen, Wan Shizhu, et al.Individual pig identification method based on YOLOv3[J]. Journal of Chinese Agricultural Mechanization, 2021, 42(2): 178-183. (in Chinese with English abstract)
[37] Bewley A, Ge Z Y, Ott L, et al. Simple online and realtime tracking[C]//Phoenix, Arizona, USA. IEEE International Conference on Image Processing (ICIP), 2016: 3464-3468.
[38] Wojke N, Bewley A, Paulus D. Simple online and realtime tracking with a deep association metric[C]//Beijing, China. IEEE International Conference on Image Processing (ICIP), 2017: 3645-3649.
[39] 張宏鳴,汪潤,董佩杰,等. 基于DeepSORT算法的肉牛多目標跟蹤方法[J]. 農業機械學報,2021,52(4):249-256.
Zhang Hongming, Wang Run, Dong Peijie, et al. Multi-object tracking method for beef cattle based on DeepSORT algorithm[J]. Transactions of the Chinese Society for Agricultural Machinery, 2021, 52(4): 249-256. (in Chinese with English abstract)
[40] 張偉,沈明霞,劉龍申,等. 基于CenterNet搭配優化DeepSORT算法的斷奶仔豬目標跟蹤方法研究[J]. 南京農業大學學報,2021,44(5):973-981.
Zhang Wei, Shen Mingxia, Liu Longshen, et al. Research on weaned piglet target tracking method based on CenterNet collocation optimized DeepSORT algorithm[J]. Journal of Nanjing Agricultural University, 2021, 44(5): 973-981. (in Chinese with English abstract)
[41] Sun P Z, Cao J K, Jiang Y, et al. TransTrack: Multiple object tracking with transformer[EB/OL]. 2021-05-04, https://arxiv.org/abs/2012.15460v1.
[42] Psota E T, Schmidt T, Mote B, et al. Long-term tracking of group-housed livestock using keypoint detection and MAP estimation for individual animal identification[J]. Sensors (Basel), 2020, 20(13): 3670.
[43] Tu S Q,Yuan W J,Liang Y,et al. Automatic detection and segmentation for group-housed pigs based on PigMS R-CNN[J]. Sensors (Basel), 2021, 21(9): 3251.
Multiple object tracking of group-housed pigs based on JDE model
Tu Shuqin, Huang Lei, Liang Yun※, Huang Zhengxin, Li Chengjie, Liu Xiaolong
(,,510642,)
Pig production has been always the pillar of the industrial livestock industry in China. Therefore, the pig industry is closely related to food safety, social stability, and the coordinated development of the national economy. An intelligent video surveillance can greatly contribute to the large-scale production of animal husbandry under labor shortage at present. It is very necessary to accurately track and identify the abnormal behavior of group-housed pigs in the breeding scene. Much effort has been focused on Multiple Object Tracking (MOT) for pig detection and tracking. Among them, two parts are included in the Tracking By Detection (TBD) paradigm, e.g., the Separate Detection and Embedding (SDE) model. Previously, the detector has been developed to detect pig objects. And then the tracking models have been selected for the pig tracking using Kalman filter and Hungarian (Sort or DeepSORT). The detection and association steps have been designed to increase the running and training time of the model in the dominant MOT strategy. Thus, real-time tracking cannot fully meet the requirement of the group-housed pigs. In this study, a Joint Detection and Embedding (JDE) model was proposed to automatically detect the pig objects and then track each one in the complex scenes (day or night, sparse or dense). The core of JDE model was to integrate the detector and the embedding model into a single network for the real-time MOT system. Specifically, the JDE model incorporated the appearance model into a single-shot detector. As such, the simultaneous output was performed on the corresponding appearance to improve the runtime and operational efficiency of the model. An overall loss of one multiple task learning loss was utilized in the JDE model. Three loss functions were included classification, box regression and appearance. Three merits were achieved after operations. Firstly, the multiple tasks learning loss was used to realize the object detection and appearance to be learned in a shared model, in order to reduce the amount of occupied memory. Secondly, the forward operation was computed using the multiple tasks loss at one time. The overall inference time was reduced to improve the efficiency of the MOT system. Thirdly, the performance of each prediction head was promoted to share the same set of low-level features and feature pyramid network architecture. Finally, the data association module was utilized to process the outputs of the detection and appearance head from the JDE, in order to produce the position prediction and ID tracking of multiple objects. The JDE model was validated on the special dataset under a variety of settings. The special dataset was also built with a total of 21 video segments and 4 300 images using the dark label video annotation software. Two types of datasets were obtained, where the public dataset contained 11 video sequences and 3 300 images, and the private dataset contained 10 video segments and 1 000 images. The experimental results show that the mean Average Precision (mAP), Multiple Object Tracking Accuracies (MOTA), IDF1 score, and FPS of the JDE on all test videos were 92.9%, 83.9%, 79.6%, and 73.9 frames/s, respectively. A comparison was also made with the SDE model and TransTrack method on the public dataset. The JDE model improved the FPS by 340%, and the MOTA by 0.5 percentage points in the same test dataset, compared with the SDE model. It infers the sufficient real-time performance of MOT using the JDE model. The MOTA, IDF1 metrics, and FPS of the JDE model was improved by 10.4 and 6.6 percentage points, and 324%, respectively, compared with the TransTrack model. The visual tracking demonstrated that the JDE model performed the best detection and tracking ability with the SDE and TransTrack models under the four scenarios, including the dense day, sparse day, dense night, and sparse night. The finding can also provide an effective and accurate detection for the rapid tracking of group-housed pigs in complex farming scenes.
object detection; object tracking; joint detection and tracking; data association; group-housed pigs
10.11975/j.issn.1002-6819.2022.17.020
TP391.4
A
1002-6819(2022)-17-0186-10
涂淑琴,黃磊,梁云,等. 基于JDE模型的群養生豬多目標跟蹤[J]. 農業工程學報,2022,38(17):186-195.doi:10.11975/j.issn.1002-6819.2022.17.020 http://www.tcsae.org
Tu Shuqin, Huang Lei, Liang Yun, et al. Multiple object tracking of group-housed pigs based on JDE model[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2022, 38(17): 186-195. (in Chinese with English abstract) doi:10.11975/j.issn.1002-6819.2022.17.020 http://www.tcsae.org
2022-04-19
2022-08-16
廣東省省級科技計劃項目(2019A050510034);廣州市重點科技計劃項目(202206010091);大學生創新創業大賽項目(202110564025)
涂淑琴,博士,講師,研究方向為圖像處理與計算機視覺。Email:tushuqin@163.com
梁云,博士,教授,研究方向為圖像處理與計算機視覺。Email:yliang@scau.edu.cn