An egg recognition method based on partial dynamic convolution and space-frequency modulation

CN123016164APending Publication Date: 2026-10-30SICHUAN AGRI UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202611417960.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-14
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

如公开号CN120507316A公开了一种基于多传感器融合的鸡蛋品质检测系统及方法,该方法通过整合光谱、压力、气味、振动四类传感器,构建数据采集 、特征提取、量化分析与决策输出全链条检测体系,解决了传统鸡蛋检测中人工主观性强、单一传感器覆盖维度有限、多指标协同决策精度低的问题

Benefits of technology

[0066]本发明的有益效果是:本发明显著提升了在复杂笼养环境中对鸡蛋的检测性能,针对主干网络提取特征存在许多冗余特征图,特别是为了应对遮挡干扰对鸡蛋识别与鸡只轮廓提取的影响,本发明设计了部分动态卷积(PartialDynamicConv),替换主干网络第三、四层Stageblock中的原始轻量卷积;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123016164A_ABST
    Figure CN123016164A_ABST
Patent Text Reader

Abstract

The application discloses an egg recognition method based on partial dynamic convolution and space-frequency modulation, and belongs to the field of intelligent breeding, comprising the following steps: constructing a partial dynamic convolution module, dynamically adjusting the convolution kernel weight through the attention mechanism of input dependence of a dynamic convolution channel, and reserving original features in an identity mapping channel to avoid information loss of a shielding area; constructing a space-frequency modulation feedforward module, suppressing cage net high-frequency noise while strengthening low-frequency core feature expression, and combining adaptive window selection to dynamically match a shielding scene; and constructing a pyramid sparse attention feature fusion module, fusing enhanced features of the partial dynamic convolution and fine-grained features output by the space-frequency modulation feedforward module, guiding through coarse-grained semantics and repairing through fine-grained details, and solving the problems of egg feature fracture and shielding difficulty in a complex cage breeding scene in a cooperative manner. The application significantly improves the recognition performance of eggs in a complex cage breeding scene with serious shielding, complex cage nets and dense egg production.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of smart farming, and in particular to an egg recognition method based on partial dynamic convolution and spatial frequency modulation. Background Technology

[0002] Eggs, as a high-protein, nutrient-rich primary agricultural product, are an important part of the diet of Chinese residents and the third largest livestock product after pigs and milk. Their rich nutritional content and moderate cost make them one of the most commonly consumed animal-based foods in the world. Poultry production continues to develop; data from the National Bureau of Statistics shows that my country's egg production reached approximately 25.913 million tons in 2025, a year-on-year increase of 4.46%. With the improvement of the egg-laying hen farming industry, traditional farming methods are no longer suitable for the requirements of modern large-scale production, leading to the emergence of tiered and stacked cage rearing technologies. The rapid development of large-scale cage rearing technology has resulted in an increasingly prominent market demand for precise egg testing. As poultry farming transforms towards large-scale, intensive, mechanized, and intelligent operations, egg collection is also gradually upgrading from traditional manual labor to mechanized, automated, and intelligent processes. However, automated collection still faces core challenges: the urgent need for accurate identification of qualified eggs, unqualified eggs, and eggs remaining in the cages to effectively improve collection efficiency, reduce breakage rates, and provide data support for egg production testing and hen culling.

[0003] Currently, researchers in the field of egg quality testing have designed several methods to detect egg quality. For example, publication number CN120507316A discloses an egg quality testing system and method based on multi-sensor fusion. This method integrates four types of sensors—spectral, pressure, odor, and vibration—to construct a complete detection system encompassing data acquisition, feature extraction, quantitative analysis, and decision output. This solves the problems of strong human subjectivity, limited coverage of single sensors, and low accuracy of multi-indicator collaborative decision-making in traditional egg testing. However, if there are many stains on the surface of the egg, it will interfere with the extraction of spectral texture features and the acquisition of excitation sound pressure signals, leading to an increase in the false crack rate. Publication No. CN119540145A discloses a non-destructive image recognition method and system for eggshell cracks, which combines dynamic programming image segmentation and lightweight deep learning network to achieve non-destructive and accurate recognition of eggshell cracks. It solves the problems of low efficiency and strong subjectivity of traditional manual visual inspection, as well as the inaccurate segmentation of crack areas and large number of model parameters of existing image detection methods. However, this solution does not take into account that in real chicken coop environments, the lighting is mostly a mixture of natural light and artificial light, with large fluctuations in light intensity. In addition, chicken coop cages will interfere with target detection and the hardware cost is high, far exceeding the equipment budget of small and medium-sized chicken coops. Publication No. CN117392069A discloses an egg quality inspection method, system, equipment and storage medium, which addresses the issue of dark spots on eggshells. This paper proposes a method for detecting egg quality based on the fusion of different spectral features. This method addresses the issues of low efficiency and high subjectivity in traditional manual egg candling, as well as the high rate of missed detection of small dark spots and large deviations in the calculation of dark spot proportions in existing single-model detection methods. However, dark spot information requires highly skilled annotators who can distinguish between dark spots, stains, and textures. Large-scale dataset construction is costly, and the coverage of dark spot types is incomplete, limiting its applicability to various scenarios. Publication number CN108872095A discloses an egg quality detection method based on the fusion of different spectral features. Targeting the egg yolk as an internal quality carrier, it combines a hyperspectral imager and a ground object spectrometer to cover both raw and cooked yolk states, achieving accurate identification of egg quality and freshness. This solves the problems of high subjectivity in traditional manual detection, existing spectral detection focusing only on the outer shell, and insufficient reliability of single-instrument data. However, this method involves destructive testing, making it unsuitable for non-destructive scenarios, and has low detection efficiency. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings of the prior art and provide an egg recognition method based on partial dynamic convolution and spatial frequency modulation, which can specifically solve the problem of interference of cage occlusion on target feature extraction, and effectively reduce the computational complexity of the model while significantly improving the accuracy of egg recognition in caged environments.

[0005] The objective of this invention is achieved through the following technical solution: an egg identification method based on partial dynamic convolution and spatial frequency modulation, comprising:

[0006] S1. In caged egg detection scenarios, targets are easily obscured by cage netting, and low light interference can cause feature loss. Information in low-contrast areas is easily lost. Furthermore, single dynamic convolution can lead to over-processing of features and insufficient robustness of the model in various environments. This invention addresses these technical issues by constructing a partially dynamic convolution module: dividing the model into dynamic convolution channels and identity mapping channels with a fixed channel ratio. The dynamic convolution channels dynamically adjust the kernel weights through an input-dependent attention mechanism, while the identity mapping channels directly retain the original features to avoid information loss in obscured areas. This channel ratio ensures the flexibility of dynamic enhancement to adapt to obscured and low-light scenarios, while retaining most of the original features and avoiding information loss in low-contrast areas through the identity channels, effectively improving the model's robustness in complex caged egg environments.

[0007] S2. In the scenario of cage net occlusion, the feature extraction of eggs is easily affected by high-frequency noise, and non-target interference information cannot be filtered out and the discriminative contour features of the target are difficult to effectively enhance. To address this problem, the present invention constructs a space-frequency modulation feedforward module: through multi-window frequency domain modulation, the frequency domain features of the occluded target are processed in a targeted manner. On the one hand, it suppresses high-frequency occlusion noise from the cage net and eliminates non-target interference information. On the other hand, it enhances the low-frequency contour features of the egg and strengthens the discriminative information of the target, thereby improving the robustness of the model in feature extraction in the occlusion scenario.

[0008] S3. In caged environments, eggs in the egg tray are easily obscured by the cage mesh, and eggs left in the cage are easily obscured by the legs of chickens, leading to feature fragmentation and breakage. This results in the inability to effectively integrate global semantics and fine-grained details, and makes it difficult to accurately enhance key local features such as egg cracks, feces and bloodstains on the eggshell surface. To address this technical problem, this invention constructs a pyramid sparse attention feature fusion module: after the encoder completes upsampling and downsampling, it selectively fuses the enhanced global semantic features output by some dynamic convolution with the fine-grained detail features output by the space-frequency modulation feedforward module. Based on the global semantics of the egg's circular structure, it establishes the association between the obscured and unobscured areas through coarse-grained semantic guidance to complete the fragmented egg features. At the same time, it accurately enhances the effective local information such as egg cracks, feces and bloodstains on the eggshell surface through fine-grained detail repair, thus collaboratively solving the feature fragmentation problem of eggs in obscured scenarios.

[0009] Further, step S1 includes:

[0010] S101. Perform channel splitting on the input feature map, according to a fixed splitting ratio. The channel is split into a dynamic convolution channel and an identity mapping channel, and the calculation formula is as follows:

[0011]

[0012]

[0013] in , representing the input feature map, The features represent those to be processed by dynamic convolution. Represents the identity mapping characteristic; total number of channels , The number of channels in the dynamic convolution. The identity mapping channel number is given, and H and W represent the height and width of the input feature map, respectively; the splitting ratio is fixed. ;

[0014] The dynamic convolution channel focuses on the key features of the non-occluded region and adaptively enhances them, while the identity mapping channel specifically preserves the original feature information of the occluded region to avoid losing the original features.

[0015] The input feature map refers to the feature map obtained by feeding the image of the eggs taken in the caged scene into the HGNetV2 network;

[0016] S102. Construct a dual-branch parallel structure to handle the occlusion problem:

[0017] Branch 1 addresses key visual features caused by occlusion by introducing a dynamic convolution mechanism to the dynamic convolution channels:

[0018] To avoid the loss of features in occluded areas due to overprocessing, branch two does not perform additional operations on the identity mapping channel and directly retains the original features, ensuring stable feature representation in severely occluded areas or low-contrast occluded edges, thus improving the model's ability to retain detailed information in occluded areas.

[0019] S103. The output features of the two branches are spliced ​​along the channel dimension to fuse the dynamically enhanced non-occluded key features and the identity-preserved occluded region features, making full use of their complementarity in occluded scenarios.

[0020] Subsequently, the fused features are compressed and adjusted in channel dimension using a 1×1 convolution. The final output formula for the occluded region is as follows:

[0021]

[0022] in, and These represent the number of input channels and the number of output channels of the feature map, respectively. This represents element-wise weighted summation, with each input feature map maintaining the same height, width, and number of channels, resulting in no change in the number of channels after fusion. Features from the dynamic convolution branch and the identity mapping branch are concatenated and then subjected to a 1×1 convolution. A unified output channel ensures flexible adaptation of module input and output dimensions.

[0023] In branch one, global context information is first extracted using global average pooling, followed by the generation of dynamic weight coefficients related to the input using a lightweight MLP. The calculation formula is as follows:

[0024]

[0025]

[0026] in, This is a global average pooling operation. To enable learnable weights and biases in lightweight MLPs, Representative input feature map The feature vectors of all channels at spatial coordinates (i, j); For feature flattening operation; Using the Sigmoid activation function, with an output range of (0, 1), attention weight coefficients are generated. , M represents the number of expert convolution kernels, which are the weight coefficients corresponding to the M expert convolution kernels. The expert convolution kernels dynamically adjust the convolution response according to the position, range and degree of the occlusion area, focusing on and enhancing the features of the key non-occlusion area, and weakening the interference of the occlusion area.

[0027] Next, the M expert convolutional kernels are weighted and fused to construct an adaptive dynamic convolutional kernel; this dynamic convolution module contains M groups of expert convolutional kernels {K1, K2, ..., K...} M}, based on weight Adaptive fusion convolution kernel:

[0028]

[0029] Dynamic convolution output:

[0030]

[0031] Final branch output:

[0032]

[0033] in, Represents batch normalization. For activation functions, based on Dynamically fuse the outputs of multiple convolutional kernels to adapt to local patterns of different input features;

[0034] Further, step S2 includes:

[0035] S201. The feature map processed in step S1 is first compressed and expanded by 1×1 group convolution to remove redundant noise information, thereby improving computational efficiency and reducing the number of parameters.

[0036] Subsequently, a nonlinear transformation is introduced through the CGLU activation function to enhance the ability to distinguish between targets and noise in occluded areas;

[0037] Finally, 1×1 grouped convolutions are used again to map the features back to the original number of channels, achieving dimensional alignment and reconstruction of effective information under occlusion conditions. This constructs a lightweight feedforward mapping path that is resistant to noise interference. The calculation formula is as follows:

[0038]

[0039] in This represents a grouped 1×1 convolution. This represents the activation function GELU. The output features of the feedforward network;

[0040] S202. To address the damage to target characteristics caused by high-frequency obstruction noise from the cage mesh, a dual-branch frequency modulation structure is designed, constructing frequency domain processing branches with window sizes of 2×2 and 4×4 respectively:

[0041] 2×2 window branch: Focusing on small target areas such as mini eggs that are easily obscured by cage nets and chicken legs, and eggs left in the cage, the frequency domain-spatial domain joint transformation is used to accurately suppress high-frequency noise components brought by cage nets in the frequency domain, while selectively enhancing fine-grained features of egg edges and textures that are easily obscured.

[0042] 4×4 window branch: Covers a larger receptive field. For a normal-sized egg that is partially occluded, it focuses on enhancing the low-frequency contour features remaining after being occluded by the cage net in the frequency domain, while suppressing interference information related to occlusion in the background, so as to effectively reconstruct the overall shape of the egg.

[0043] The frequency domain features are obtained by performing a two-dimensional fast Fourier transform on the two window branches. Frequency truncation is performed on the frequency domain features to filter out high-frequency noise components corresponding to the cage mesh and remove invalid background interference, thus obtaining the frequency domain features after frequency truncation. Subsequently, the truncated frequency domain features are subjected to element-wise complex weighting to adaptively enhance target feature frequencies and suppress occlusion noise frequencies, thereby improving the model's adaptability to targets of different scales. The calculation formula is as follows:

[0044]

[0045] in, This represents the characteristics of the feedforward network (FFN) output. This indicates an operation that divides the feature window according to its size. This represents a two-dimensional Fast Fourier Transform. The frequency domain features are defined for the i-th window size; frequency truncation is performed on... Perform frequency domain masking filtering to remove high-frequency components corresponding to the cage mesh blockage;

[0046] S203. Construct a window selector to achieve dynamic fusion of multi-window output. First, perform global average pooling on the input features to extract global statistical features containing occlusion distribution information.

[0047] The features are then mapped to the number of windows using 1×1 convolution, and the fusion weight coefficients for each window are generated by Softmax normalization. ;

[0048] The contribution of each branch is dynamically adjusted according to the degree of regional occlusion: for areas with severe occlusion by the cage net, the weight of the corresponding window is increased to focus on key frequency components; for areas with light occlusion, the weight of each window is kept balanced to achieve comprehensive feature capture.

[0049] Weighted fusion driven by occlusion level enhances the model's robustness to feature responses of multiple egg targets in complex caged scenarios. The calculation formula is as follows:

[0050]

[0051] The characteristics are those after frequency truncation and complex weighted modulation. This represents the frequency domain characteristics after frequency truncation. The weights are represented as learnable complex numbers adapted to the truncated frequency size; the final output of the occluded region is a multi-scale feature map. :

[0052]

[0053] This represents the inverse operation of window partitioning. Indicates the fast inverse Fourier transform. To adapt to window weights, This is the final output of the space frequency modulation feedforward module; when i=1, it represents the first window branch, i.e., the 2×2 window branch, and when i=2, it represents the second window branch, i.e., the 4×4 window branch.

[0054] Further, step S3 includes:

[0055] S301. Obtain the multi-scale feature map obtained in step S203, perform upsampling and downsampling processing to obtain feature maps with different spatial resolutions, and then use 1×1 convolution to unify the channels of the feature map and map it to the same dimension; at the same time, preserve the spatial resolution of the feature map to ensure the integrity of occlusion details in multi-scale information. Combine the feature map output in step S1, and after unifying the channels of the feature map by 1×1 convolution, use it as the input of the pyramid sparse attention feature fusion module PST.

[0056] S302. Design the Pyramid Sparse Attention Feature Fusion Module (PST) to replace the traditional simple splicing method:

[0057] The PST module uses low-resolution features as keys and high-resolution features as queries, and uses a cross-attention mechanism to guide and enhance low-level details through high-level semantics; where low-resolution features are high-level semantic features and high-resolution features are low-level detail features.

[0058] The PST module adopts a two-stage strategy from coarse to fine: in the coarse-grained stage, the feature map is divided into 4×4 blocks, and the pixel with the highest feature response value in each block is selected as the key pixel.

[0059] In the fine-grained stage, neighborhood feature refinement is performed on the key pixels selected in the coarse-grained stage to accurately capture local details of the egg in the occluded scene, such as the continuous outline of the eggshell crack and the texture distribution of the stain, to make up for the loss of fine-grained information by sparse sampling.

[0060] S303. Construct a bidirectional fusion path to achieve top-down and bottom-up information interaction:

[0061] Top-down approach: High-level semantic information is upsampled and fused with low-level features to enhance the low-level features' ability to perceive targets in occluded areas;

[0062] Bottom-up approach: Low-level detailed information is fused with high-level features through downsampling to supplement the spatial localization capabilities of high-level features;

[0063] A PST module is introduced at each fusion node to replace the traditional stitching operation, enabling the content to adaptively focus on occlusion-related features and achieve sparse and efficient cross-layer feature fusion.

[0064] S304. Output the fused multi-scale feature maps hierarchically as input to the subsequent RepNCSPELAN4 module and Decoder. The fused features must meet the following requirements: high-level semantics can effectively guide low-level features to identify occluded areas; low-level texture information can fully supplement the localization accuracy of high-level features.

[0065] The fusion process reduces computation through Top-K selection of pyramid sparse attention; the fused features have stronger semantic consistency, providing reliable feature support for target recognition in subsequent occluded scenarios; the output multi-scale features are further enhanced by RepNCSPELAN4 and then fed into the Decoder. The decoder uses the enhanced features to complete the detection, category discrimination and location regression of egg targets in caged scenarios, and outputs the egg recognition results.

[0066] The beneficial effects of this invention are: This invention significantly improves the detection performance of eggs in complex cage environments. In view of the fact that there are many redundant feature maps in the backbone network, especially in order to deal with the impact of occlusion interference on egg recognition and chicken contour extraction, this invention designs PartialDynamicConv to replace the original lightweight convolution in the third and fourth Stageblock layers of the backbone network.

[0067] By utilizing a dynamic coefficient generation mechanism, we can accurately preserve and dynamically enhance local key details, significantly improve feature discriminativeness, avoid computational redundancy caused by global dynamic convolution, and balance feature extraction efficiency and accuracy.

[0068] The Spatial Frequency Modulation Feedforward (SMF) module is designed to improve the model's ability to perceive small targets like eggs and key features in occluded environments by focusing on local details of the target in the spatial domain and suppressing noise interference caused by illumination changes and low contrast in the frequency domain, while maintaining low computational overhead.

[0069] A pyramid sparse attention feature fusion module (PST) is introduced, which utilizes its coarse-to-fine cross-layer attention mechanism to guide the sparse selection of low-level features through high-level features, thereby achieving efficient, sparse, and content-adaptive cross-layer feature fusion.

[0070] This system overcomes the shortcomings of traditional target detection algorithms under conditions of occlusion, lighting changes, and low contrast. The detection model provides high-precision, low-resource-consumption technical support for poultry farming scenarios such as egg sorting, automated egg collection, and chicken culling, demonstrating clear industrial application value. Attached Figure Description

[0071] Figure 1 This is a flowchart of the method of the present invention;

[0072] Figure 2 Here is a structural diagram of a portion of the dynamic convolution module;

[0073] Figure 3 This is a structural diagram of the space frequency modulation feedforward module. Detailed Implementation

[0074] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings, but the scope of protection of the present invention is not limited to the following description.

[0075] like Figure 1 As shown, to make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be described more clearly and completely below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of this application provided below with reference to the accompanying drawings is not intended to limit the scope of protection of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application. The present invention will be further described below with reference to the accompanying drawings.

[0076] like Figure 1 As shown, this invention specifically relates to an egg recognition method based on partial dynamic convolution and spatial frequency modulation, which can effectively overcome the influence of low lighting in the cage and obstruction by the egg tray and cage on egg detection; specifically, it includes the following:

[0077] S1. To address the technical problems in caged egg detection scenarios, such as target occlusion by cage netting, low light interference leading to feature loss, loss of information in low-contrast areas, and the tendency of single dynamic convolution to overprocess features and insufficient robustness of the model in complex environments, this invention constructs a partially dynamic convolution module: dividing the model into dynamic convolution channels and identity mapping channels with a fixed channel ratio. The dynamic convolution channels dynamically adjust the kernel weights through an input-dependent attention mechanism to enhance features in areas of the egg occluded by cage netting and chicken legs in caged environments. The identity mapping channel directly retains the original features to avoid loss of information in occluded areas. The dual-channel design ensures the flexibility of dynamic enhancement to adapt to occlusion and low-light scenarios, while retaining most of the original features and avoiding loss of information in low-contrast areas through identity mapping, effectively improving the detection robustness of the model in complex caged environments.

[0078] S2. To address the technical problems of egg target feature extraction being susceptible to high-frequency noise interference in cage net occlusion scenarios, the inability to filter out non-target interference information, and the difficulty in effectively enhancing the target discriminative contour features, this invention constructs a space-frequency modulation feedforward module; through multi-window frequency domain modulation, the frequency domain features of the occluded target are processed in a targeted manner, on the one hand suppressing high-frequency occlusion noise from the cage net and eliminating non-target interference information, and on the other hand enhancing the low-frequency contour features of the egg and strengthening the target discriminative information, thereby improving the robustness of the model in feature extraction in occlusion scenarios;

[0079] S3. Addressing the technical challenges of fragmented and broken features caused by cage mesh and occlusion by chicken legs in caged environments, particularly the inability to effectively integrate global semantics and fine-grained details, and the difficulty in precisely enhancing key local features such as egg cracks, feces, and bloodstains on the eggshell surface, this invention constructs a pyramid sparse attention feature fusion module. After upsampling and downsampling by the encoder, the enhanced global semantic features output by some dynamic convolutions are specifically fused with the fine-grained detail features output by the spatial frequency modulation feedforward module. Based on the global semantics of the egg's circular structure, coarse-grained semantic guidance is used to establish a connection between occluded and unoccluded areas to complete the fragmented egg features. Simultaneously, fine-grained detail repair precisely enhances effective local information such as egg cracks, feces, and bloodstains on the eggshell surface, collaboratively solving the feature fragmentation problem of eggs in occluded scenarios.

[0080] In step S1, the construction of partially dynamic convolutional modules involves a collaborative design of dynamic enhancement and original feature preservation. For example, partially dynamic convolutional modules include... Figure 2 As shown, reducing the damage to target features caused by cage net occlusion specifically includes the following:

[0081] S101, Channel Splitting: To address the issues of easy loss of features and noise interference in occluded areas during cage rearing, the input feature map is divided into dynamic convolution channels and identity mapping channels along the channel dimension at a fixed ratio: the dynamic convolution channels are responsible for adaptive feature enhancement in occluded scenarios, avoiding excessive noise amplification caused by single-channel processing; the identity mapping channels do not perform additional calculations, preserving the original details of the eggs under the occlusion of cages and chicken legs;

[0082] The input feature map refers to the feature map obtained by feeding the image of the eggs taken in the caged scene into the backbone network (HGNetV2);

[0083] S102, Routing Network: It performs global perception of input features, focuses on capturing key information such as cage network distribution and occlusion area location, and generates k dynamic weighting coefficients that are strongly correlated with the occlusion scene, providing a basis for subsequent adaptive adjustment of convolutional kernels;

[0084] S103, Conditional Convolution: Encapsulate k independent expert convolution kernels, and combine these expert kernels by weighting coefficients α generated by the routing network to obtain a dynamic kernel that adapts to the current input occlusion situation, while suppressing cage net occlusion and background clutter;

[0085] S104. Feature Concatenation and Compression: The occlusion enhancement features output by the dynamic convolution channel and the original detail features retained by the identity mapping channel are concatenated along the channel dimension to make full use of their complementarity in anti-occlusion. Then, 1×1 group convolution is used to unify the number of channels and eliminate redundant information introduced during the concatenation process, further improving the discriminative power of target features in occlusion scenarios and completing the extraction of basic anti-occlusion features.

[0086] In the embodiments of this application, the space-frequency modulation feedforward module in S2 accurately suppresses occlusion noise and enhances the characteristics of occluded targets through targeted frequency domain modulation and adaptive window selection. The space-frequency modulation feedforward module is as follows: Figure 3 As shown, it specifically includes the following:

[0087] S201, Basic Feature Transformation: 1×1 grouped convolution is used on the input feature map to perform channel shifting, reducing computational overhead while initially separating occlusion noise from target information. Subsequently, nonlinearity is introduced through the CGLU activation function to enhance the ability to distinguish between the egg outline and cage noise in the occluded region, mapping the features to a feature space that makes it easier to identify the occluded target;

[0088] S202, Multi-window frequency modulation: Two parallel branches are constructed to differentiate the occlusion characteristics of targets of different scales: The 2×2 window branch focuses on small target areas such as mini eggs and stranded eggs that are easily occluded by dense cage nets. Through frequency domain-spatial domain joint transformation, high-frequency occlusion noise of cage nets is accurately suppressed in the frequency domain; The 4×4 window branch covers a larger receptive field and is adapted to large targets such as normal-sized eggs that are easily partially occluded. Through frequency domain modulation, the residual mid-low frequency contour features after occlusion are enhanced to achieve effective reconstruction of the overall shape of the egg.

[0089] S203, Adaptive Window Fusion: This method dynamically adapts to different occlusion levels using a window selector. Global average pooling is applied to the input features to extract global statistical information including occlusion distribution and intensity. Normalized weights for each window are generated through 1×1 convolution and a Softmax activation function. These weights are dynamically adjusted based on scene changes such as occlusion and lighting. Finally, the multi-window outputs are weighted and summed to obtain low-redundancy, high-discriminative quality and location joint features.

[0090] In the embodiments of this application, step S3, which involves constructing a pyramid sparse attention feature fusion module to repair feature breaks caused by occlusion, specifically includes the following steps:

[0091] S301. Obtain the multi-scale feature map obtained in step S203, perform upsampling and downsampling processing to obtain feature maps with different spatial resolutions, and then use 1×1 convolution to unify the channels of the feature map and map it to the same dimension; at the same time, preserve the spatial resolution of the feature map to ensure the integrity of occlusion details in multi-scale information. Combine the feature map output in step S1, and after unifying the channels of the feature map by 1×1 convolution, use it as the input of the pyramid sparse attention feature fusion module PST.

[0092] S302. Design the Pyramid Sparse Attention Feature Fusion Module (PST) to replace the traditional simple splicing method:

[0093] The PST module uses low-resolution features as keys and high-resolution features as queries, and uses a cross-attention mechanism to guide and enhance low-level details through high-level semantics; where low-resolution features are high-level semantic features and high-resolution features are low-level detail features.

[0094] The PST module adopts a two-stage strategy from coarse to fine: in the coarse-grained stage, the feature map is divided into 4×4 blocks, and the pixel with the highest feature response value in each block is selected as the key pixel.

[0095] In the fine-grained stage, neighborhood feature refinement is performed on the key pixels selected in the coarse-grained stage to accurately capture local details of the egg in the occluded scene, such as the continuous outline of the eggshell crack and the texture distribution of the stain, to make up for the loss of fine-grained information by sparse sampling.

[0096] S303. Construct a bidirectional fusion path to achieve top-down and bottom-up information interaction:

[0097] Top-down approach: High-level semantic information is upsampled and fused with low-level features to enhance the low-level features' ability to perceive targets in occluded areas;

[0098] Bottom-up approach: Low-level detailed information is fused with high-level features through downsampling to supplement the spatial localization capabilities of high-level features;

[0099] A PST module is introduced at each fusion node to replace the traditional stitching operation, enabling the content to adaptively focus on occlusion-related features and achieve sparse and efficient cross-layer feature fusion.

[0100] S304. Output the fused multi-scale feature maps hierarchically as input to the subsequent RepNCSPELAN4 module and Decoder. The fused features must meet the following requirements: high-level semantics can effectively guide low-level features to identify occluded areas; low-level texture information can fully supplement the localization accuracy of high-level features.

[0101] The fusion process reduces computation through Top-K selection of pyramid sparse attention; the fused features have stronger semantic consistency, providing reliable feature support for target recognition in subsequent occluded scenarios; the output multi-scale features are further enhanced by RepNCSPELAN4 and then fed into the Decoder, which is a general Transformer detection and decoding structure. Based on the enhanced features, the decoder completes the detection, category discrimination and position regression of egg targets in caged scenarios, and outputs the egg recognition results.

[0102] The above description is merely a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. It can be used in various other combinations, modifications, and improvements, and can be altered within the scope of the concept described herein through the above teachings or related technologies or knowledge. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention should be within the protection scope of the appended claims.

Claims

1. An egg recognition method based on partial dynamic convolution and spatial frequency modulation, characterized in that: Includes the following steps: Step S1: Construct a partial dynamic convolution module to process the input feature map: Divide the dynamic convolution channel and the identity mapping channel into a fixed channel ratio. The dynamic convolution channel dynamically adjusts the convolution kernel weights through an input-dependent attention mechanism, while the identity mapping channel directly retains the original features to avoid the loss of information in occluded areas. Step S2: Construct a space-frequency modulation feedforward module: Perform targeted processing on the frequency domain features of the occluded target through multi-window frequency domain modulation, suppress high-frequency occlusion noise, eliminate non-target interference information, enhance low-frequency contour features, strengthen target discriminative information, and improve the robustness of feature extraction in occluded scenarios. Step S3: Construct a pyramid sparse attention feature fusion module: After the encoder completes upsampling and downsampling, the enhanced global semantic features output by some dynamic convolutions are fused with the fine-grained detail features output by the spatial frequency modulation feedforward module. The association between occluded and unoccluded regions is established through coarse-grained semantic guidance, while local effective information is repaired through fine-grained details.

2. The egg recognition method based on partial dynamic convolution and spatial frequency modulation according to claim 1, characterized in that: Step S1 includes: S101. Perform channel splitting on the input feature map, according to a fixed splitting ratio. The channel is split into a dynamic convolution channel and an identity mapping channel, and the calculation formula is as follows: ; ; in , representing the input feature map, The features represent those to be processed by dynamic convolution. Represents the identity mapping characteristic; total number of channels , The number of channels in the dynamic convolution. The identity mapping channel number is given, and H and W represent the height and width of the input feature map, respectively; the splitting ratio is fixed. ; The dynamic convolution channel focuses on the key features of the non-occluded region and adaptively enhances them, while the identity mapping channel specifically preserves the original feature information of the occluded region to avoid losing the original features. The input feature map refers to the feature map obtained by feeding the image of the eggs taken in the caged scene into the HGNetV2 network; S102. Construct a dual-branch parallel structure to handle the occlusion problem: Branch 1 addresses key visual features caused by occlusion by introducing a dynamic convolution mechanism to the dynamic convolution channels: To avoid the loss of features in occluded areas due to overprocessing, branch two does not perform additional operations on the identity mapping channel and directly retains the original features, ensuring stable feature representation in severely occluded areas or low-contrast occluded edges, thus improving the model's ability to retain detailed information in occluded areas. S103. The output features of the two branches are spliced ​​along the channel dimension to fuse the dynamically enhanced non-occluded key features and the identity-preserved occluded region features, making full use of their complementarity in occluded scenarios. Subsequently, the fused features are compressed and adjusted in channel dimension using a 1×1 convolution. The final output formula for the occluded region is as follows: ; in, and These represent the number of input channels and the number of output channels of the feature map, respectively. This represents element-wise weighted summation, with each input feature map maintaining the same height, width, and number of channels, resulting in no change in the number of channels after fusion. Features from the dynamic convolution branch and the identity mapping branch are concatenated and then subjected to a 1×1 convolution. A unified output channel ensures flexible adaptation of module input and output dimensions.

3. The egg recognition method based on partial dynamic convolution and spatial frequency modulation according to claim 2, characterized in that: In branch one, global context information is first extracted using global average pooling, followed by the generation of dynamic weight coefficients related to the input using a lightweight MLP. The calculation formula is as follows: ; ; in, This is a global average pooling operation. To enable learnable weights and biases in lightweight MLPs, Representative input feature map The feature vectors of all channels at spatial coordinates (i, j); For feature flattening operation; Using the Sigmoid activation function, with an output range of (0, 1), attention weight coefficients are generated. , M represents the number of expert convolution kernels, which are the weight coefficients corresponding to the M expert convolution kernels. The expert convolution kernels dynamically adjust the convolution response according to the position, range and degree of the occlusion area, focusing on and enhancing the features of the key non-occlusion area, and weakening the interference of the occlusion area. Next, the M expert convolutional kernels are weighted and fused to construct an adaptive dynamic convolutional kernel; this dynamic convolution module contains M groups of expert convolutional kernels {K1, K2, ..., K...} M }, based on weight Adaptive fusion convolution kernel: ; Dynamic convolution output: ; Final branch output: ; in, Represents batch normalization. For activation functions, based on The outputs of multiple convolutional kernels are dynamically fused to adapt to local patterns of different input features.

4. The egg recognition method based on partial dynamic convolution and spatial frequency modulation according to claim 1, characterized in that: Step S2 includes: S201. The feature map processed in step S1 is first compressed and expanded by 1×1 group convolution to remove redundant noise information, thereby improving computational efficiency and reducing the number of parameters. Subsequently, a nonlinear transformation is introduced through the CGLU activation function to enhance the ability to distinguish between targets and noise in occluded areas; Finally, 1×1 grouped convolutions are used again to map the features back to the original number of channels, achieving dimensional alignment and reconstruction of effective information under occlusion conditions. This constructs a lightweight feedforward mapping path that is resistant to noise interference. The calculation formula is as follows: ; in This represents a grouped 1×1 convolution. This represents the activation function GELU. The output features of the feedforward network; S202. To address the damage to target characteristics caused by high-frequency obstruction noise from the cage mesh, a dual-branch frequency modulation structure is designed, constructing frequency domain processing branches with window sizes of 2×2 and 4×4 respectively: 2×2 window branch: Focusing on small target areas such as mini eggs that are easily obscured by cage nets and chicken legs, and eggs left in the cage, the frequency domain-spatial domain joint transformation is used to accurately suppress high-frequency noise components brought by cage nets in the frequency domain, while selectively enhancing fine-grained features of egg edges and textures that are easily obscured. 4×4 window branch: Covers a larger receptive field. For a normal-sized egg that is partially occluded, it focuses on enhancing the low-frequency contour features remaining after being occluded by the cage net in the frequency domain, while suppressing interference information related to occlusion in the background, so as to effectively reconstruct the overall shape of the egg. The frequency domain features are obtained by performing a two-dimensional fast Fourier transform on the two window branches. Frequency truncation is performed on the frequency domain features to filter out high-frequency noise components corresponding to the cage mesh and remove invalid background interference, thus obtaining the frequency domain features after frequency truncation. Subsequently, the truncated frequency domain features are subjected to element-wise complex weighting to adaptively enhance target feature frequencies and suppress occlusion noise frequencies, thereby improving the model's adaptability to targets of different scales. The calculation formula is as follows: ; in, This represents the characteristics of the feedforward network (FFN) output. This indicates an operation that divides the feature window according to its size. This represents a two-dimensional Fast Fourier Transform. The frequency domain features are defined for the i-th window size; frequency truncation is performed on... Perform frequency domain masking filtering to remove high-frequency components corresponding to the cage mesh blockage; S203. Construct a window selector to achieve dynamic fusion of multi-window output. First, perform global average pooling on the input features to extract global statistical features containing occlusion distribution information. The features are then mapped to the number of windows using 1×1 convolution, and the fusion weight coefficients for each window are generated by Softmax normalization. ; The contribution of each branch is dynamically adjusted according to the degree of regional occlusion: for areas with severe occlusion by the cage net, the weight of the corresponding window is increased to focus on key frequency components; for areas with light occlusion, the weight of each window is kept balanced to achieve comprehensive feature capture. Weighted fusion driven by occlusion level enhances the model's robustness to feature responses of multiple egg targets in complex caged scenarios. The calculation formula is as follows: ; The characteristics are those after frequency truncation and complex weighted modulation. This represents the frequency domain characteristics after frequency truncation. The weights are represented as learnable complex numbers adapted to the truncated frequency size; the final output of the occluded region is a multi-scale feature map. : ; This represents the inverse operation of window partitioning. Indicates the fast inverse Fourier transform. To adapt to window weights, This is the final output of the space frequency modulation feedforward module; when i=1, it represents the first window branch, i.e., the 2×2 window branch, and when i=2, it represents the second window branch, i.e., the 4×4 window branch.

5. The egg recognition method based on partial dynamic convolution and spatial frequency modulation according to claim 4, characterized in that: Step S3 includes: S301. Obtain the multi-scale feature map obtained in step S203, perform upsampling and downsampling processing to obtain feature maps with different spatial resolutions, and then use 1×1 convolution to unify the channels of the feature map and map it to the same dimension; at the same time, preserve the spatial resolution of the feature map to ensure the integrity of occlusion details in multi-scale information. Combine the feature map output in step S1, and after unifying the channels of the feature map by 1×1 convolution, use it as the input of the pyramid sparse attention feature fusion module PST. S302. Design the Pyramid Sparse Attention Feature Fusion Module (PST) to replace the traditional simple splicing method: The PST module uses low-resolution features as keys and high-resolution features as queries, and uses a cross-attention mechanism to guide and enhance low-level details through high-level semantics; where low-resolution features are high-level semantic features and high-resolution features are low-level detail features. The PST module adopts a two-stage strategy from coarse to fine: in the coarse-grained stage, the feature map is divided into 4×4 blocks, and the pixel with the highest feature response value in each block is selected as the key pixel. In the fine-grained stage, neighborhood feature refinement is performed on the key pixels selected in the coarse-grained stage to accurately capture local details of the egg in the occluded scene, such as the continuous outline of the eggshell crack and the texture distribution of the stain, to make up for the loss of fine-grained information by sparse sampling. S303. Construct a bidirectional fusion path to achieve top-down and bottom-up information interaction: Top-down approach: High-level semantic information is upsampled and fused with low-level features to enhance the low-level features' ability to perceive targets in occluded areas; Bottom-up approach: Low-level detailed information is fused with high-level features through downsampling to supplement the spatial localization capabilities of high-level features; A PST module is introduced at each fusion node to replace the traditional stitching operation, enabling the content to adaptively focus on occlusion-related features and achieve sparse and efficient cross-layer feature fusion. S304. Output the fused multi-scale feature maps hierarchically as input to the subsequent RepNCSPELAN4 module and Decoder. The fused features must meet the following requirements: high-level semantics can effectively guide low-level features to identify occluded areas; low-level texture information can fully supplement the localization accuracy of high-level features. The fusion process reduces computation through Top-K selection of pyramid sparse attention; the fused features have stronger semantic consistency, providing reliable feature support for target recognition in subsequent occluded scenarios; the output multi-scale features are further enhanced by RepNCSPELAN4 and then fed into the Decoder. The decoder uses the enhanced features to complete the detection, category discrimination and location regression of egg targets in caged scenarios, and outputs the egg recognition results.

Citation Information

Patent Citations

  • Egg quality detection method based on fusion of different spectrum characteristics

    CN108872095A

  • Egg quality detection method, system and equipment and storage medium

    CN117392069A

  • Lossless image recognition method and system for eggshell cracks

    CN119540145A

  • Egg quality detection system and method based on multi-sensor fusion

    CN120507316A