Abstract:
As the negative impact of weeds on agricultural production becomes increasingly severe, efficient weed detection methods are crucial for promoting sustainable agricultural development. However, existing weed detection models still face challenges in terms of accuracy and efficiency. To address this issue, this paper, based on YOLOv5, introduced Knowledge Distillation techniques and integrated the “knowledge” from multiple-teacher models, aiming to enhance performance and real-time detection ability of the weed detection model. Firstly, a temperature coefficient-based soft voting mechanism for logits (TS_Logits) was proposed, which dynamically adjusted the distillation loss weights of the teacher models, effectively integrating the strengths of each teacher model. Meanwhile, a multi-teacher feature fusion method based on attention mechanisms (AT_Feature) was also proposed, which dynamically weighted key features and suppressed redundant information. In this paper, the open-source CottonWeedDet12 dataset was used, with data augmentation techniques applied for random expansion, ultimately obtaining
9210 weed images. These images were divided into training and validation sets in an 8:2 ratio, and a test set consisting of 554 actual weed images was also incorporated. Based on YOLOv5s, channel pruning techniques were applied to obtain a student model with a size of 2.9 MB, an F1-score (
F1) of 93.5%, and a mean Average Precision of validation set (mAP
val) of 95.9%. Meanwhile, YOLOv5s, YOLOv7 and YOLOv10s were used as teacher models, and three Logits-based knowledge distillation methods (KD, Luminet, and DKD) and ten Feature-based knowledge distillation methods (FitNet, AT, NST, PKT, RKD, VID, SemCKD, CWD, MGD, and FGD) were applied. The experimental results showed that the student model achieved the best performance when YOLOv5s was used as the teacher model, further proving that using the same model architecture facilitated knowledge transfer between the teacher and student models, thereby enhancing the distillation effect. Additionally, this study evaluated the effect of the TS_Logits and the AT_Feature on the student model performance. The TS_Logits, which combined the strengths of YOLOv5s and YOLOv7, significantly enhanced the student model performance, achieving an
F1 of 94.2% and a mAP
val of 96.4%. The AT_Feature significantly enhanced the student model performance by integrating features from the teacher models, generating richer feature maps. Specifically, MGD achieved an
F1 of 93.9% and a mAP of 96.4%; CWD achieved an
F1 of 94.2% and a mAP
val of 96.4%; and PKT achieved an
F1 of 94.3% and a mAP
val of 96.4%. After combining the TS_Logits and AT_Feature, the proposed YOLOv5s-MGD performed excellently in model accuracy and real-time detection performance. The model achieved an
F1 of 94.5%, a mAP
val of 96.8%, a mean Average Precision of test set (mAP
test) of 93.6%, a frame rate of 46.71 frames per second (FPS), a computational complexity of 4.1 giga floating point operations (GFLOPs), and a model size of 2.9 MB. Compared to YOLOv5s, YOLOv5s-MGD exhibited a decrease of only 0.9 percentage points in mAP
val, while the FPS increased by approximately 57.22%, computational complexity was reduced by about 74.38%, and the model size decreased by approximately 79.86%. Compared to YOLOv7, YOLOv5s-MGD showed a 1.3 percentage points decrease in mAP
val, but FPS increased by approximately 1076.57%, along with significant optimizations in computational complexity and model size. Compared to YOLOv10s, YOLOv5s-MGD had a 0.9 percentage points decrease in mAP
val, FPS increased by approximately 143.41%, computational complexity was reduced by about 83.27%, and the model size decreased by approximately 82.42%. In summary, YOLOv5s-MGD not only maintained high accuracy but also significantly improved detection speed, computational efficiency, and storage performance, making it well-suited for real-time deployment on resource-constrained devices. This model effectively addressed the challenges of weed detection and provided strong technical support for the development of modern agriculture.