Abstract:
Green lawns can play a crucial role in the landscape and ecological environments with the rapid urbanization in China. However, there is an ever-increasing demand for the daily maintenance of lawns. Among them, the heterogeneous weeds can often compete with the native grass for nutrients and growing space in lawns, leading to the low overall quality of urban greenery. The aesthetic appeal of the lawn can also be diminished after premature aging. Thereby, the accurate and rapid detection of the weed can be required for deep learning and computer vision. This study aims to improve the efficiency and accuracy of the detection of heterogeneous weeds in natural environments. A lightweight algorithm was also proposed using the original YOLOv8n model. Firstly, the deformable convolutional network v2 (DCNv2) was employed to combine with the c2f convolutional layers in the backbone network. The offsets were then introduced to enhance the feature extraction of the improved model. Different regular shapes of the heterogeneous weeds were captured after optimization. Additionally, a modulation mechanism was incorporated to control the contribution of each sampling point to the output. The precision and robustness were then improved to focus more on the target regions, thereby reducing the interference from background noise. Secondly, a bidirectional feature pyramid network (BiFPN) was introduced in the neck network. Multi-scale features were efficiently fused using bidirectional cross-scale connections and weighted feature fusion. The targets were detected at varying scales. Furthermore, the BiFPN significantly reduced the computational overhead, compared with the traditional feature pyramid network (FPN). The redundant connections were also eliminated to incorporate the lightweight weighting mechanisms. The efficiency and generalization of feature fusion were also improved after feature fusion. Lastly, the traditional intersection over union (IoU) loss function was replaced with the inner-IoU (inner intersection over union) loss function. The objective function of the bounding box regression was then optimized to learn the target location information, thereby improving the convergence speed and detection performance. More precise guidance was realized for the improved model. The experimental results show that the improved YOLOv8-LDB model reduced the number of parameters, the computational cost, and the model size by 32.7%, 13.6%, and 31.8%, respectively, compared with the original YOLOv8n. While the mean average precision (mAP) increased by 3.2 percentage points. The performance of the improved YOLOv8-LDB model was better than that of the seven commonly used network models (including Faster-RCNN, SSD, YOLOv5s, YOLOv5n, YOLOv7n, YOLOv10n, and YOLOv11n), in terms of the precision, parameter count, computational cost, and model size. The mean average precision was improved by 21.6, 9.6, 1.6, 7.7, 2.4, 4.1, and 3.3 percentage points, respectively. Additionally, the detection speed increased from 80.4 to 87.1 frames per second. The inference efficiency was also enhanced for the real-time detection of heterogeneous weeds in natural environments. The YOLOv8-LDB algorithm demonstrated superior performance across multiple metrics. Automatic sprayers and weeding robots can be integrated to realize variable-rate precision spraying and targeted weed control. The automation level of lawn management can also be further advanced in the future. The lightweight improved model can be expected to find wide applications in smart city greening and precision agriculture. The findings can also provide technical support to protect the sustainable ecological environment in urban areas.