Lightweight soybean pod counting method and system based on structure distillation and foreground guidance
By employing a main-auxiliary dual-branch neural network architecture and a structural distillation mechanism, the auxiliary branch generates a density map with enhanced structure, while the main branch learns fine-grained structural information. This solves the problems of high computational resource consumption and insufficient robustness in existing models, achieving efficient and lightweight soybean pod counting.
Patent Information
- Application Number
- CN202511386622.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-26
- Publication Date
- 2026-01-09
AI Technical Summary
Existing deep learning models consume a lot of computational resources and are difficult to deploy in soybean pod counting. They also have limited robustness and generalization ability to environmental changes, making it difficult to meet the needs of agricultural production for high efficiency, reliability and easy deployment.
A main-slave dual-branch neural network architecture is adopted. The auxiliary branch generates a structure-enhanced density map by guiding the generation of foreground masks, while the main branch learns fine-grained structural information through structural distillation mechanism. Multi-level loss functions are designed to improve the model's ability to express target regions and its robustness to complex backgrounds. The main branch adopts a lightweight architecture.
It improves counting accuracy and robustness without increasing computing resource consumption, is suitable for edge computing devices, and meets the real-time and portability requirements of agricultural scenarios.
Smart Images

Figure CN121305338A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision and agricultural intelligent sensing technology, and particularly relates to a lightweight soybean pod counting method and system based on structural distillation and foreground guidance. Background Technology
[0002] Against the backdrop of rapid development of intelligent agriculture, the rapid and accurate assessment of crop yield has become a key means to improve agricultural production efficiency and decision-making. As an important indicator of soybean yield, the accurate counting of soybean pods is crucial for variety selection, field management, and food security. However, traditional manual counting methods suffer from low efficiency and large errors, making it difficult to meet the urgent needs of automation and intelligentization in large-scale agricultural production.
[0003] In recent years, deep learning techniques such as density map regression and object detection have made significant progress in the field of crowded object counting. However, in complex agricultural scenarios, cluttered backgrounds and varying lighting conditions still pose significant challenges to the counting task. Existing methods mostly rely on complex deep models, but these still suffer from high computational resource consumption, high deployment difficulty, and limited robustness and generalization ability to environmental changes, making it difficult to meet the demands of practical production for efficient, reliable, and easily deployable systems. Therefore, there is an urgent need for a lightweight, novel density estimation framework with foreground awareness capabilities to better adapt to the practical application requirements of agricultural image tasks such as soybean pod counting.
[0004] This invention proposes a soybean pod density estimation method and its lightweight intelligent counting system that integrates a structural distillation mechanism and a foreground guidance strategy. By constructing a main-auxiliary dual-branch neural network architecture, the auxiliary branch, guided by a foreground mask, first performs explicit extraction and structure-enhanced density estimation of the soybean pod region. Then, through the structural distillation mechanism, fine-grained structural information is transmitted to the main branch, improving the main branch's ability to model the target spatial distribution and edge structures. This technology improves model inference accuracy while maintaining computational efficiency, making it suitable for large-scale deployment and real-time applications in practical agricultural scenarios. Summary of the Invention
[0005] The purpose of this invention is to provide a lightweight soybean pod counting method and system based on structured distillation and foreground guidance, in order to solve the problems of existing deep models proposed in the background art, such as high computational resource consumption, high deployment difficulty, and limited robustness and generalization ability to environmental changes when automatically counting soybean pods in complex agricultural environments.
[0006] To achieve the above objectives, the present invention employs the following technical solution:
[0007] In its first aspect, this invention proposes a lightweight soybean pod counting method based on structural distillation and foreground guidance, comprising the following steps:
[0008] S1. Construct a soybean pod density estimation model. The soybean pod density estimation model adopts a main-auxiliary dual-branch neural network architecture. The auxiliary branch neural network is guided by a foreground mask to generate a structurally enhanced pod density map, which is used to guide the main branch neural network to focus on the real pod area to generate the pod density map.
[0009] S2. Design a structured density-supervised quaternary loss function, including main branch density loss, auxiliary branch density loss, main-auxiliary consistency distillation loss, and background suppression loss;
[0010] S3. The soybean pod density estimation model is trained and optimized. Based on the structural distillation mechanism and the prospect guidance strategy, the main branch neural network learns the structural expression of the auxiliary branch neural network during the training phase, and the soybean pod density estimation model is optimized based on the loss function.
[0011] S4. Using the main branch neural network in the optimized soybean pod density estimation model, process the images of soybean plants to be counted and estimate the total number of soybean pods.
[0012] This method constructs a main-auxiliary dual-branch neural network architecture. The auxiliary branch, guided by a foreground mask, first performs explicit extraction and structure-enhancing density estimation of the soybean pod region. It then transmits fine-grained structural information to the main branch through a structural distillation mechanism, improving the main branch's ability to model the target spatial distribution and edge structures. Furthermore, a multi-level loss function is designed, including density estimation loss based on optimal transmission distance between the main and auxiliary branches, consistency loss, and background suppression loss, effectively enhancing the model's expressive power for the target region and its robustness to complex backgrounds. The main branch adopts a lightweight architecture to achieve efficient density estimation, meeting the deployment requirements of edge computing devices. The overall system has a compact structure and low computational overhead, making it suitable for intelligent agricultural applications in resource-constrained environments. It also possesses good real-time performance, portability, and generalization capabilities.
[0013] Preferably, the soybean pod density estimation model in S1 is as follows:
[0014] Auxiliary branch neural networks, including semantic segmentation models and auxiliary density estimation networks;
[0015] The auxiliary branch neural network takes soybean plant images as input, performs foreground segmentation on the images based on the semantic segmentation model to generate a foreground mask, obtains a foreground image based on the foreground mask, and inputs it into the auxiliary density estimation network to generate a structure-enhanced pod density map.
[0016] Main branch neural networks, including main density estimation networks;
[0017] The main branch neural network takes soybean plant images as input, while the auxiliary branch neural network provides structural supervision signals to guide the main branch neural network to focus on the real pod region and generate a pod density map.
[0018] Furthermore, the auxiliary branch neural network and the main branch neural network are specifically as follows:
[0019] An auxiliary branch neural network is used to input image I into the semantic segmentation model SegNet to extract the foreground pod region and obtain the foreground mask Mask. The foreground mask Mask is then multiplied with image I at the pixel level to obtain the foreground image I_F. Image I_F retains the pixels belonging to the pod target in image I and sets the rest to 0, thus masking the background. Subsequently, image I_F enters the auxiliary density estimation network and outputs the density map DM2 guided by the foreground.
[0020] The main branch neural network takes image I as input and generates density map DM1.
[0021] Preferably, both the auxiliary density estimation network and the main density estimation network adopt the density estimation network DMENet, which includes a front-end module and a back-end module.
[0022] The low-level visual features of the image are extracted by the front-end convolution module and multi-scale feature fusion is performed. In the back-end module, multi-branch convolution with different dilation rates is combined with CBAM attention to enhance the modeling ability of dense target regions.
[0023] Furthermore, the front-end module and the back-end module are specifically as follows:
[0024] The front-end module consists of multiple stacked convolutional layers, which gradually extract the basic features of the image. Then, the feature maps at the last three scales are upsampled and downsampled and fused to achieve the integration of multi-scale feature information.
[0025] The backend module adopts a multi-parallel structure, with each branch consisting of convolutional blocks with different dilation rates and a CBAM attention module. The dilated convolution expands the receptive field by setting different dilation rates. The CBAM attention module introduces channel attention and spatial attention mechanisms to enhance attention to key regions. Finally, the feature outputs of the multiple branches are fused and a pod density map is generated through single-channel convolution.
[0026] Preferably, the structured density-supervised quaternary loss function in S2 is as follows:
[0027] Main branch density loss L main The density map DM1 generated by the main branch neural network is used to ensure that it is consistent with the true density map GT. Specifically:
[0028] Lmain =Sinkhorn(DM1,GT)
[0029] Auxiliary branch density loss L aux To improve the accuracy of the density map DM2 generated by the auxiliary branch neural network, specifically:
[0030] L aux =Sinkhorn(DM2,GT)
[0031] Main and auxiliary consistency distillation loss L cons To encourage the density maps predicted by the main branch neural network and the auxiliary branch neural network to maintain a consistent overall distribution, the following is specifically used:
[0032] L cons =Sinkhorn(DM1,DM2)
[0033] Background suppression loss L bg This is used to suppress erroneous responses of the main branch neural network in the background region and highlight the foreground region, specifically:
[0034]
[0035] The final loss function is:
[0036] L total =L1L main +L2L aux +λ3L cons +L4L bg
[0037] Among them, λ1, λ2, λ3, and λ4 are hyperparameters used to balance the impact of various losses; Sinkhorn is the optimal transmission distance.
[0038] Preferably, the training phase in S3 specifically includes the following:
[0039] During training, the main branch neural network and the auxiliary branch neural network output density maps respectively, and these maps are compared with the real density maps under supervision to calculate the corresponding density loss L. main With L aux And apply a primary-auxiliary consistency distillation loss L to the output layer. cons This allows the main branch neural network to learn the regions of interest of the auxiliary branch neural network; background suppression loss L is introduced during training. bg The non-zero density values predicted by the main branch neural network in non-foreground regions are penalized, guiding the model to reduce its response to background regions.
[0040] In a second aspect, this invention proposes a lightweight soybean pod counting system based on structural distillation and foreground guidance, comprising:
[0041] The image input module is used to input the preprocessed soybean plant image into the main branch density estimation module.
[0042] The main branch density estimation module uses a main branch neural network trained and optimized based on a lightweight soybean pod counting method using structural distillation and foreground guidance; it is used to generate pod density maps.
[0043] The counting module is used to convert the pod density map into a target total number for visualization output.
[0044] Compared with the prior art, the beneficial effects of the present invention are:
[0045] (1) This invention designs a lightweight intelligent soybean pod counting system that supports automatic inference. The system adopts a lightweight soybean pod density estimation model with a main branch architecture for density estimation, achieving performance improvement without increasing inference overhead. To address the challenge of densely packed and similarly shaped pods in pod counting, the system uses the semantic segmentation model SegNet or introduces a large model-generated pod region mask based on point prompts as an additional supervisory signal to assist distillation, helping the model better distinguish pods from the background. Furthermore, a multivariate loss mechanism suitable for pod counting is designed, including in-mask consistency constraints and out-of-mask inhibition constraints, effectively mitigating prediction diffusion problems caused by pod overlap and occlusion, making the predicted density more focused on the actual pod region. This invention integrates large model distillation and task-specific loss on the density map counting framework, proposing an improved method more suitable for pod counting characteristics, significantly improving counting accuracy and localization robustness in dense pod scenarios. The system is compatible with edge computing devices, possesses rapid response capabilities, and meets the real-time, portable, and reliable agricultural production needs of resource-constrained environments such as fields.
[0046] (2) In this invention, the soybean pod density estimation model integrates structural distillation and foreground guidance mechanisms. The auxiliary branch explicitly extracts the soybean pod region under foreground guidance and generates a density map with enhanced structure. The extracted structural information is transmitted to the main branch in the form of distillation, which further enhances its ability to model the spatial distribution and edge structure of the target, thereby improving the robustness and generalization ability of the model under complex background and illumination change conditions.
[0047] (3) In this invention, the soybean pod density estimation model adopts the density estimation network DMENet, introduces the CBAM attention mechanism to enhance the response to the soybean pod region, and combines dilated convolution to expand the receptive field, thereby improving the context modeling capability while taking into account the computational efficiency.
[0048] (4) In this invention, the soybean pod density estimation model strengthens training constraints through a structured density-supervised quaternary loss design, constructs a density estimation loss and consistency loss based on the optimal transmission distance for the main branch and auxiliary branches, and introduces a background suppression loss for the main branch to synergistically improve the modeling accuracy of the target area, effectively suppress background interference, and enhance the robustness and generalization ability of the model. Attached Figure Description
[0049] Figure 1 This is a flowchart of the lightweight soybean pod counting method based on structural distillation and foreground guidance in this invention;
[0050] Figure 2 This is a structural block diagram of the soybean pod density estimation model in this invention;
[0051] Figure 3 This is a block diagram of the density estimation network DMENet in this invention. Detailed Implementation
[0052] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0053] Example 1:
[0054] See Figure 1 A lightweight soybean pod counting method based on structural distillation and foreground guidance is proposed. This method designs a soybean pod density estimation model, employing a master-slave dual-branch neural network architecture. Through dual-branch collaborative modeling and structural distillation mechanisms, the model's ability to focus on the target region and its counting accuracy are effectively improved, thus achieving soybean pod counting. The method includes the following steps:
[0055] Step 1: Construct a soybean pod density estimation model.
[0056] The soybean pod density estimation model employs a main-auxiliary dual-branch neural network architecture. The input image simultaneously enters both the main branch and the auxiliary branch. The main branch is responsible for predicting the final density map, while the auxiliary branch, during the training phase, guides the generation of a structure-enhanced density map through foreground masks and provides structural supervision signals. This guides the main branch to focus on the soybean pod region, thereby improving modeling accuracy and learning efficiency, and enhancing the structural expressiveness of the density map. Figure 2 As shown, the model incorporates the CBAM attention mechanism to enhance the response to the soybean pod region, and combines it with dilated convolution to expand the receptive field, thereby improving contextual modeling capabilities while maintaining computational efficiency.
[0057] In this embodiment, the auxiliary branch neural network employs the semantic segmentation model SegNet and the auxiliary density estimation network DMENet. The auxiliary branch neural network is only enabled during the training phase. It performs foreground segmentation on the image based on SegNet, generates a foreground mask, and inputs the foreground image into the auxiliary density estimation network to form a structural distillation and guidance mechanism, guiding the main branch to focus on the real pod region.
[0058] In this embodiment, the main branch neural network uses only the density estimation network DMENet. The main branch neural network takes a soybean pod image as input and outputs a density map as the final prediction result, and is enabled during both training and inference phases. During training, a structural distillation strategy is further introduced, enabling the main branch to mimic the structural expression of the auxiliary branch at the feature layer. When outputting the density map, the main and auxiliary branches are constrained for consistency using Sinkhorn distance, while background suppression loss is combined to weaken the response of non-target regions, thereby enhancing robustness to complex backgrounds.
[0059] Specifically, Figure 3 The structure of the density estimation network DMENet is shown, which includes a front-end module and a back-end module. Specifically, the front-end module consists of multiple stacked convolutional layers, progressively extracting the basic features of the input pod image. Subsequently, upsampling and downsampling operations are performed on the feature maps at the last three scales, and then fused to effectively integrate multi-scale feature information and enhance the model's ability to represent the target density distribution. The back-end module adopts a multi-path parallel structure, with each branch consisting of convolutional blocks with different dilation rates and a CBAM attention mechanism. The dilated convolution expands the receptive field by setting different dilation rates, improving the modeling ability of dense regions; the CBAM attention module introduces channel attention and spatial attention mechanisms to further optimize feature representation and enhance the model's attention to key regions. Finally, the feature outputs from the multiple branches are fused, and a pod density map is generated through single-channel convolution.
[0060] Step two: Design a loss function to optimize the model.
[0061] This method employs a structured density-supervised quaternary loss, comprising main branch density loss, auxiliary branch density loss, main-auxiliary consistency distillation loss, and background suppression loss. The first three types utilize optimal transport loss to constrain the spatial distribution of the density map, enhancing target modeling capabilities in complex backgrounds. This method achieves structured density modeling of dense targets without relying on precise segmentation labels, exhibiting high accuracy, high robustness, and good generalization ability. It is suitable for intelligent counting tasks of dense targets such as soybean pods in agricultural scenarios.
[0062] Specifically, the proposed two-branch pod density estimation model's quaternary loss function consists of four parts: main branch density estimation loss, auxiliary branch density estimation loss, consistency loss, and background suppression loss. The main branch density estimation loss constrains the density map DM1 output by the main branch to be consistent with the true density map GT, thus ensuring the model's prediction quality during the inference phase. The auxiliary branch density estimation loss improves the accuracy of the density map DM2 generated by the auxiliary branch, allowing it to positively guide the main branch during training. The density estimation loss employs the Sinkhorn distance, a regularized optimal transport distance, to more reasonably capture the semantic distance between density distributions. This loss effectively encourages the model to generate density maps with more reasonable structure and more accurate shape. The density estimation losses for the main branch and auxiliary branch are defined as follows:
[0063] L main =Sinkhorn(DM1,GT) (1)
[0064] L aux =Sinkhorn(DM2,GT) (2)
[0065] The consistency loss encourages the density maps predicted by the main branch and auxiliary branches to maintain consistency in overall distribution, thereby enhancing the main branch's ability to focus on and respond to the foreground region. This loss also uses the Sinkhorn distance, i.e.
[0066] L cons =Sinkhorn(DM1,DM2) (3)
[0067] Background suppression loss suppresses erroneous responses from the main branch in the background region, highlighting the importance of the foreground (pod) region in the density estimation process. This loss penalizes non-zero density values predicted by the model in the background region, guiding the network to focus more on the foreground region, thereby improving the discriminativeness and robustness of the prediction results. Background suppression loss is defined as:
[0068]
[0069] The final loss function is a weighted combination of the above terms, i.e.
[0070] L total =λ1L main +λ2L aux +λ3L cons +λ4L bg (5)
[0071] Among them, λ1, λ2, λ3, and λ4 are hyperparameters used to balance the effects of various losses.
[0072] Step 3: Train the soybean pod density estimation model.
[0073] In actual deployment, the input is the original image I of the pod, which is normalized before being input into the model. The model structure consists of two parts: a main branch and an auxiliary branch. The main branch directly estimates the density of image I and outputs a density map DM1. This branch participates in both the training and inference phases. The auxiliary branch is only enabled during the training phase, and its core function is to guide the main branch to learn more discriminative density features through foreground information.
[0074] Figure 1 The diagram illustrates the complete flowchart of the proposed dual-branch structure during the training phase, demonstrating the specific implementation of the structural distillation mechanism and foreground guidance strategy during training. Unlike the inference phase, the training phase simultaneously utilizes both the main branch and auxiliary branch networks, enhancing the generalization ability and robustness to complex backgrounds of the main branch through collaborative optimization.
[0075] During the training phase, the input is the original soybean pod image, which is first fed into the foreground extraction module of the auxiliary branch. This module uses a lightweight semantic segmentation network (such as SegNet) to segment the image, obtaining a foreground mask, from which pixel information belonging to the soybean pod region is extracted. The foreground mask is multiplied pixel by pixel with the original image to generate the foreground image, preserving the original pixel information of the soybean pod region while suppressing the background region, thus achieving background interference masking.
[0076] Specifically, in the auxiliary branch, image I is first input into the semantic segmentation model SegNet to extract the foreground pod region, obtaining the foreground mask Mask. Then, it is multiplied pixel-level with the original image to obtain the foreground image I_F = I × M. This image I_F retains the pixels belonging to the pod target in the original image, while setting the rest to 0, thus masking the background. Subsequently, I_F enters an auxiliary density estimation subnetwork with the same structure as the main branch, outputting the foreground-guided density map DM2.
[0077] The foreground image is fed into the density estimation path of the auxiliary branch, which has the same structure as the main branch, generating a density map guided by the foreground. At the same time, the original image is also input into the main branch network, and is processed by modules such as multi-scale feature extraction and multi-branch receptive field attention to generate the main density map.
[0078] During training, the main branch and auxiliary branch output density maps respectively, and perform supervised comparison with the real density maps to calculate the corresponding density estimation losses, denoted as L. main With L aux And apply structural consistency constraint loss L to the output layer. cons This encourages the main branch to learn the regions of interest of the auxiliary branches. Furthermore, to further suppress background noise, a background suppression loss term L is introduced during training. bgThe model is penalized for non-zero density values predicted by the main branch in non-foreground regions, thus guiding the model to reduce its response to background regions.
[0079] Through the joint optimization of the above-mentioned structural distillation mechanism and foreground guidance strategy, the main branch can focus more on the target area during training, thereby achieving higher accuracy in density map prediction and soybean pod counting performance, which is especially suitable for challenging agricultural image scenarios such as severe occlusion and complex backgrounds.
[0080] Step 4: The optimized model is used to identify soybean pod density.
[0081] Figure 1 The flowchart illustrating the implementation of this invention in the inference phase demonstrates how the system efficiently predicts the number of soybean pods based on the trained main branch network during actual deployment or application. In this phase, the system structure is simplified, retaining only the main branch network and discarding the auxiliary branches used for guidance and optimization during the training phase. This significantly reduces the computational complexity and resource consumption of the model, achieving lightweight design and making it more suitable for applications with high real-time and lightweight requirements, such as agricultural production sites and mobile terminals.
[0082] Specifically, the input for the inference stage is the original image of the soybean plant. This image, after being resized and normalized, is then input into the main branch network. The main branch first extracts the low-level visual features of the image through the front-end convolutional module, and then performs multi-scale feature fusion to fully integrate the feature information of soybean pods at different levels, thereby improving the model's ability to represent complex target structures.
[0083] At the back end of the main branch, multi-branch convolutions with different dilation rates are combined with CBAM attention to enhance the model's ability to model dense target regions. Dilated convolutions can achieve multi-scale contextual information fusion without significantly increasing computational overhead, enabling the model to maintain good target recognition capabilities even when dealing with complex situations such as overlapping pods and occlusion. Finally, the main branch outputs a density map, where each pixel value represents the density of soybean pods in its corresponding region. By integrating the pixel values of the density map, the total number of soybean pods in the entire image can be accurately estimated.
[0084] The greatest advantage of this inference structure is that, while maintaining the performance improvement brought about by structural distillation training, it successfully removes the computational burden of auxiliary branches, enabling the model to have both high prediction accuracy and deployment flexibility, significantly improving response speed and device adaptability, and achieving lightweighting of the method and system.
[0085] This invention presents a lightweight intelligent soybean pod counting system based on an optimized main-branch neural network design. Built upon a main-branch neural network structure, this system integrates key modules such as image input, deep feature learning, density map regression, and result visualization, achieving end-to-end intelligent processing of soybean pod counting tasks. The system first receives images of soybean plants through the image input module. Then, the main-branch density estimation module performs feature extraction, feature enhancement, and density map generation, forming the core of the entire inference process. The counting module converts the generated density map into the target total count and provides a visual output for easy user understanding and use. The system is compact, computationally inefficient, supports integration with agricultural image acquisition terminals, is compatible with edge computing devices, and possesses excellent deployment flexibility and real-time response capabilities, enabling efficient operation in complex environments such as fields. Due to its efficiency and practicality, this system is particularly suitable for agricultural production scenarios with high requirements for real-time performance and resource utilization, and has promising prospects for widespread application.
[0086] The above description is only for the purpose of helping to understand the method and core essence of the present invention, but the scope of protection of the present invention is not limited thereto. For those skilled in the art, any equivalent substitutions or modifications made to the technical solution and inventive concept disclosed in the present invention within the scope of the technology disclosed in the present invention should be covered within the scope of protection of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A lightweight soybean pod counting method based on structural distillation and foreground guidance, characterized in that, Includes the following steps: S1. Construct a soybean pod density estimation model. The soybean pod density estimation model adopts a main-auxiliary dual-branch neural network architecture. The auxiliary branch neural network is guided by a foreground mask to generate a structurally enhanced pod density map, which is used to guide the main branch neural network to focus on the real pod area to generate the pod density map. S2. Design a structured density-supervised quaternary loss function, including main branch density loss, auxiliary branch density loss, main-auxiliary consistency distillation loss, and background suppression loss; S3. The soybean pod density estimation model is trained and optimized. Based on the structural distillation mechanism and the prospect guidance strategy, the main branch neural network learns the structural expression of the auxiliary branch neural network during the training phase, and the soybean pod density estimation model is optimized based on the loss function. S4. Using the main branch neural network in the optimized soybean pod density estimation model, process the images of soybean plants to be counted and estimate the total number of soybean pods.
2. The lightweight soybean pod counting method based on structured distillation and foreground guidance according to claim 1, characterized in that, The soybean pod density estimation model in S1 is as follows: Auxiliary branch neural networks, including semantic segmentation models and auxiliary density estimation networks; The auxiliary branch neural network takes soybean plant images as input, performs foreground segmentation on the images based on the semantic segmentation model to generate a foreground mask, obtains a foreground image based on the foreground mask, and inputs it into the auxiliary density estimation network to generate a structure-enhanced pod density map. Main branch neural networks, including main density estimation networks; The main branch neural network takes soybean plant images as input, while the auxiliary branch neural network provides structural supervision signals to guide the main branch neural network to focus on the real pod region and generate a pod density map.
3. The lightweight soybean pod counting method based on structured distillation and foreground guidance according to claim 2, characterized in that, The auxiliary branch neural network and the main branch neural network are specifically as follows: An auxiliary branch neural network is used to input image I into the semantic segmentation model SegNet to extract the foreground pod region and obtain the foreground mask Mask. The foreground mask Mask is then multiplied with image I at the pixel level to obtain the foreground image I_F. Image I_F retains the pixels belonging to the pod target in image I and sets the rest to 0, thus masking the background. Subsequently, image I_F enters the auxiliary density estimation network and outputs the density map DM2 guided by the foreground. The main branch neural network takes image I as input and generates density map DM1.
4. The lightweight soybean pod counting method based on structure distillation and foreground guidance according to claim 2, characterized in that, Both the auxiliary density estimation network and the main density estimation network adopt the density estimation network DMENet, which includes a front-end module and a back-end module. The low-level visual features of the image are extracted through the front-end convolution module, and multi-scale feature fusion is performed. The backend module employs multi-branch convolutions with different dilation rates in conjunction with CBAM attention to enhance the modeling capability for dense target regions.
5. The lightweight soybean pod counting method based on structured distillation and foreground guidance according to claim 4, characterized in that, The front-end module and back-end module are specifically as follows: The front-end module consists of multiple stacked convolutional layers, which gradually extract the basic features of the image. Then, the feature maps at the last three scales are upsampled and downsampled and fused to achieve the integration of multi-scale feature information. The backend module adopts a multi-parallel structure, with each branch consisting of convolutional blocks with different dilation rates and a CBAM attention module. The dilated convolution expands the receptive field by setting different dilation rates. The CBAM attention module introduces channel attention and spatial attention mechanisms to enhance attention to key regions. Finally, the feature outputs of the multiple branches are fused and a pod density map is generated through single-channel convolution.
6. The lightweight soybean pod counting method based on structure distillation and foreground guidance according to claim 1, characterized in that, The structured density-supervised quaternary loss function in S2 is as follows: Main branch density loss L main The density map DM1 generated by the main branch neural network is used to ensure that it is consistent with the true density map GT. Specifically: L main =Sinkhorn(DM1,GT) Auxiliary branch density loss L aux To improve the accuracy of the density map DM2 generated by the auxiliary branch neural network, specifically: L aux =Sinkhorn(DM2,GT) Main and auxiliary consistency distillation loss L cons To encourage the density maps predicted by the main branch neural network and the auxiliary branch neural network to maintain a consistent overall distribution, the following is specifically used: L cons =Sinkhorn(DM1,DM2) Background suppression loss L bg This is used to suppress erroneous responses of the main branch neural network in the background region and highlight the foreground region, specifically: The final loss function is: L total =λ1L main +λ2L aux +λ3L cons +λ4L bg Among them, λ1, λ2, λ3, and λ4 are hyperparameters used to balance the impact of various losses; Sinkhorn is the optimal transmission distance.
7. The lightweight soybean pod counting method based on structured distillation and foreground guidance according to claim 6, characterized in that, The training phase in S3 is as follows: During training, the main branch neural network and the auxiliary branch neural network output density maps respectively, and these maps are compared with the real density maps under supervision to calculate the corresponding density loss L. main With L aux And apply a primary-auxiliary consistency distillation loss L to the output layer. cons This enables the main branch neural network to learn the region of interest of the auxiliary branch neural network; Background suppression loss L is introduced during training. bg The non-zero density values predicted by the main branch neural network in non-foreground regions are penalized, guiding the model to reduce its response to background regions.
8. A lightweight soybean pod counting system based on structured distillation and foreground guidance, characterized in that, include: The image input module is used to input the preprocessed soybean plant image into the main branch density estimation module. The main branch density estimation module uses the main branch neural network trained and optimized in any of the lightweight soybean pod counting methods based on structural distillation and foreground guidance as described in claims 1-7; it is used to generate a pod density map. The counting module is used to convert the pod density map into a target total number for visualization output.