A Defect Detection Method for Ferrite Permanent Magnet Sheets Based on Cross-Scale Communication and Shared Detail Enhancement
By improving the YOLOv12 network architecture and combining spatial reweighting, cross-scale feature communication, and lightweight shared detail enhancement techniques, the problems of weak feature extraction and spatial misalignment in ferrite permanent magnet sheet defect detection were solved, achieving efficient and accurate defect detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG SCI-TECH UNIV
- Filing Date
- 2026-04-21
- Publication Date
- 2026-07-14
AI Technical Summary
Existing technologies struggle to accurately extract subtle defect features from ferrite permanent magnet sheets against a background of intense grinding texture, and also suffer from cross-scale spatial misalignment issues, resulting in low detection accuracy and high model deployment costs.
A defect detection model for ferrite permanent magnet sheets based on the YOLOv12 network architecture is adopted. The spatial reweighting module suppresses high-frequency background features, the cross-scale feature communication network module realizes multi-scale feature matching and fusion, and the lightweight shared detail enhancement detection head module extracts weak defect edge contour features.
Without increasing the number of model parameters, it significantly improves detection accuracy and inference efficiency, enabling robust quality inspection on industrial production lines, reducing false detection rates and enhancing the ability to locate minor defects.
Smart Images

Figure CN122391158A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method for detecting defects in ferrite permanent magnet sheets using a lightweight network architecture, specifically a method for detecting defects in ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement, belonging to the field of machine vision and intelligent industrial defect detection technology. Background Technology
[0002] Ferrite permanent magnet materials are widely used in key fields such as electronic communications, automotive industry, and micro-special motors due to their high coercivity, excellent corrosion resistance, and cost-effectiveness. However, in the complex pressing, sintering, and grinding processes, defects such as micro-cracks, edge grinding, pinholes, and chipped edges inevitably occur on the surface of ferrite permanent magnet sheets due to process fluctuations and environmental factors. These defects not only damage the product's appearance but also severely affect the uniformity of the magnetic circuit distribution and mechanical strength.
[0003] With the acceleration of modern industrial automation, traditional manual visual inspection, due to its high labor intensity, low efficiency, and high false negative rate, can no longer meet production demands. The rapid development of deep learning technology has brought new solutions to industrial defect detection. However, ferrite permanent magnet sheets have a dark gray surface with extremely low imaging contrast and are covered with dense grinding textures. This high-frequency background noise easily masks low-contrast defects such as microcracks, resulting in extremely low signal-to-noise ratios for features extracted by conventional convolutional networks and a persistently high false positive rate. Furthermore, the defect scales on the sheet surface vary greatly, ranging from micrometer-level cracks and pinholes to centimeter-level large-area edge chipping. Existing target detection networks (such as the native YOLO series) typically use rigid upsampling and stitching when performing multi-scale feature fusion, ignoring the semantic gap between deep semantics and shallow geometric features. This easily leads to misalignment of features in spatial distribution, causing serious deviations in the boundary localization of irregular defects. Furthermore, the edge gradient changes of many defects such as edge grinding and micro-chipping in ferrite permanent magnet sheets are extremely weak, and conventional convolution is difficult to capture their high-frequency contour information. While using complex large models based on Transformer, such as RT-DETR, can improve accuracy, its huge number of parameters and extremely high computational cost make it difficult to carry out low-cost, high-speed real-time deployment on industrial edge devices with limited computing power. Summary of the Invention
[0004] Based on the above background, the purpose of this invention is to provide a defect detection method for ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement, which can accurately extract the weak defect features of ferrite permanent magnet sheets against a background of strong grinding texture, effectively solve the problem of cross-scale spatial misalignment, and has high inference efficiency.
[0005] To achieve the above-mentioned objectives, the present invention provides the following technical solution:
[0006] A defect detection method for ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement, the method comprising the following steps:
[0007] A ferrite permanent magnet sheet defect detection model is constructed based on the YOLOv12 network architecture. The model includes a backbone network unit, a neck network unit, and a detection head unit. The shallow stages of the backbone network unit include a spatial reweighting module, which suppresses the response of high-frequency grinding background features by reweighting convolutional kernel weights using spatial density priors. The neck network unit includes a cross-scale feature communication network module, which achieves spatial matching and fusion of multi-scale features through global context extraction and dynamic semantic flow alignment. The detection head unit includes a lightweight shared detail enhancement detection head module, which employs a cross-scale feature parameter sharing strategy combined with reparameterized differential convolution to extract the edge contour features of weak defects.
[0008] Surface images of ferrite permanent magnet sheets are acquired and a defect dataset is constructed. The defect dataset is then used to train a defect detection model for the ferrite permanent magnet sheets.
[0009] The image of the ferrite permanent magnet sheet to be detected is input into the trained ferrite permanent magnet sheet defect detection model, and the defect detection result is output.
[0010] Preferably, the spatial reweighting module includes a dimensionality reduction convolutional layer, a feature splitting layer, several stacked spatial reweighting bottleneck sub-modules, and a channel splicing layer connected in sequence. After the input feature map is processed by the dimensionality reduction convolutional layer, it is split into two output paths by the feature splitting layer. One path is output after feature purification by the several stacked spatial reweighting bottleneck sub-modules, and the other path retains the original information. The outputs of the two paths are fused in the channel splicing layer.
[0011] Preferably, the spatial reweighting bottleneck submodule is configured with a spatial reweighting convolution operator, and the feature processing flow of the spatial reweighting convolution operator includes:
[0012] Obtain the two-dimensional symmetric space prior matrix that presents the central focusing attenuation characteristics;
[0013] The standard learnable convolutional kernel weights are multiplied element-wise with the prior matrix in the two-dimensional symmetric space to generate the reweighted equivalent convolutional kernel.
[0014] The equivalent convolution kernel is used to perform discrete convolution operation on the input feature map.
[0015] Preferably, the two-dimensional symmetric space prior matrix is generated by defining a one-dimensional density vector. ,in, The attenuation coefficient is less than 1.0; through the one-dimensional density vector The outer product generates the prior matrix of the two-dimensional symmetric space.
[0016] Preferably, the cross-scale feature communication network module includes a global context semantic calibration submodule and a dynamic spatial feature alignment submodule that are cascaded together.
[0017] Preferably, the feature processing flow of the global context semantic calibration submodule includes: mapping noisy deep input features to a query matrix, and using pyramid pooling to aggregate the spatial dimensions at multiple scales to generate a key matrix and a value matrix; generating a global attention map by calculating the inner product of the query matrix and the key matrix and applying the Softmax function; aggregating the global attention map and the value matrix to generate global context features, and using a Tanh-driven feature mask branch to perform element-wise spatial weighting on the global context features; and finally generating deep semantic calibration features through residual mapping.
[0018] Preferably, the feature processing flow of the dynamic spatial feature alignment submodule includes: upsampling the deep semantic calibration features from the global context semantic calibration submodule, then concatenating them with the shallow geometric features from the backbone network unit, and inputting them into the offset generator to predict the dense spatial offset field and gated fusion weights.
[0019] Using grid resampling technology, pixel-level deformation mapping is performed on the deep semantic calibration features based on the spatial offset field, so that the response center is aligned with the defect edge of the shallow geometric features;
[0020] The aligned two-layer features are adaptively added and output using the gated fusion weights.
[0021] Preferably, the lightweight shared detail enhancement detection head module is configured with a feature extraction sub-network with fully shared weights; the feature maps of three different scales from the neck network unit are reduced to a uniform number of channels and then input into the feature extraction sub-network for processing, in which a group normalization layer is used instead of a batch normalization layer for feature standardization; after the shared regression branch output by the feature extraction sub-network, an independent learnable scaling factor is configured, which is used to adaptively calibrate the coordinate prediction amplitude of each level.
[0022] Preferably, the feature extraction subnetwork is configured with a reparameterized differential enhanced convolution operator. During training of the ferrite permanent magnet sheet defect detection model, the reparameterized differential enhanced convolution operator performs convolution calculations on five branches in parallel. These five branches include a standard convolution branch for extracting low-frequency semantics, a central difference convolution branch for calculating the central difference, a horizontal difference convolution branch for calculating the vertical edge gradient, a vertical difference convolution branch for calculating the horizontal edge gradient, and an angular difference convolution branch for calculating the diagonal edge gradient. When the image of the ferrite permanent magnet sheet to be detected is input into the trained ferrite permanent magnet sheet defect detection model to output the defect detection result, the reparameterized differential enhanced convolution operator merges the weights and biases of the five branches into a single equivalent standard convolution kernel for forward feature extraction.
[0023] Preferably, when training the ferrite permanent magnet sheet defect detection model, the hyperparameters are set as follows: input image size is 640×640, training rounds are 300, batch size is 16, the optimizer uses stochastic gradient descent, the initial learning rate is 0.01, the weight decay coefficient is 0.0005, and the dynamic momentum parameter is 0.937.
[0024] Compared with the prior art, the present invention has the following advantages:
[0025] This invention presents a defect detection method for ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement. It provides an end-to-end industrial vision inspection solution that balances high detection accuracy with lightweight deployment. By deeply customizing the YOLOv12 network architecture, it integrates spatial reweighting mechanism, cross-scale feature communication network and lightweight shared detail enhancement detection head for collaborative optimization. This not only overcomes the difficulties of strong grinding texture interference on the surface of ferrite permanent magnet sheets, spatial misalignment of extreme-scale defects and difficulty in locating weak edges, but also improves the inference performance of the detection model with almost no increase in the number of model parameters. It provides a highly robust and easy-to-deploy-at-the-edge technical path for high-speed automated quality inspection of ferrite permanent magnet sheets on industrial production lines.
[0026] This invention incorporates a spatial reweighting module in the shallow layers of the backbone network. By introducing a spatial density prior matrix with center-focusing attenuation characteristics, the weights of the standard convolutional kernels are reweighted. This mechanism breaks the equal weighting pattern of standard convolution and can adaptively suppress the activation response of surrounding high-frequency grinding background textures during the feature extraction stage. This significantly improves the feature signal-to-noise ratio of low-contrast defects such as fine cracks and shallow scratches, thereby reducing the model's false detection rate.
[0027] This invention deploys a cross-scale feature communication network module in the neck network. This module first filters out cluttered background noise in deep features through global contextual semantic calibration, extracting pure semantic mappings. Subsequently, it explicitly learns inter-layer semantic flow through dynamic spatial feature alignment, and uses grid resampling technology to perform pixel-level deformation stretching of deep semantics. This dynamic alignment mechanism avoids the spatial misalignment problem caused by traditional rigid fusion methods, enabling deep semantics to better fit shallow geometric features and improving the boundary regression accuracy for irregular defects such as large-area chipped corners.
[0028] The detection head unit of this invention employs a lightweight shared detail enhancement detection head module. On one hand, by utilizing the morphological self-similarity of physical defects at different scales through a cross-scale feature parameter sharing strategy, it abandons the redundant structure of traditional multi-branch independent designs, significantly compressing the number of model parameters. On the other hand, it innovatively introduces a reparameterized differential enhancement convolution operator. During the training phase, it explicitly learns the high-frequency gradients of defect edges through differential convolutions in multiple directions, and during the inference phase, it utilizes linear additivity to merge them into a single standard convolution. This design enables the model to significantly enhance its ability to extract weak defect contours while maintaining fast inference speed. Attached Figure Description
[0029] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0030] Figure 1 This is a schematic diagram of the network architecture of the ferrite permanent magnet sheet defect detection model in this invention;
[0031] Figure 2 This is a schematic diagram of the spatial reweighting module (SR-C3k2) in this invention;
[0032] Figure 3 This is a schematic diagram illustrating the operating mechanism of the spatially reweighted convolution operator (SR-Conv) in this invention;
[0033] Figure 4 This is a schematic diagram of the architecture of the Cross-Scale Feature Communication Network (CSFCN) module in this invention;
[0034] Figure 5 This is a schematic diagram of the architecture of the reparameterized differential enhancement convolution operator (DEConv) in this invention;
[0035] Figure 6This is a feature comparison heatmap of the ablation test in this invention. In the figure, YOLOv12 represents the baseline model YOLOv12n of the ablation test, A represents the SR-C3k2 module, B represents the CSFCN module, and FMSD-YOLO12 represents the ferrite permanent magnet sheet defect detection model that is finally integrated and supplemented with the SR-C3k2 module, CSFCN module and LSDECD module.
[0036] Figure 7 This is a comparison chart of the test results from the comparative experiment in this invention. Detailed Implementation
[0037] The technical solution of the present invention will be further described in detail below through specific embodiments and in conjunction with the accompanying drawings. It should be understood that the implementation of the present invention is not limited to the following embodiments, and any modifications and / or alterations made to the present invention will fall within the protection scope of the present invention.
[0038] In this invention, unless otherwise specified, all parts and percentages are by weight, and the equipment and raw materials used are commercially available or commonly used in the art. Unless otherwise specified, the methods in the following embodiments are conventional methods in the art. Unless otherwise specified, the components or equipment in the following embodiments are general standard parts or components known to those skilled in the art, and their structures and principles can be learned by those skilled in the art through technical manuals or conventional experimental methods.
[0039] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings. In this detailed description, numerous specific details are set forth to facilitate explanation and provide a thorough understanding of the embodiments of the present invention. However, one or more embodiments may be practiced by those skilled in the art without these specific details.
[0040] This invention discloses a method for detecting defects in ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement. The method includes the following steps: constructing a defect detection model for ferrite permanent magnet sheets based on the YOLOv12 network architecture; acquiring surface images of ferrite permanent magnet sheets and constructing a defect dataset; training the defect detection model for ferrite permanent magnet sheets using the defect dataset; inputting the image of the ferrite permanent magnet sheet to be detected into the trained defect detection model for ferrite permanent magnet sheets; and outputting the defect detection result.
[0041] The ferrite permanent magnet sheet defect detection model comprises a backbone network unit, a neck network unit, and a detection head unit. The improvements of the ferrite permanent magnet sheet defect detection model compared to the YOLOv12 network architecture are mainly reflected in the structured enhancement of the backbone network unit's feature extraction capabilities, the efficient fusion and alignment of cross-scale features in the neck network unit, and the lightweight, reparameterized design of the detection head unit. The shallow stages of the backbone network unit include a spatial reweighting module, which uses spatial density prior reweighting of convolutional kernel weights to suppress the response of high-frequency grinding background features. The neck network unit includes a cross-scale feature communication network module, which uses global context extraction and dynamic semantic flow alignment to achieve spatial matching and fusion of multi-scale features. The detection head unit includes a lightweight shared detail enhancement detection head module, which employs a cross-scale feature parameter sharing strategy combined with reparameterized differential convolution to extract the edge contour features of weak defects.
[0042] Ferrite permanent magnet sheet surface images not only suffer from overall dark gray color and low imaging contrast, but their surface defects also exhibit extreme scale differences, posing a significant challenge to effective feature extraction. Therefore, this embodiment deeply reconstructs the YOLOv12 network architecture, constructing a system as follows: Figure 1 The enhanced model FMSD-YOLO12 shown is used as a defect detection model for ferrite permanent magnet sheets.
[0043] The backbone network unit is used for multi-scale feature extraction from the input ferrite permanent magnet sheet image. This unit includes a convolutional module (Conv), a spatial reweighting module (SR-C3k2), and an A2C2f module with a region attention mechanism. The input image is sequentially passed through two convolutional modules for initial feature extraction and downsampling; then connected sequentially to the first spatial reweighting module (SR-C3k=False) and the third convolutional module; next, connected sequentially to the second spatial reweighting module (SR-C3k=False) and the fourth convolutional module; finally, connected sequentially to the first A2C2f module (A2=True), the fifth convolutional module, and the second A2C2f module (A2=True). The conventional convolutional modules are used for basic feature extraction and spatial dimensionality reduction. The spatial reweighting module, deployed in the shallow layer, is one of the core improvements in this embodiment, used to filter high-frequency grinding background noise at the source and enhance the signal-to-noise ratio of small defects. The A2C2f module, deployed in the deep layer, utilizes an attention mechanism to capture the global semantics of large-scale defects. The outputs of the second SR-C3k2 module, the first A2C2f module, and the second A2C2f module of the backbone network unit are connected to the neck network unit as three feature maps of different scales.
[0044] The neck network unit is used to fully fuse the deep semantic features extracted by the backbone network unit with the shallow geometric features. This unit includes an A2C2f module, an upsampling module, a concatenation module, a convolution module, a spatial reweighting module (SR-C3k2), and a cross-scale feature communication network module (CSFCN). First, using a top-down path, the upsampling and concatenation modules progressively amplify the deep features and concatenate them with the corresponding shallow features of the backbone network unit. During this process, multiple A2C2f modules configured in pure convolution mode (A2=False) are interspersed for feature processing. Then, using a bottom-up path, the downsampling convolution module and the concatenation module perform multi-level feature aggregation again and connect to a spatial reweighting module configured in enhancement mode (SR-C3k=True). At the end of the neck network unit, to solve the feature space misalignment problem caused by traditional concatenation fusion, this embodiment integrates the cross-scale feature communication network module (CSFCN). The Global Context Semantic Calibration (CFC) submodule receives the deepest features to extract a clean global context; the Dynamic Spatial Feature Alignment (SFC) submodule receives the shallowest features and performs pixel-level deformation alignment under the guidance of the global context. The neck network unit finally outputs alignment features at three scales, P3, P4, and P5, to the detection head unit.
[0045] The detection head unit receives the fused multi-scale features and outputs the final defect category and bounding box location. This unit is configured as the Lightweight Shared Detail Enhancement Detection Head Module (LSDECD), an innovative design in this embodiment. Feature maps from the P3, P4, and P5 scales of the neck network unit are first passed through a dimensionality reduction convolutional group normalization layer (Conv-GN) to unify the number of channels, and then jointly input into a feature extraction sub-network with shared weights. This shared network contains a reparameterized differential enhancement convolutional layer (DEConv-GN), whose outputs are connected to the bounding box regression branch (1×1Conv-Reg) and the object classification branch (1×1Conv-Cls), respectively. After the regression branch, a scale module is independently connected, and finally, the network is optimized by combining ProbIoU+DFL loss and BCE loss. The detection head unit significantly reduces the number of network parameters through a cross-scale parameter sharing strategy. At the same time, it uses reparameterized differential convolution to explicitly enhance the ability to perceive high-frequency gradients at the edges of weak defects. Thus, while ensuring the model is lightweight, it achieves high-precision localization of fuzzy defects at the edges of ferrite permanent magnet sheets.
[0046] The following sections will provide detailed descriptions of the Spatial Reweighting Module (SR-C3k2), the Cross-Scale Feature Communication Network Module (CSFCN), and the Lightweight Shared Detail Enhancement Detection Head Module (LSDECD) introduced in this embodiment.
[0047] During the processing of ferrite permanent magnet sheets, dense high-frequency grinding textures are inevitably left on the surface. When dealing with low-contrast minor defects (such as micro-cracks), the translation invariance and weighting mechanism of the standard convolution used in the YOLOv12 network architecture can easily lead to the feature extraction process being dominated by the surrounding background texture noise. The purpose of designing the spatial reweighting module in this embodiment is to improve the signal-to-noise ratio of features from the source.
[0048] like Figure 2 As shown, the spatial reweighting module (SR-C3k2) comprises a series of sequentially connected dimensionality-reducing convolutional layers (1×1 Conv), a feature splitting layer (Split), several stacked spatial reweighting bottleneck sub-modules (SR-Bottleneck), and a channel concatenation layer (Concat). After processing by the dimensionality-reducing convolutional layers, the input feature map is split into two output paths by the feature splitting layer. One path refines the features through several stacked spatial reweighting bottleneck sub-modules, while the other path serves as a shortcut connection, preserving the original information. The outputs of the two paths are then fused at the channel concatenation layer. The SR-C3k2 module retains the efficient gradient splitting and aggregation mechanism of Cross-Stage Local Networks (CSP). Its core lies in completely replacing the standard 3×3 convolutions within the residual bottleneck (Bottleneck) with the SR-Conv operator, constructing the SR-Bottleneck, which is highly robust to texture noise.
[0049] SR-C3k2 is primarily deployed in the shallow stages (P2 and P3 layers) of the backbone network. This is because shallow networks have high spatial resolution and are mainly responsible for extracting low-level geometric features such as edges and contours, but this also makes them highly susceptible to contamination by high-frequency grinding particles on the surface of the ferrite permanent magnet sheet. SR-C3k2 acts as a crucial source filter here. When features carrying severely cluttered backgrounds flow through SR-Bottleneck, the built-in SR-Conv operator utilizes its static density mask. High-frequency activation responses at edges are continuously suppressed. Through multiple stacking processes, periodic pseudo-defect textures are effectively filtered out, while genuine micro-crack features are highly preserved. This mechanism ensures that the semantic features passed to subsequent deep networks are purer, avoids the amplification of noise errors with increasing network depth, and also takes into account inference efficiency.
[0050] like Figure 3As shown, the feature processing flow of the Spatial Reweighted Convolution Operator (SR-Conv) can be divided into three core stages: Spatial Prior Generation, Weights Re-weighting, and Feature Application. Specifically, it includes: obtaining a two-dimensional symmetric spatial prior matrix that reflects the center focusing decay characteristics; multiplying the standard learnable convolutional kernel weights element-wise with the two-dimensional symmetric spatial prior matrix to generate a reweighted equivalent convolutional kernel; and performing discrete convolution operations on the input feature map using the equivalent convolutional kernel.
[0051] SR-Conv breaks away from the standard convolutional model of fully parameter-free learning by explicitly injecting static spatial prior constraints into the weights. Given standard learnable convolutional kernel weights... In this embodiment, a spatial density mask matrix based on distance attenuation is constructed. .like Figure 3 The upper part shows the model widely used in the field. Taking the convolution kernel as an example, its density distribution is determined by the attenuation coefficient. Decision. First, define a one-dimensional density vector. Then, a two-dimensional symmetric spatial prior matrix is generated through outer product. :
[0052] ;
[0053] The matrix exhibits a central value of 1.0 that decreases symmetrically outwards (with the corners being 1.0). The network exhibits a two-dimensional Gaussian distribution. During each forward propagation of the network, will be Modulation. Specifically, through element-wise multiplication, a reweighted equivalent convolutional kernel is generated. :
[0054] ;
[0055] in This represents the spatial coordinates of the convolution kernel. This step forcibly assigns the convolution kernel the physical property of center focus without adding any additional learnable parameters.
[0056] After obtaining the equivalent convolution kernel, the feature extraction process can be represented as:
[0057] ;
[0058] in This represents the discrete convolution operation. For the input feature map, To output the feature map, This is a bias term.
[0059] Figure 3 The second half explains the physical meaning of this operator when the original feature map with severe grinding texture noise enters the receptive field. It acts as a soft attention filter, adaptively suppressing the activation response of surrounding high-frequency background textures, concentrating feature extraction on the central pixel, and greatly enhancing the feature contrast of fine defect areas.
[0060] In ferrite permanent magnet sheet defect detection, the scale of defects varies greatly, ranging from microcracks occupying several pixels to large-area edge chipping. The feature pyramid used in the YOLOv12 network architecture typically relies on simple bilinear interpolation upsampling and channel concatenation for multi-scale feature fusion. This rigid fusion method ignores the semantic gap between shallow and deep features, easily leading to spatial misalignment of features and causing severe deviations in the boundary localization of irregular defects. Therefore, this embodiment introduces a cross-scale feature communication network module (CSFCN).
[0061] like Figure 4 As shown, the cross-scale feature communication network module includes a cascaded global context semantic calibration submodule (CFC) and a dynamic spatial feature alignment submodule (SFC). The feature processing flow of the global context semantic calibration submodule includes: mapping noisy deep input features to a query matrix, and using pyramid pooling to aggregate the spatial dimensions at multiple scales to generate a key matrix and a value matrix; generating a global attention map by calculating the inner product of the query matrix and the key matrix and applying the Softmax function; aggregating the global attention map and the value matrix to generate global context features, and using a Tanh-driven feature mask branch to perform element-wise spatial weighting on the global context features; finally, generating deep semantic calibration features through residual mapping. The feature processing flow of the dynamic spatial feature alignment submodule includes: upsampling the deep semantic calibration features from the global context semantic calibration submodule, then concatenating them with the shallow geometric features from the backbone network unit, and inputting them into the offset generator to predict the dense spatial offset field and gated fusion weights; using grid resampling technology, performing pixel-level deformation mapping on the deep semantic calibration features according to the spatial offset field, so that its response center is aligned to the defect edge of the shallow geometric features; and outputting the aligned two-layer features adaptively added by the gated fusion weights.
[0062] like Figure 4 As shown in (a), deep features (such as the P5 layer) have a large receptive field and are rich in high-level semantics, but the large receptive field is easily involved by large areas of high-frequency grinding texture noise. Figure 4(a) As shown on the far left), this leads to pixel-context mismatch. Direct fusion would amplify the noise. Therefore, a CFC module is deployed to extract a clean global context. Given a noisy input, the network maps it to a dense query matrix (Query, Simultaneously, pyramid pooling (PSP) is used to aggregate spatial dimensions at multiple scales, generating a key matrix (Key, ...) that condenses background priors. ) and Value Matrix (Value, ). Through calculation and Matrix inner product and application The model obtains a global attention map that can distinguish between defects and background. This map is then compared with... After aggregation, a global context is generated. For further refinement, CFC introduces a mechanism... The driven feature mask branch performs element-wise spatial weighting on the context features, and finally adds it to the original features through residual mapping. After CFC calibration, the output features are freed from cluttered background noise, exhibiting a strong, clean response only at the defect semantic center. Figure 4 (a) The blue-purple highlighted area provides high-quality semantic guidance for subsequent fusion from the source.
[0063] like Figure 4 As shown in (b), after obtaining the pure deep semantic features, they need to be fused with shallow features (such as the P3 layer). However, shallow features ( Figure 4 (b) As shown in the lower right corner) Although it contains precise physical geometry ( Figure 4 (b) cyan diagonal cracks), but lack global semantics; while the deep calibration features after CFC calibration only contain fuzzy semantic centers ( Figure 4 (b) Blue halo). Traditional direct concatenation leads to spatial misalignment between semantics and structure. Therefore, the SFC module abandons rigid concatenation and instead explicitly learns the semantic flow between layers. First, the upsampled deep features are concatenated with the shallow features and input into the offset generator (Offset) to predict two sets of dense spatial offset fields ( and And gated fusion weights. Then, SFC uses grid sampling technology to stretch and distort the original deep and shallow features at the pixel level according to the predicted offset field (e.g., Figure 4(b) As shown in the central Deformable Alignment region. This physical deformation forces the response center of the deep semantics to flow precisely and align with the true defect edges of the shallow features. Finally, the aligned two-layer features are adaptively added through gated fusion. After spatial calibration, the deep semantics are highlighted (e.g. Figure 4 (b) The leftmost Aligned Feature (blue area) closely adheres to the shallow geometric crack (cyan). This demonstrates that the SFC mechanism can eliminate spatial misalignment in multi-scale fusion, greatly improving the model's boundary regression accuracy for irregular and weak defects.
[0064] In the native YOLO architecture, the detection head typically assigns independent convolutional branches to feature maps of different scales (P3, P4, P5). While this design is straightforward, it introduces significant parameter redundancy in deep networks. Furthermore, conventional 3×3 convolutions tend to smooth local features, making it difficult to capture high-frequency gradient changes at subtle cracks or chipped corners on the surface of ferrite permanent magnet sheets, which can easily lead to missed detections. To enhance the perception of weak defect contours while maintaining a lightweight design, this embodiment proposes a lightweight shared detail enhancement detection head (LSDECD).
[0065] The RetinaNet-based cross-scale feature consistency design abandons the redundant structure of multi-branch independent designs and adopts a parameter sharing strategy. P3, P4, and P5 features from CSFCN, after being reduced to 256 channels, are fed into a fully shared feature extraction sub-network. This strategy leverages the morphological self-similarity of physical defects at different scales, significantly compressing the number of detector head parameters while improving the model's generalization ability for multi-scale targets. To address the normalization distribution conflict caused by parameter sharing, this embodiment introduces group normalization (GN) instead of batch normalization. GN calculation is independent of batch size and exhibits extremely high stability in the cross-scale shared architecture. Furthermore, to compensate for the distribution differences in target regression amplitudes at different scales, an independent learnable scaling factor (Scale) is introduced after the shared regression branch, achieving adaptive calibration of the coordinate prediction amplitude at each level.
[0066] The feature extraction subnetwork is configured with a reparameterized differential augmentation convolution operator (DEConv). For example... Figure 5 As shown, during the training phase, DEConv deploys 5 branches in parallel: in addition to a regular branch for extracting low-frequency semantics. In addition to convolution, four innovative difference convolution operators are introduced. These operators calculate the center difference (CDC, capturing isolated point mutations), horizontal difference (HDC, capturing vertical edges), vertical difference (VDC, capturing horizontal edges), and angular difference (ADC, capturing diagonal edges), respectively. By calculating the gradient difference between the center pixel and its neighborhood, these operators force the network to explicitly learn high-frequency edge information of defects, effectively enhancing its response to weak contours. During the inference deployment phase, the linear additivity principle of convolution operations is utilized to merge the weights of the five branches from the training phase with the bias lossless into a single equivalent 3×3 convolution kernel. This reparameterized design completely offloads the burden of difference calculations during model deployment, significantly mitigating the missed detection problem caused by blurred edge contours without adding any additional inference latency.
[0067] This embodiment acquires surface images of ferrite permanent magnet sheets and constructs a defect dataset through a real industrial setting. The ferrite permanent magnet sheets are conveyed to the imaging area via a conveyor belt and photographed by high-speed industrial cameras at different angles. Defects are manually selected and confirmed by quality inspectors, and after cropping, 3592 images are obtained. Abnormal areas in the images are clearly delineated and marked. Finally, the dataset is labeled using LabelImg software and saved as a txt file, divided into training, testing, and validation sets in an 8:1:1 ratio.
[0068] In this embodiment, when training the defect detection model for ferrite permanent magnet sheets, the hyperparameters are set as follows: input image size 640×640, training epochs 300, batch size 16, the optimizer uses stochastic gradient descent with an initial learning rate of 0.01, a weight decay coefficient of 0.0005, and a dynamic momentum parameter of 0.937. This embodiment uses precision, recall, and... mAP@0.5 and mAP@0.5–0.95 were used as metrics to evaluate model accuracy. To assess the model's lightweight characteristics, GFLOPs and parameter count were selected as metrics. Precision Recall rate refers to the proportion of correctly predicted positive samples out of all predicted positive samples. This represents the proportion of correctly classified positive samples out of all actual positive samples. It is a global indicator for evaluating the model, and a higher value indicates a better performance. This indicates that the model maintains high prediction accuracy while possessing stronger defect coverage capabilities. It measures the accuracy of a single category. A higher value indicates better model performance. It is of many kinds The average value is used to evaluate the overall detection accuracy of multiple targets.
[0069] To verify the specific contributions of each innovative module to the performance of the ferrite permanent magnet sheet defect detection model, ablation experiments were conducted on the aforementioned dataset. All experiments were performed under the same hyperparameter settings, using YOLOv12n as the baseline model. The results of the ablation experiments are shown in Table 1.
[0070] Table 1 Ablation Experiment Results of the Defect Detection Model for Ferrite Permanent Magnet Sheets
[0071]
[0072] As shown in Table 1, integrating the SR-C3k2 module alone improved the key high-precision metric mAP@75 by 2.1% and reduced GFLOPs by approximately 5.2%. This indicates that by introducing SR-Conv convolutions with spatial density priors, the model can filter high-frequency grinding texture noise in the background with extremely high computational efficiency, significantly improving the feature extraction capability for low-contrast subtle defects. The CSFCN module, utilizing global context and semantic flow alignment mechanisms, effectively solves the spatial misalignment problem caused by large defect scale differences, improving boundary localization capability (mAP@50 improved by 1.5%). This is crucial for handling complex and irregular defects with significant scale differences (such as large-area chipped corners and micro-cracks). Finally, replacing the detector head with the LSDECD head alone significantly reduced the model's parameter count to 2.2M (a 12% reduction), while improving mAP@75 by 1.5%. This fully demonstrates the significant advantages of cross-scale parameter sharing strategies in model lightweighting. Furthermore, the reparameterized differential convolutions effectively enhance the perception of high-frequency gradients at edges, improving localization accuracy with zero inference cost.
[0073] The combination of various modules further demonstrates the systematic optimization and synergistic effect of the network structure. The combination of SR-C3k2 and LSDECD forms a lightweight and efficient core, achieving an accuracy of up to 91.2% with a computational cost of only 5.2 GFLOPs and 2.2M parameters. This shows that clean input features combined with an edge-sensitive detection head can greatly reduce the false detection rate. The combination of CSFCN and LSDECD makes the model's mAP@50 jump to 86.3%, and the recall and... Recall reached the highest values of 83.4% and 82.6% respectively, proving that context alignment solved the macroscopic semantic bias, while differential convolution enhanced the microscopic details and contours. The combination of the two significantly reduced the false negatives. SR-C3k2 and CSFCN first suppressed grinding textures through shallow source filters and then performed deep feature semantic calibration, achieving significant results (mAP@75 improved by 2.9%). The fully integrated solution FMSD-YOLO12 achieved the best overall performance, with recall improved to 81.9% (+2.9%), overall metric mAP@50 improved to 86.4% (+2.4%), and the more stringent mAP@75 metric jumped to 79.8% (+3.7%), while still maintaining a lightweight parameter count of 2.6M. Figure 6 As shown, FMSD-YOLO12 exhibits highly concentrated and extremely sharpness on the defect core and weak edges, while the baseline model, affected by complex grinding textures, displays a large-area diffuse and blurred response. This further visually confirms the significance of the improvement mechanism, demonstrating that the synergistic effect of each module successfully enables the model to achieve fast, accurate, and stable defect detection in the highly challenging task of detecting defects on the surface of ferrite permanent magnet sheets.
[0074] In the SR-C3k2 module, this embodiment injects a two-dimensional spatial prior matrix. This is used to reshape the weight distribution of the convolution kernel. It is a one-dimensional density vector Generated through outer product. Therefore, hyperparameters The density decay coefficient directly determines the spatial attention distribution of the convolutional receptive field. To verify the rationality of the parameter selection and explore the optimal configuration, while keeping all other training settings unchanged, the three key stages of SR-Conv (corresponding to the layers in the backbone network that extract P3, P4, and P5 features, respectively) were uniformly introduced into the network. Sensitivity analysis experiments were conducted to set up representative stratification adjustment schemes.
[0075] In order to give the density parameter ( To establish a scientific and robust baseline, an empirical configuration space from existing technologies was adopted, and selected... These serve as core validation values. Mathematically, these specific values represent three spatial priors: center focusing, uniform (standard convolution), and edge enhancement. Specifically, when... At that time, the prior matrix Degenerates into an all-one matrix, equivalent to a standard convolution that performs weighted aggregation of local pixels. When ( )hour, It exhibits a Gaussian attenuation characteristic with central focus, serving as a low-pass filter and suppressing background noise. Conversely, when... ( The edge weights of the convolutional kernel are amplified, exhibiting high-frequency edge enhancement characteristics. Based on the above benchmark values, two parameter configuration strategies were designed to explore the optimal weight distribution: a unified strategy and a hierarchical adjustment strategy. The unified strategy aims to verify the consistency effect of global spatial priors; while the hierarchical adjustment strategy assumes that as the network deepens and the receptive field increases, the feature extraction requirements of different layers may differ. The results of the sensitivity analysis experiments are shown in Table 2.
[0076] Table 2. Results of the sensitivity analysis of the density attenuation coefficient.
[0077]
[0078] According to the experimental results in Table 2, Uniform (0.9, 0.9, 0.9) achieved the best overall performance (85.8% mAP@50), significantly outperforming the equal-weighted convolution baseline. (84.2%) and edge enhancement strategies ( (82.3%). This demonstrates that for dense high-frequency grinding textures on the magnetic sheet surface, The soft attention mechanism can effectively reduce background interference and focus on subtle defects; while This will incorrectly amplify edge texture noise, leading to a sharp performance degradation. Various hierarchical strategies attempting to impart different filtering characteristics at different network depths have failed to surpass the unified strategy. This is because the background noise of industrial ferrite permanent magnet sheets exhibits cross-scale homogeneity; if filtering constraints are relaxed at deeper layers (…),… This will passively reactivate shallow, unfiltered pseudo-defects, thereby interfering with the semantic alignment of subsequent CSFCN modules. Therefore, global maintenance It is the optimal solution for consistent denoising.
[0079] To further evaluate the overall performance and industrial applicability of the proposed FMSD-YOLO12 model, a comprehensive comparative experiment was conducted with current mainstream object detection algorithms, including RT-DETR based on the Transformer architecture and the YOLO series models based on the CNN architecture. All models were trained and tested under the same dataset partitioning and hyperparameter settings. The performance evaluation results of the comparative experiments are shown in Table 3.
[0080] Table 3 Comparative experimental results of ferrite permanent magnet sheet defect detection models
[0081]
[0082] As shown in Table 3, the experimental results demonstrate that FMSD-YOLO12 achieves the best balance between detection accuracy and model lightweighting, with its overall performance significantly outperforming other comparative algorithms. FMSD-YOLO12 achieves the best results in several key metrics, with mAP@50 reaching 86.4% and the more challenging high-precision metric mAP@75 reaching 79.8%. Notably, compared to the baseline model YOLOv12n, FMSD-YOLO12 achieves a significant 3.7% leap in mAP@75 (from 76.1% to 79.8%). This improvement in stringent metrics indicates that the model can not only detect defects but also generate bounding boxes that closely match the physical contours of the defects. This directly verifies the superior effectiveness of the CSFCN module in eliminating spatial feature misalignment and the DEConv operator in capturing high-frequency edge gradients. Addressing the stringent low-miss-detection requirements of industrial scenarios, FMSD-YOLO12 achieves the highest recall rate (81.9%). Compared to the parameter-intensive RT-DETR (which achieves 90.1% precision but only 81.5% recall), this model demonstrates stronger robustness and feature coverage when dealing with irregular defects across scales. The model has 2.6M parameters, only 13% of RT-DETR, almost on par with the baseline model. After improvement, its inference frame rate still reaches 197.7 FPS, fully meeting the requirements of real-time industrial detection and offering the advantage of low-cost deployment on edge devices. To better illustrate the superiority of FMSD-YOLO12, this embodiment selects several representative detection images for comparison, and the comparison results are as follows: Figure 7 As shown.
[0083] In the stable extraction of weak features, such as Figure 7 In the detection of the worn-out defects (LM) in column 1 and the small break in the upper right corner of column 3, all YOLO comparison models could outline the targets, but FMSD-YOLO12 achieved higher detection accuracy (both 0.93), significantly outperforming YOLOv12n (0.83 and 0.86) and other models. This demonstrates that, with the assistance of the context calibration (CFC) mechanism, the FMSD-YOLO12 model can effectively prevent the low-level features of weak defects from being diluted by complex background semantics, thus achieving extremely high detection stability and accuracy. In terms of strong texture noise resistance and multi-scale capture (such as...), it also demonstrates superior performance. Figure 7In column 2, the sample surface is covered with a high-frequency grinding background, and also contains tiny sand holes (Dots) and small breaks of various shapes. The native YOLOv12n and YOLOv11n / v8n showed significant missed detections, while YOLOv9t's prediction accuracy was too low. This demonstrates the spatial filtering capability of the SR-C3k2 module in FMSD-YOLO12, effectively shielding texture noise and accurately and with high confidence identifying all targets with significant scale differences. It also demonstrates its ability to accurately regress irregular boundaries (such as...). Figure 7 (Column 4) For edge clipping (XB) of extremely irregular physical boundaries, the predicted bounding boxes of the traditional YOLO model are generally loose and redundant. However, driven by DEConv differential edge enhancement, FMSD-YOLO12 generates extremely compact bounding boxes that fit the limit contour of the defect.
[0084] This article uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. It should be noted that those skilled in the art can make several improvements and modifications to the present invention without departing from the principles of the present invention, and these improvements and modifications also fall within the protection scope of the claims of the present invention.
Claims
1. A method for detecting defects in ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement, characterized in that: The method includes the following steps: A ferrite permanent magnet sheet defect detection model is constructed based on the YOLOv12 network architecture. The model includes a backbone network unit, a neck network unit, and a detection head unit. The shallow stages of the backbone network unit include a spatial reweighting module, which suppresses the response of high-frequency grinding background features by reweighting convolutional kernel weights using spatial density priors. The neck network unit includes a cross-scale feature communication network module, which achieves spatial matching and fusion of multi-scale features through global context extraction and dynamic semantic flow alignment. The detection head unit includes a lightweight shared detail enhancement detection head module, which employs a cross-scale feature parameter sharing strategy combined with reparameterized differential convolution to extract the edge contour features of weak defects. Surface images of ferrite permanent magnet sheets are acquired and a defect dataset is constructed. The defect dataset is then used to train a defect detection model for the ferrite permanent magnet sheets. The image of the ferrite permanent magnet sheet to be detected is input into the trained ferrite permanent magnet sheet defect detection model, and the defect detection result is output.
2. The method for detecting defects in ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement as described in claim 1, characterized in that: The spatial reweighting module includes a dimensionality reduction convolutional layer, a feature splitting layer, several stacked spatial reweighting bottleneck sub-modules, and a channel splicing layer connected in sequence. After the input feature map is processed by the dimensionality reduction convolutional layer, it is split into two output paths by the feature splitting layer. One path is output after feature purification by the several stacked spatial reweighting bottleneck sub-modules, and the other path retains the original information. The outputs of the two paths are fused in the channel splicing layer.
3. The method for detecting defects in ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement as described in claim 2, characterized in that: The spatial reweighting bottleneck submodule is configured with a spatial reweighting convolution operator, and the feature processing flow of the spatial reweighting convolution operator includes: Obtain the two-dimensional symmetric space prior matrix that presents the central focusing attenuation characteristics; The standard learnable convolutional kernel weights are multiplied element-wise with the prior matrix in the two-dimensional symmetric space to generate the reweighted equivalent convolutional kernel. The equivalent convolution kernel is used to perform discrete convolution operation on the input feature map.
4. The method for detecting defects in ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement as described in claim 3, characterized in that: The prior matrix of the two-dimensional symmetric space is generated by defining a one-dimensional density vector. ,in, The attenuation coefficient is less than 1.0; through the one-dimensional density vector The outer product generates the prior matrix of the two-dimensional symmetric space.
5. The method for detecting defects in ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement as described in claim 1, characterized in that: The cross-scale feature communication network module includes a cascaded global context semantic calibration submodule and a dynamic spatial feature alignment submodule.
6. The method for detecting defects in ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement as described in claim 5, characterized in that: The feature processing flow of the global context semantic calibration submodule includes: mapping noisy deep input features to a query matrix, and using pyramid pooling to aggregate the spatial dimensions at multiple scales to generate a key matrix and a value matrix; generating a global attention map by calculating the inner product of the query matrix and the key matrix and applying the Softmax function; aggregating the global attention map and the value matrix to generate global context features, and using a Tanh-driven feature mask branch to perform element-wise spatial weighting on the global context features; and finally generating deep semantic calibration features through residual mapping.
7. The method for detecting defects in ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement as described in claim 6, characterized in that: The feature processing flow of the dynamic spatial feature alignment submodule includes: upsampling the deep semantic calibration features from the global context semantic calibration submodule, then concatenating them with the shallow geometric features from the backbone network unit, and inputting them into the offset generator to predict the dense spatial offset field and gated fusion weights. Using grid resampling technology, pixel-level deformation mapping is performed on the deep semantic calibration features based on the spatial offset field, so that the response center is aligned with the defect edge of the shallow geometric features; The aligned two-layer features are adaptively added and output using the gated fusion weights.
8. The method for detecting defects in ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement as described in claim 1, characterized in that: The lightweight shared detail enhancement detection head module is configured with a feature extraction sub-network with fully shared weights. The feature maps of three different scales from the neck network unit are reduced to a uniform number of channels and then input into the feature extraction sub-network for processing. The feature extraction sub-network uses a group normalization layer instead of a batch normalization layer for feature standardization. After the shared regression branch output by the feature extraction sub-network, an independent learnable scaling factor is configured. The learnable scaling factor is used to adaptively calibrate the coordinate prediction amplitude of each level.
9. The method for detecting defects in ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement as described in claim 8, characterized in that: The feature extraction subnetwork is configured with a reparameterized differential enhanced convolution operator. When training the ferrite permanent magnet sheet defect detection model, the reparameterized differential enhanced convolution operator performs convolution calculations of five branches in parallel. The five branches include a standard convolution branch for extracting low-frequency semantics, a central difference convolution branch for calculating the central difference, a horizontal difference convolution branch for calculating the vertical edge gradient, a vertical difference convolution branch for calculating the horizontal edge gradient, and an angular difference convolution branch for calculating the diagonal edge gradient. When the image of the ferrite permanent magnet sheet to be detected is input into the trained ferrite permanent magnet sheet defect detection model and the defect detection result is output, the reparameterized differential enhanced convolution operator merges the weights and biases of the five branches into a single equivalent standard convolution kernel for forward feature extraction.
10. The method for detecting defects in ferrite permanent magnet sheets based on cross-scale communication and shared detail enhancement according to claim 1, characterized in that: When training the ferrite permanent magnet sheet defect detection model, the hyperparameters are set as follows: input image size is 640×640, training rounds are 300, batch size is 16, the optimizer uses stochastic gradient descent, the initial learning rate is 0.01, the weight decay coefficient is 0.0005, and the dynamic momentum parameter is 0.937.