Weed detection method and device based on hypergraph enhanced YOLOv11 framework
The weed detection method based on the hypergraph-enhanced YOLOv11 framework solves the problems of occlusion, geometric distortion and high-order topological relationships in weed detection in farmland environments, and achieves high-precision, real-time weed identification and spatial positioning, which is suitable for agricultural edge devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XINJIANG AIR & EARTH INTEGRATION LABORATORY TECHNOLOGY CO LTD
- Filing Date
- 2026-03-04
- Publication Date
- 2026-06-23
AI Technical Summary
Existing weed detection algorithms face challenges such as occlusion, geometric distortion, and the complexity of high-order topological relationships in real farmland environments, resulting in low detection accuracy and difficulty in meeting real-time and robustness requirements.
A weed detection method based on the hypergraph-enhanced YOLOv11 framework is adopted. By reconstructing the local-global collaborative backbone network, introducing a geometric adaptive module and a hypergraph-enhanced semantic neck, a high-order spatial topological feature fusion mechanism is constructed. The hypergraph computing module is used to capture high-order relationships, and a hybrid aggregation network is combined to filter background noise, so as to achieve accurate localization and differentiation of occluded targets.
It significantly improves detection accuracy (mAP50 reaches 91.16%), reduces false detection rate while maintaining real-time inference speed (89.74 FPS), and is suitable for resource-constrained agricultural edge devices, possessing high engineering application value.
Smart Images

Figure CN122265829A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of weed detection, and in particular to a weed detection method and apparatus based on the hypergraph-enhanced YOLOv11 framework, which is especially suitable for accurate weed identification and spatial localization in unstructured field environments. Background Technology
[0002] Weed overgrowth is a key problem causing yield losses in current agricultural production, and its damage often exceeds that of pests and diseases combined. Utilizing intelligent, high-precision weed detection technology for targeted weed control in modern agriculture can not only reduce the use of chemical pesticides but also promote the sustainable development of agricultural ecosystems. Developing a weed detection algorithm is of paramount strategic importance.
[0003] With the rapid iteration of machine vision technology, the YOLO (You Only Look Once) series of object detection algorithms based on deep learning have been widely used in real-time detection tasks of agricultural robots. However, when these existing algorithms are placed in real, unstructured, and complex field environments, their robustness and adaptability still face many technical bottlenecks.
[0004] First, in real farmland environments, the occlusion between crops and weeds blurs the edges of targets, making it difficult for traditional fixed convolutional kernels to effectively extract the incomplete features of occluded targets, leading to missed detections. At the same time, weeds at different growth stages exhibit highly irregular geometric distortions and scale spans in morphology and scale, which places higher demands on the model's multi-scale perception and deformation adaptation capabilities. Finally, the spatial topological relationships between targets in farmland scenes are complex, and traditional architectures often ignore high-order semantic associations, making it difficult to distinguish the semantic boundaries of targets in densely overlapping scenes.
[0005] In summary, how to effectively overcome occlusion interference, non-rigid geometric deformation, and lack of high-order topological features in complex backgrounds while ensuring that the model meets the real-time requirements of edge devices is a key technical challenge that urgently needs to be addressed to improve the performance of weed detection in fields. Summary of the Invention
[0006] This invention provides a weed detection method and apparatus based on the hypergraph-enhanced YOLOv11 framework. This invention addresses the problem of low detection accuracy in existing weed detection models in complex farmland scenarios due to insufficient global context awareness, weak geometric deformation representation capabilities, and lack of high-order topological relationships. Details are described below:
[0007] Firstly, a weed detection method based on the hypergraph-enhanced YOLOv11 framework, the method comprising:
[0008] Based on the YOLOv11 baseline network, the local-global collaborative backbone network is reconstructed to obtain the first optimized network;
[0009] The neck network is reconstructed into a hypergraph-enhanced semantic neck to establish a high-order spatial topological feature fusion mechanism and obtain a second optimized network;
[0010] The second optimized network was used as the final enhanced detection model, and field weeds were detected based on this enhanced detection model.
[0011] The enhanced detection model was comprehensively validated using the constructed dataset and multiple public datasets; the validated enhanced detection model was then used for weed detection.
[0012] The first optimized network is:
[0013] In the shallow layers of the backbone network, a moving inverted residual structure is set up, and depthwise separable convolution is used to preserve the small edge features of weeds.
[0014] In the deeper stages of the main structure, a mobile visual transformation module is introduced to establish a global perception field that transcends local areas;
[0015] In the deep layer (p5) of the backbone network, a geometrically adaptive residual module is designed. While retaining the inverted residual structure, the 3×3 static depth convolution is replaced with deformable convolution, and the receptive field offset is adjusted adaptively.
[0016] The second optimized network is:
[0017] Construct a multi-scale semantic collection layer to force the multi-layer features of the backbone network from shallow to deep to be aligned to a uniform scale;
[0018] The cascaded hypergraph computation module maps aligned pixels to hypergraph vertices for higher-order relation inference;
[0019] The hybrid aggregation network is integrated as a post-filter for hypergraph computation, and the background noise interference introduced during the hypergraph aggregation process is adaptively filtered using a multi-branch architecture.
[0020] The input flows from top to bottom along the backbone network, passing through the standard convolution module, the moving inverted residual module, the moving visual transformation module, and the geometrically adaptive residual module in sequence to capture deformation features.
[0021] In this process, the second optimization network explicitly uses average pooling layers with step sizes of 8×8, 4×4, and 2×2 to perform large-span dimensionality reduction for the shallow features P1, P2, and P3, respectively.
[0022] For the terminal P5 feature, nearest neighbor interpolation upsampling alignment is used. The five features are finally spliced along the channel to construct a full-scale feature tensor that simultaneously contains the micro-texture of the seedling stage and the macro-morphology of the mature stage. The full-scale feature tensor is used as the enhanced input for subsequent hypergraph computation.
[0023] The hypergraph computation module utilizes hypergraph theory to model high-order complex relationships between pixels.
[0024] The method cascades a hybrid aggregation network after the hypergraph computing nodes to construct a noise-resistant filtering mechanism for topological features;
[0025] The hybrid aggregation network is cascaded and integrated as a post-feature of the hypergraph, employing a multi-branch parallel architecture:
[0026] Branch 1 uses 1×1 convolutions without activation functions to transmit hypergraph structure information; Branch 2 uses 3×3 depthwise convolutions to compensate for local spatial neighborhood cues; Branch 3 extracts nonlinear high-order semantics and filters irrelevant background by stacking bottleneck layers.
[0027] By combining hypergraphs and aggregations in a cascaded structure, multi-scale receptive fields are used to perform weighted correction on the high-order topological relationships captured by the hypergraph.
[0028] In a second aspect, a weed detection device based on the hypergraph-enhanced YOLOv11 framework, the device comprising: a processor and a memory, the memory storing program instructions, the processor calling the program instructions stored in the memory to cause the device to perform the method described in any of the first aspects.
[0029] Third aspect, a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the method described in any one of the first aspects.
[0030] The beneficial effects of the technical solution provided by this invention are:
[0031] 1. This invention uses local-global collaborative feature extraction to extract the backbone. By integrating the MobileViT (Mobile Vision Transform) module, it achieves long-range dependency capture, effectively making up for the limitations of traditional convolution in environmental context perception. This enables the model to achieve accurate localization based on the spatial distribution characteristics of weeds and surrounding crops, and solves the problem of context loss in complex backgrounds.
[0032] 2. This invention introduces the MV2_DCN (Geometric Adaptive Residual) module into the deep layer of the trunk, and uses the adaptive spatial offset of deformable convolution DCNv3 to accurately capture the non-rigid geometric distortion features of weeds, which significantly alleviates the feature misalignment problem caused by the irregular shape of weeds and the difference in growth stage, and improves the robustness of feature representation.
[0033] 3. This invention constructs a hypergraph-enhanced semantic neck and uses hypergraph computation to represent the high-order spatial topological relationship between targets. It breaks through the limitations of traditional binary association modeling, can effectively extract the edge topological logic of occluded targets, and clearly distinguish the boundaries of crops and weeds that occlude each other in densely overlapping scenes in the feature space, thus greatly reducing the false detection rate.
[0034] 4. The model training and evaluation method used in this invention is trained on a self-built TWD (Typical Weed Dataset) dataset that realistically recreates extreme working conditions, and validated on public datasets such as HRWD and MWS. Experiments show that MDH-YOLO significantly improves detection accuracy (mAP50 reaches 91.16%) while maintaining real-time inference speed (89.74 FPS). It achieves performance superior to large-size models with extremely low parameter count (2.76 M), making it particularly suitable for deployment of resource-constrained agricultural edge devices and possessing extremely high engineering application value. Attached Figure Description
[0035] Figure 1 This is a flowchart of a weed detection method based on the hypergraph augmentation YOLOv11 framework;
[0036] Figure 2 Example images of some samples from self-built TWD data under different lighting and occlusion conditions;
[0037] Figure 3 This is a schematic diagram of the overall architecture of the MDH-YOLO weed detection algorithm;
[0038] Figure 4 This is a schematic diagram of the main feature extraction module;
[0039] Figure 5 This is a detailed structural diagram of the MobileViTBlock module;
[0040] Figure 6 This is a schematic diagram of the structure of the multi-scale semantic collection layer;
[0041] Figure 7 This is a detailed structural diagram of the hybrid aggregation network (MANet);
[0042] Figure 8 A visual diagram comparing the detection results of the MDH-YOLO model and the benchmark model in typical scenarios. Detailed Implementation
[0043] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below.
[0044] To address the bottlenecks in existing deep learning weed detection algorithms when facing complex farmland environments due to severe occlusion, drastic geometric distortion, and complex spatial dependencies, this invention proposes an enhanced detection model, MDH-YOLO (Hypergraph-Enhanced YOLO). Using YOLOv11 as a baseline, this model significantly improves target perception capabilities in harsh environments by reconstructing a local-global collaborative backbone, introducing a geometrically adaptive module, and constructing a hypergraph-enhanced semantic neck.
[0045] Example 1
[0046] like Figure 1 As shown, this invention provides a weed detection method based on the hypergraph-enhanced YOLOv11 framework. This method significantly improves the overall performance of the model through a series of systematic optimization steps and module designs. In particular, the introduction of a local-global collaborative feature extraction backbone enables simultaneous modeling of local detail textures and global dependencies. Simultaneously, it combines an enhanced feature fusion neck that integrates hypergraph computation and semantic collection, effectively distinguishing semantic boundaries between densely occluded targets. The method includes the following steps:
[0047] Step 101: Collect and construct a typical weed dataset (TWD) for model training;
[0048] To ensure the model can adapt to real and varied agricultural environments, this embodiment of the invention collected images in typical cotton and corn planting areas. The dataset covers 10 typical weeds, including amaranth, purslane, and kochia. The image collection covered the entire life cycle of the weeds from seedling to maturity, and recorded various natural lighting conditions such as strong light, weak light, backlight, and shadow. After rigorous screening, extremely incomplete samples with an occlusion rate exceeding 75% were removed, and a dataset containing 6601 high-resolution images was finally constructed, named TWD (Typical Weed Dataset). Example image of the dataset is shown below. Figure 2 As shown in the figure, this dataset realistically recreates the extreme working conditions of target overlap and complex background interference in a farmland environment.
[0049] Step 102: Based on the YOLOv11 baseline network, reconstruct the local-global collaborative backbone network to obtain the first optimized network;
[0050] To address the challenge of balancing lightweight design and long-range context modeling in traditional CNN models, the innovative structural feature of the backbone network in this invention is its departure from the original YOLOv11 backbone architecture. Instead, it employs a phased, heterogeneous module stacking design. Specifically, in the shallow layers, the Mobile Inverted Residual Structure (MV2Block), a previously used technique, is densely deployed, utilizing its depthwise separable convolutions to preserve the subtle edge features of weeds with minimal computational overhead. In the mid-to-deep layers, the MobileViTBlock module is introduced to establish a global perceptual field beyond local areas. To address the challenge of irregular geometric distortions in weed targets, this invention innovatively designs the MV2_DCN (Geometric Adaptive Residual Module) in the deep layers of the backbone network (feature map layer P5). This module, while retaining the inverted residual structure, replaces its core 3×3 static depthwise convolution with deformable convolutions (DCNv3), adaptively adjusting the receptive field offset to accurately capture the distortion features of weeds in complex farmland environments.
[0051] Step 103: Reconstruct the neck network into a hypergraph-enhanced semantic neck to establish a high-order spatial topological feature fusion mechanism and obtain the second optimized network;
[0052] The design of this neck network aims to overcome the limitations of ordinary convolution, which is confined to local neighborhoods. The structural inventiveness of the hypergraph-enhanced semantic neck in this invention lies in its unique three-stage cascaded architecture: First, a multi-scale semantic collection layer is constructed to force the multi-layer features of the backbone network from shallow to deep to be aligned to a uniform scale; second, a cascaded hypergraph computation module (HCM) is connected to map the aligned pixels to hypergraph vertices for high-order relation inference; finally, a hybrid aggregation network (MANet) is integrated as a post-filter for hypergraph computation, using its multi-branch architecture to adaptively filter background noise interference introduced during hypergraph aggregation.
[0053] Step 104: Use the second optimized network as the final enhanced detection model MDH-YOLO, and use this model to detect weeds in the field;
[0054] Step 105: Using the dataset constructed in Step 101 and multiple public datasets, conduct comprehensive experimental validation of the enhanced detection model MDH-YOLO.
[0055] Experimental results and visualization analysis demonstrate that the model proposed in this invention exhibits superior performance compared to existing comparative algorithms. It achieves more accurate predictions when handling complex backgrounds and occluded scenes, provides more refined bounding box regression, and demonstrates higher output confidence. Furthermore, it exhibits stronger generalization ability and environmental robustness across multiple datasets, validating the algorithm's practical value and stability in real-world applications.
[0056] In summary, this invention, through steps 101 to 105, proposes a weed detection method based on the hypergraph-enhanced YOLOv11 framework. This method aims to address the problems of high false negative rates, feature confusion, and weak model generalization ability in weed detection under complex field conditions. The proposed method has been thoroughly validated through ablation and comparative experiments on self-built datasets and multiple public datasets. Experimental results and inference visualization analysis show that this invention performs better in terms of detection accuracy, bounding box regression accuracy, and handling complex scenarios such as occlusion. It also possesses stronger model generalization ability and robustness, demonstrating good application prospects and promotional value.
[0057] Example 2
[0058] The key technical details of Example 1 will be further described below.
[0059] The MDH-YOLO model proposed in this invention addresses the core challenge of weed detection in farmland environments through systematic structural optimization. First, it constructs a weed dataset closely resembling natural scenes to compensate for the shortcomings of existing public datasets. Second, it makes several key improvements based on the YOLOv11n architecture, including designing and integrating a local-global collaborative hybrid feature extraction backbone to simultaneously model local detail textures and global dependencies; introducing an enhanced feature fusion neck that integrates hypergraph computation and semantic collection; and utilizing hypergraph convolution to represent higher-order spatial topological relationships between targets to effectively distinguish semantic boundaries between densely occluded targets. Finally, systematic ablation experiments and multi-dataset comparative tests verify the independent effectiveness and synergistic gain of each module. Experimental results show that MDH-YOLO outperforms baseline and other mainstream detection models in terms of detection accuracy, model complexity, and generalization ability. It is particularly suitable for resource-constrained agricultural edge computing devices and practical deployment scenarios, demonstrating significant practical value and promotion potential, as detailed below:
[0060] Step 201: Construct a local-global collaborative backbone network and introduce a geometric adaptive mechanism at a specific level to achieve adaptive feature extraction for complex farmland environments;
[0061] To address the limitations of traditional CNN models in effectively capturing global contextual information due to local receptive field constraints, and their inability to handle irregular deformations of weeds, a deep reconstruction of the feature extraction backbone was performed on the YOLOv11 architecture, named the Local-Global Cooperative Backbone Network. Its structure is as follows: Figure 3As shown in the left box, the input flows from top to bottom along the backbone network, passing through the standard convolutional module, the moving inverted residual module (MV2Block), the moving visual transformation module (MobileViTBlock), and the geometrically adaptive residual module (MV2_DCN) in sequence to capture deformation features.
[0062] Among them, the Moving Inverted Residual Module (MV2Block) and the Geometric Adaptive Residual Module (MV2_DCN) are the main feature extraction module structures, as shown below. Figure 4 As shown. In the shallow stages of the network, the MV2Block module is used for efficient preliminary feature extraction and downsampling. The overall structure of this module is an inverted residual structure, and residual connections are enabled according to different input strides (corresponding to...). Figure 4 (Structure shown in s=1). The input feature map first enters a 1*1 pointwise convolutional layer. After batch normalization (BN layer) and activation function (SiLU layer), the features are mapped to a higher-dimensional feature space, providing a richer representational basis for subsequent spatial feature extraction. Then, the channel-expanded feature map is fed into a 3*3 deep convolutional layer (DWC layer) to extract spatial features channel by channel, reducing computation while maintaining the receptive field. Finally, the feature map enters another 1*1 linear projection layer, compressing the channels back to the original dimension. This module effectively reduces computational overhead while preserving subtle edge features.
[0063] The Moving Inverted Residual Module (MV2Block) can efficiently extract features from conventional targets, but when faced with irregular geometric distortions caused by severe weeds in farmland environments, it often leads to misalignment and loss of key deep features. To address this, this invention innovatively designs a geometrically adaptive residual module (MV2_DCN) and precisely deploys it in the deep layers of the backbone network (feature map layer P5), as shown in the following structure. Figure 4 As shown in the middle.
[0064] The core invention of this module lies in its "asymmetric reconstruction" of its internal feature extraction operator: it retains the two 1×1 linear bottleneck layers used for dimensionality increase and decrease in the standard inverted residual structure, but forces the core 3×3 depthwise convolution (DWConv) to be replaced with a deformable convolutional layer based on the DCNv3 protocol. This design enables the module to have a built-in parallel offset generation branch, which can adaptively learn the spatial offset of the grid sampling points based on the semantic content of the current input features using lightweight convolutions. Figure 4 As shown on the right, the sampling grid is no longer a regular rectangle, but can adaptively diverge or converge based on the edge direction of the weed leaves. Figure 4As shown on the right, the sampling grid is no longer a regular rectangle, but rather diverges or converges according to the edge direction of the weed leaves, thus accurately capturing irregular target features. For position p0 on the input feature map X, the formula for updating the output Y is:
[0065]
[0066] Where G and K represent the number of aggregation groups and the total number of sampling points, respectively; and This represents the learnable projective weight and modulation scalar of the k-th sampling point in the g-th group; This represents the pixel value of the input feature map at the specified coordinates. This is an adaptive spatial offset used to dynamically diverge sampling points based on the actual contours of the weeds. This indicates the center coordinates of the current convolutional kernel's sliding window on the feature map. This indicates that the k-th sampling point in the standard convolution kernel is relative to the center. The fixed grid offset.
[0067] After undergoing the aforementioned geometric correction, the features are compressed through a 1x1 convolution and then fused with the input features using residuals, outputting deep semantic features that are robust to deformation. Through this adaptive adjustment of the convolution range, MV2_DCN can significantly alleviate feature misalignment caused by geometric distortion, ensuring accurate representation of deep semantic features.
[0068] As networks deepen to capture the long-range spatial relationships between weeds and their growing environment, MobileViTBlock is introduced, with a structure as follows: Figure 5 As shown. The core inventive point of MobileViTBlock in this embodiment of the invention lies in its combination of the locality of convolution and the globality of Transformer. The internal data processing flow of the MobileViTBlock module is configured as follows:
[0069] First, let the input feature tensor be... This module uses a standard 3x3 convolutional layer and a 1x1 point convolutional layer to perform local spatial encoding on the input features, and the output encoded features are denoted as follows: .
[0070] Subsequently, The next stage is global dependency modeling, which aims to address the limited receptive field of traditional convolutions. This is achieved through tensor rearrangement and self-attention weighted computation: in the tensor rearrangement (corresponding to the fold in the structural graph) phase... The feature map is divided into non-overlapping 2x2 patches. Through tensor dimension transformation, the feature map is rearranged into a sequence. At this point, pixels within each patch are flattened, and pixels at the same position in different patches are aggregated into the same dimension, constructing an implicit global interaction sequence. This global interaction sequence is then input into a 2- or 4-layer Transformer encoder. Each layer includes a multi-head self-attention (MHSA) mechanism and a feedforward neural network. In MHSA, the query vector (Q), key vector (K), and value vector (V) are calculated according to the following formula:
[0071]
[0072] in The scaling factor is used. This step enables pixels in any patch to interact with corresponding pixels in other patches across the entire image over long distances. After the sequence is weighted by multi-head self-attention, the encoded sequence is restored to a B*C*H*W feature map structure through a reverse rearrangement operation, thus obtaining the enhanced global features. This corresponds to the fold operation in the structure diagram.
[0073] Finally, the enhanced global features The input X is concatenated along the channel dimension and then fused with features through a convolutional layer to output enhanced features that combine local texture details with global semantic context.
[0074] Step 202: Reconstruct the neck network into a hypergraph to enhance the semantic neck, in order to represent higher-order spatial topological relationships;
[0075] The purpose of this invention is to address the problems of boundary ambiguity and feature confusion caused by the lack of high-order semantic association modeling when dealing with densely overlapping scenes in existing technologies. To this end, this invention designs a novel hypergraph-enhanced semantic neck, whose overall architecture, from front to back, includes: a multi-scale semantic collection layer, a hypergraph computation module (HCM), and a hybrid aggregation network (MANet).
[0076] Existing technologies typically only fuse features from adjacent deep layers, neglecting edge texture information contained in features from very shallow layers. Therefore, the primary structural innovation of the neck network in this invention lies in designing a multi-scale semantic collection structure spanning five layers, such as... Figure 6As shown in the diagram, this structure uses the intermediate-scale P4 feature output from the backbone network as the baseline and designs differentiated alignment operators: for the shallow P1, P2, and P3 features, large-span dimensionality reduction is explicitly performed using average pooling layers (AvgPool) with strides of 8×8, 4×4, and 2×2, respectively, to filter high-frequency environmental noise while preserving micro-texture; for the terminal P5 feature, nearest-neighbor interpolation upsampling alignment is used. The above five features are finally concatenated along the channels. This specific combination structure breaks the traditional layer-by-layer FPN connection paradigm of the YOLO series, directly constructing a full-scale feature tensor that simultaneously contains the micro-texture of the seedling stage and the macro-morphology of the mature stage, serving as an enhanced input for subsequent hypergraph computation. Its specific data flow and structural layout are described below. Figure 6 The top three paths, as shown, receive input from shallow features P1, P2, and P3 of the backbone network. These shallow features contain the richest texture details but have a very small receptive field. They are processed by 8*8, 4*4, and 2*2 average pooling layers (AvgPool), respectively, to significantly downsample the spatial resolution to the P4 scale. This effectively compresses the resolution while significantly suppressing high-frequency background noise and filtering out subtle background interference such as soil particles. Figure 6 The intermediate baseline branch directly leads to the features of the P4 layer of the backbone network. These features possess both textural and semantic information and are selected as the spatial baseline for semantic collection. The data flow here undergoes no size transformation and is directly passed forward; finally, as... Figure 6 As shown in the bottommost path, the input comes from the P5 feature at the end of the backbone. This layer has the lowest feature resolution but contains rich semantic information of the entire image. After nearest neighbor interpolation upsampling, the size is enlarged to be consistent with P4. The above five aligned features are fused along the channel dimension through a concat operation to form a full-scale variation feature tensor covering the fine texture of the seedling stage to the overall shape of the mature stage. This tensor serves as the input node for the subsequent Hypergraph Computation Module (HCM), ensuring that each node contains both local details and global semantics when constructing the hypergraph, laying a solid data foundation for solving the occlusion problem.
[0077] After obtaining the aforementioned deeply intertwined hybrid features, a Hypergraph Computation Module (HCM) is introduced. This module utilizes hypergraph theory to model high-order complex relationships between pixels, overcoming the limitation of traditional convolutions that can only process local neighborhoods. Its data processing flow is as follows: This module first defines the vertices and performs spatial mapping on the features, then converts the hybrid feature tensor output from the previous level... Each pixel in the graph is considered a vertex in the hypergraph structure. Let the feature map size be H*W and the number of channels be C. The graph will be reshaped and transposed to construct a vertex set V containing H*W vertices. This operation abstracts the feature map as a node distribution in the feature space. Then, hyperedge construction is performed, using the K-Nearest Neighbors (KNN) algorithm to dynamically retrieve associated points in the feature space. For each central vertex, its Euclidean distance to all other vertices in the feature space is calculated. Set a dynamic threshold τ, if If the vertex is less than τ, it is determined that the vertex belongs to the hyperedge. The K most semantically similar neighbor nodes are selected as the hyperedges. By traversing all vertices, an association matrix representing the membership relationship between vertices and hyperedges is generated. Finally, the hypergraph convolution operation in the spatial domain updates the vertex features using the hypergraph convolution operator in the spatial domain. The calculation process is as follows:
[0078]
[0079] in, The enhanced feature matrix is the output after hypergraph convolution processing; the enhanced feature matrix is the output after hypergraph convolution processing. Nonlinear activation functions are used to introduce nonlinear transformation capabilities; The correlation matrix is used to define the topological connectivity between pixels. A value of 1 indicates a vertex. It belongs to the superedge Otherwise, it is 0; The hyperedge weight matrix is used to adjust the importance of different hyperedges in information transmission; The diagonal elements of the Vertex Degree Matrix represent the number of hyperedges connected to each vertex, used to normalize features and prevent numerical explosion. This is the Hyperedge Degree Matrix, where the diagonal elements represent the number of vertices contained in each hyperedge. The input is the node feature matrix; These are learnable transformation weight matrices (Filter Weights) used to map and extract feature dimensions during feature propagation.
[0080] The calculation process is performed from right to left: First, input features. With learnable state transition matrix Multiplication maps the features to a high-dimensional subspace suitable for topological propagation; the transpose of the incidence matrix is then utilized. By pooling the features of all vertices belonging to the same hyperedge onto that hyperedge, local semantics are centralized. , The converged hyperedge features are normalized using the hyperedge weight matrix and hyperedge degree matrix, respectively. Hyperedges with different correlation strengths are then weighted according to the hyperedge weight matrix to suppress noisy connections. Subsequently, the correlation matrix is used again... The weighted hyperedge context information is diffused to each vertex, so that each pixel obtains the enhanced features of its semantic neighbors. The vertex degree matrix is used to normalize the degree of the updated vertex features to prevent numerical explosion; finally, it is processed by a nonlinear activation function. Increase the nonlinear expressive power of the model, and through residual connections ( The original features are fused with the topological features to output the final enhanced features. .
[0081] By simulating higher-order interactions between multiple pixels, the hypergraph computing module can effectively extract the edge topological logic of occluded targets and clearly distinguish the boundaries between mutually occluded crops and weeds in the feature space.
[0082] Step 203: Cascade a hybrid aggregation network (MANet) after the hypergraph computing nodes to construct a noise-resistant filtering mechanism for topological features.
[0083] Considering that the Hypergraph Computation Module (HCM), when dynamically building graphs based on distance thresholds, is prone to introducing similar backgrounds (such as soil reflections and similar crops) into hyperedges as noise, the inventive point of this invention lies not in MANet itself, but in cascading and integrating the Hybrid Aggregation Network (MANet) as a post-processor for hypergraph features. MANet, as cited in the prior art (e.g....), Figure 7 (As shown) a multi-branch parallel architecture: Branch 1 uses 1×1 convolutions without activation functions to transmit hypergraph structure information; Branch 2 uses 3×3 depthwise convolutions to compensate for local spatial neighborhood cues; Branch 3 extracts nonlinear high-order semantics and filters irrelevant backgrounds through stacked bottleneck layers. This invention, through a cascaded structure combining hypergraphs and aggregations, adaptively utilizes multi-scale receptive fields to weight and correct the high-order topological relationships captured by the hypergraph, ensuring that the features transmitted to the detection head possess extremely high target discriminative power and semantic purity. Its specific structural flow is as follows: Input features are fed into three parallel branches for processing. Figure 7In the leftmost branch one, the input features first undergo a linear transformation via a 1x1 convolution (Conv1*1). This branch does not contain non-linear activation functions to preserve the original topological structure information of the hypergraph computation output and prevent feature drift during depth transformation. Moving to the right is branch two, where the data stream, after dimensionality reduction via a 1x1 convolution (Conv1*1), enters a 3x3 deep convolutional layer (DWConv k*k). Utilizing its local receptive field, this layer focuses on capturing local texture cues around pixels to supplement spatial neighborhood information that hypergraph computation might overlook. Further to the right is branch three, where the data stream is split by a split operation and then passes through stacked bottleneck layers. This branch uses multiple non-linear transformations to extract deeper abstract semantics, filtering out background textures (such as reflections and soil particles) that do not match the weed features. Finally, the outputs of all branches are concatenated along the channel dimension and integrated through a convolutional layer. This design can adaptively utilize multi-scale receptive fields to filter out complex interference in farmland backgrounds, ensuring that the features transmitted to the detection head have extremely high class discrimination and semantic purity, significantly enhancing the robustness of the model.
[0084] Step 204: Based on the above improvements, an enhanced weed detection network, MDH-YOLO, is proposed.
[0085] Its overall architecture is as follows Figure 3 As shown, it comprises three core components: a local-global collaborative backbone network, a hypergraph-enhanced semantic neck network, and a standard detection head. The backbone network, through the collaborative work of MV2Block, MobileViTBlock, and MV2_DCN, achieves comprehensive feature extraction from texture details to global dependencies and geometric shapes. The neck network, through the cooperation of a multi-scale semantic collection layer, a hypergraph computation module, and MANet, upgrades feature fusion from simple stitching to high-order topological relationship modeling, significantly improving recognition capabilities in densely occluded scenes. The detection head adopts the multi-scale detection design of YOLOv11, achieving accurate bounding box regression. Overall improvements significantly enhance MDH-YOLO's detection accuracy (mAP50 reaching 91.16%), model lightweighting (2.76 M parameters), and adaptability to complex agricultural scenarios, making it suitable for practical deployment on resource-constrained edge devices.
[0086] Step 205: Selection of experimental environment and evaluation indicators;
[0087] All experiments were conducted on a high-performance computing platform, with hardware configurations including two Intel Xeon Gold5218R CPUs and eight NVIDIA A40 GPUs (48 GB VRAM per card). The software environment was based on Ubuntu 22.04, utilizing the PyTorch 2.4.1 deep learning framework and CUDA 12.2 for parallel computing acceleration. This embodiment selected multiple metrics to quantitatively evaluate model performance: the accuracy metric used was the mean precision (mAP), including mAP50 at an IoU threshold of 0.5, and a comprehensive metric mAP50:95 for IoU thresholds ranging from 0.5 to 0.95. The F1 score was also recorded to comprehensively measure the model's precision and recall. Efficiency metrics used were: frames per second (FPS) to measure inference speed; parameters and gigaflops (GFLOPs) to measure computational complexity; and model size to measure storage usage.
[0088] Step 206: Analysis of algorithm experiment results.
[0089] To objectively verify the technical effectiveness of the MDH-YOLO model proposed in this invention in complex farmland environments, this embodiment systematically analyzes the model from three dimensions: module effectiveness, model generalization ability, and qualitative detection effect, based on the self-built TWD dataset and public datasets such as HRWD and MWS.
[0090] (1) Analysis of the results of the module ablation experiment
[0091] To verify the independent contribution of each improvement module, tests were conducted on the TWD dataset to progressively stack the modules (data shown in Table 1).
[0092] First, by introducing a local-global collaborative backbone (configuration A) on the baseline model YOLOv11n, mAP50 increased from 87.29% to 89.07%, while the number of parameters decreased by 0.414 M. This result demonstrates that the MobileViT module effectively establishes long-range dependencies while reducing model redundancy, thus compensating for the shortcomings of traditional convolutions in global context awareness.
[0093] Secondly, after further introducing hypergraph-enhanced semantic neck (configuration B), the mAP50 exceeded 90%, reaching 90.03%. This significant improvement verifies the advantages of hypergraph computing in representing high-order spatial relationships, and effectively solves the feature confusion problem in densely distributed scenes by modeling the topological connections between pixels.
[0094] Finally, after integrating the geometric adaptation module (configuration C), the complete MDH-YOLO model achieved an mAP50 of 91.16%, a 3.87% improvement over the baseline. This confirms that deformable convolution (DCNv3) significantly enhances the model's ability to locate non-rigid deformations and irregular edges of weeds by dynamically adjusting the sampling field. Despite a slight increase in computational cost, MDH-YOLO maintained an inference speed of 89.74 FPS, meeting the needs of real-time agricultural operations.
[0095] (2) Cross-dataset comparative experimental analysis
[0096] MDH-YOLO was compared with mainstream models such as YOLOv8n, YOLOv9t, YOLOv10n, YOLOv12n, and RT-DETR (data shown in Table 2). On the TWD dataset, MDH-YOLO's mAP50 (91.16%) outperformed all the compared models. In particular, compared with the large parameter model RT-DETR-ResNet101 based on the Transformer architecture, the model of this invention, with only about 4.5% of the parameters, achieved a 5.65% higher mAP50. This indicates that the lightweight topology modeling architecture designed for farmland scenarios has higher feature extraction efficiency than the general heavy detection architecture. On the HRWD dataset with drastic light fluctuations and the MWS dataset containing different growth cycles, MDH-YOLO also maintained its leading position, with mAP50 reaching 80.01% and 89.20%, respectively. This verifies the robustness and generalization ability of the model of this invention in dealing with complex light changes and morphological differences at different growth stages.
[0097] (3) Visual analysis of model detection results
[0098] By comparing the detection results of typical samples (e.g.) Figure 8 As shown in the figure, it can be seen that: for scenarios where crops and weeds overlap at a high density ( Figure 8 In columns 1-2, baseline models often produce redundant predicted boxes or miss detections, while MDH-YOLO, leveraging the topological relationships captured by the hypergraph, can accurately infer the complete structure of occluded targets, generating clear and independent bounding boxes. This is particularly useful for extremely irregularly shaped grasses (Grassaceae). Figure 8 (Column 4) The bounding box generated by MDH-YOLO tightly fits the edge of the weeds, and the confidence score significantly improves from 0.28 for the baseline model to 0.80, demonstrating its strong characterization ability for non-rigid deformations. This is particularly relevant for tiny seedlings in a mimicry background (…). Figure 8(Columns 5-6) The model of this invention successfully captured weak targets that the baseline model missed, with a confidence improvement of more than 0.15, proving the effective aggregation and anti-interference ability of the multi-scale semantic collection layer for weak features.
[0099] Table 1. Ablation experimental results of MDH-YOLO on a self-built dataset
[0100]
[0101] Table 2. Performance on different datasets
[0102]
[0103] Example 3
[0104] A weed detection device based on the hypergraph-enhanced YOLOv11 framework is disclosed. This device can be applied to various hardware platforms, including but not limited to agricultural robots, unmanned aerial vehicles (UAVs), intelligent spraying equipment, or handheld agricultural terminals. The device includes:
[0105] Image acquisition unit: one or more cameras configured on the device for acquiring images or video streams of farmland in real time or offline.
[0106] Processor: can be a central processing unit (CPU), graphics processing unit (GPU), application-specific integrated circuit (ASIC), or field-programmable gate array (FPGA) or other hardware with computing capabilities.
[0107] Memory: A non-volatile storage medium, such as flash memory or solid-state drive (SSD), used to store the operating system, application programs, and the MDH-YOLO model program instructions and model weight files described in Embodiments 1 and 2 of this invention.
[0108] The processor invokes the MDH-YOLO model program instructions stored in memory to cause the device to execute the following method steps in Embodiments 1 and 2:
[0109] Weed images were collected and labeled to construct a weed dataset;
[0110] Based on a weed dataset, the YOLOv11 baseline network model is improved to obtain a weed detection model. Specifically, the structural optimization of the YOLOv11 object detection network is implemented as follows:
[0111] The backbone of the baseline YOLOv11n network was replaced with a local-global collaborative feature extraction backbone; the deep P5 layer of the backbone network was integrated with a geometrically adaptive residual module (MV2_DCN); the neck network was reconstructed into a hypergraph-enhanced semantic neck, which includes a multi-scale semantic collection layer, a hypergraph computation module (HCM), and a hybrid aggregation network (MANet).
[0112] The working principle of the local-global collaborative feature extraction backbone is as follows: by alternately integrating the mobile inverted residual structure (MV2Block) and the mobile visual transformation module (MobileViTBlock), edge features are preserved in the shallow layer, and global contextual connections are established in the middle and deep layers through a self-attention mechanism.
[0113] The working principle of the geometric adaptive residual module (MV2_DCN) is as follows: it uses the adaptive spatial offset of deformable convolution (DCNv3) to dynamically adjust the sampling points to match the non-rigid geometric distortion of weeds.
[0114] The working principle of the hypergraph-enhanced semantic neck is as follows: First, multi-scale features are aggregated through a multi-scale semantic collection layer. Then, hyperedges are constructed using the K-nearest neighbor algorithm through HCM and hypergraph convolution operations are performed to represent high-order topological relationships. Finally, background noise is filtered and topological features are dynamically weighted through MANet's multi-branch architecture.
[0115] Weed detection models are used to detect weeds in field images.
[0116] It should be noted that the device descriptions in the above embodiments correspond to the method descriptions in Embodiments 1 and 2, and the embodiments of the present invention will not be repeated here.
[0117] Unless otherwise specified, the model numbers of the various devices in this embodiment of the invention are not limited, and any device that can perform the above functions is acceptable.
[0118] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of a preferred embodiment, and the sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0119] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A weed detection method based on the hypergraph-enhanced YOLOv11 framework, characterized in that, The method includes: Based on the YOLOv11 baseline network, the local-global collaborative backbone network is reconstructed to obtain the first optimized network; The neck network is reconstructed into a hypergraph-enhanced semantic neck to establish a high-order spatial topological feature fusion mechanism and obtain a second optimized network; The second optimized network was used as the final enhanced detection model, and field weeds were detected based on this enhanced detection model. The enhanced detection model was comprehensively validated using the constructed dataset and multiple public datasets; the validated enhanced detection model was then used for weed detection.
2. The weed detection method based on the hypergraph-enhanced YOLOv11 framework according to claim 1, characterized in that, The first optimized network is: In the shallow layers of the backbone network, a moving inverted residual structure is set up, and depthwise separable convolution is used to preserve the small edge features of weeds. In the deeper stages of the main structure, a mobile visual transformation module is introduced to establish a global perception field that transcends local areas; A geometrically adaptive residual module is designed in the deep p5 layer of the backbone network. While retaining the inverted residual structure, the 3×3 static depthwise convolution is replaced with deformable convolution, and the receptive field offset is adjusted adaptively.
3. The weed detection method based on the hypergraph-enhanced YOLOv11 framework according to claim 1, characterized in that, The second optimized network is: Construct a multi-scale semantic collection layer to force the multi-layer features of the backbone network from shallow to deep to be aligned to a uniform scale; The cascaded hypergraph computation module maps aligned pixels to hypergraph vertices for higher-order relation inference; The hybrid aggregation network is integrated as a post-filter for hypergraph computation, and the background noise interference introduced during the hypergraph aggregation process is adaptively filtered using a multi-branch architecture.
4. The weed detection method based on the hypergraph-enhanced YOLOv11 framework according to claim 2, characterized in that, The input flows from top to bottom along the backbone network, passing sequentially through the standard convolution module, the moving inverted residual module, the moving visual transformation module, and the geometrically adaptive residual module to capture deformation features.
5. The weed detection method based on the hypergraph-enhanced YOLOv11 framework according to claim 4, characterized in that, The second optimization network explicitly uses average pooling layers with step sizes of 8×8, 4×4, and 2×2 to perform large-span dimensionality reduction for the shallow features P1, P2, and P3, respectively. For the terminal P5 feature, nearest neighbor interpolation upsampling alignment is used. The five features are finally spliced along the channel to construct a full-scale feature tensor that simultaneously contains the micro-texture of the seedling stage and the macro-morphology of the mature stage. The full-scale feature tensor is used as the enhanced input for subsequent hypergraph computation.
6. The weed detection method based on the hypergraph-enhanced YOLOv11 framework according to claim 4, characterized in that, The hypergraph computation module uses hypergraph theory to model high-order complex relationships between pixels.
7. The weed detection method based on the hypergraph-enhanced YOLOv11 framework according to claim 4, characterized in that, The method cascades a hybrid aggregation network after the hypergraph computing nodes to construct a noise-resistant filtering mechanism for topological features; The hybrid aggregation network is cascaded and integrated as a post-feature of the hypergraph, employing a multi-branch parallel architecture: Branch 1 uses 1×1 convolutions without activation functions to transmit hypergraph structure information; Branch 2 uses 3×3 depthwise convolutions to compensate for local spatial neighborhood cues; Branch 3 extracts nonlinear high-order semantics and filters irrelevant background by stacking bottleneck layers. By combining hypergraphs and aggregations in a cascaded structure, multi-scale receptive fields are used to perform weighted correction on the high-order topological relationships captured by the hypergraph.
8. A weed detection device based on the hypergraph-enhanced YOLOv11 framework, characterized in that, The device includes a processor and a memory, the memory storing program instructions, the processor calling the program instructions stored in the memory to cause the device to perform the method according to any one of claims 1-7.
9. A weed detection device based on the supergraph enhancement YOLOv11 framework according to claim 8, wherein the device is applied to the hardware platform of agricultural robots, unmanned plant protection, intelligent spraying equipment or handheld agricultural terminals.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program including program instructions that, when executed by a processor, cause the processor to perform the method described in any one of claims 1-7.