An artificial intelligence-based magnetic core winding quality detection method and system

By combining polarization image acquisition of the magnetic core with an improved YOLOv8 model, the problem of low accuracy caused by specular reflection interference in magnetic core inspection was solved, achieving high-precision and high-efficiency defect detection.

CN122115368APending Publication Date: 2026-05-29HEBEI MINGQI TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HEBEI MINGQI TECH CO LTD
Filing Date
2026-02-10
Publication Date
2026-05-29

Smart Images

  • Figure CN122115368A_ABST
    Figure CN122115368A_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on artificial intelligence's magnetic core winding quality detection method and system, it is related to defect detection technical field;Original magnetic material is wound by preset winding parameter and obtains initial magnetic core element and collects polarized image by winding operation;Polarized image is decoded initially to obtain initial decoding image set;The adaptive polarization channel correlation weight between each other between initial decoding image set is calculated to obtain correlation channel weight set;According to correlation channel weight set, initial decoding image set is reconstructed and fused to obtain depolarization image;Depolarization image is input to improved YOLOv8 model and is detected to obtain the detection result containing defect category and position.The method utilizes polarization imaging combined with adaptive weight fusion to effectively eliminate the glare and overexposure interference of the high-reflective surface of the magnetic core, while the improved YOLOv8 model is used to improve the accuracy and efficiency of defect detection, thereby improving the detection accuracy of the magnetic core.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of defect detection technology, specifically relating to a method and system for detecting the winding quality of magnetic cores based on artificial intelligence. Background Technology

[0002] With the deepening application of artificial intelligence in the field of electronic manufacturing inspection, the magnetic core winding quality inspection technology based on artificial intelligence has achieved steady development. It has gradually advanced from the initial basic inspection capabilities to higher precision and higher efficiency inspection levels. The scope of inspection has continued to expand, the adaptability to various inspection needs has been continuously improved, and the overall intelligence level of the inspection system has continued to improve, steadily moving towards a more adaptable and comprehensive direction that better suits industrial automated production.

[0003] Patent application CN118365638A discloses a magnetic core inspection method, system, and computer based on computer vision. The method includes: acquiring an initial image to be inspected corresponding to the magnetic core; adjusting the position and tilt of the initial image to obtain a final image to be inspected; determining the four corner points of the magnetic core in the final image to be inspected, and judging whether there is a corner missing defect based on the corner point feature vector; extracting the contour of the final image to be inspected to judge whether there is a broken edge defect; delineating a first detection area at the edge of the final image to be inspected to judge whether there is a black edge defect; delineating a second detection area in the final image to be inspected to determine whether there is a dirt defect and a blur defect; and judging the surface quality of the magnetic core based on the judgment results of corner missing defects, broken edge defects, black edge defects, dirt defects, and blur defects.

[0004] However, this method does not fully consider the inherent characteristics of the magnetic core as a highly reflective metal surface, which leads to uniform glare and local overexposure in the acquired images, masking the true subtle defects such as missing corners and broken edges on the magnetic core surface. At the same time, the method relies on corner extraction and contour recognition to judge defects, without adapting to the image degradation caused by reflection interference, which can lead to corner offset, contour breakage or misidentification. Furthermore, it does not consider the impact of varying lighting conditions on the grayscale characteristics of the detection area, further increasing the probability of misjudgment and missed detection of defects, ultimately resulting in low accuracy in detecting the magnetic core. Summary of the Invention

[0005] The purpose of this invention is to solve the problem of low accuracy in defect detection of magnetic cores due to specular reflection interference during visual inspection, and to propose a magnetic core winding quality inspection method and system based on artificial intelligence.

[0006] In a first aspect of this invention, a method for detecting the winding quality of magnetic cores based on artificial intelligence is first proposed, the method comprising: An initial magnetic core element is obtained by winding the original magnetic material using preset winding parameters, and a polarization image of the initial magnetic core element is acquired; the polarization image is composed of four sub-pixels with different polarization directions arranged in a superpixel array. The polarization image is initially decoded to obtain an initial decoded image set; The adaptive polarization channel correlation weights between each pair of images in the initial decoded image set are calculated to obtain the correlation channel weight set; Based on the relevant channel weight set, the initial decoded image set is reconstructed and fused to obtain a depolarized image; The depolarized image is input into the improved YOLOv8 model for defect detection to obtain detection results that include defect category and location.

[0007] This scheme obtains the initial magnetic core element by winding the original magnetic material, and then acquires its polarization image composed of sub-pixels with multiple polarization directions, which can make full use of the multi-dimensional information of polarization imaging. Combined with preliminary decoding, adaptive polarization channel related weight calculation and image reconstruction fusion, a depolarized image is obtained, which can effectively eliminate polarization interference and restore the true details of the image. Finally, the high-quality depolarized image is input into the improved YOLOv8 model for defect detection, which not only improves the identification and detection accuracy of defect features, but also accurately outputs the category and location information of defects. Overall, it achieves high accuracy and high robustness in the detection of magnetic material defects, and provides reliable technical support for the quality control of magnetic materials.

[0008] Optionally, performing preliminary decoding on the polarization image to obtain an initial decoded image set includes: The polarization image is downsampled, and sparse sampled images of each polarization direction are extracted to obtain a sparse image set; The first local gradient set and the second local gradient set are obtained by calculating the neighborhood gradient of each pixel in its own polarization direction and the adjacent polarization direction for the target sparse image; the target sparse sampled image is any sparse image in the sparse image set; A weighted fusion of the first local gradient set and the second local gradient set is obtained to obtain a comprehensive local gradient set. The interpolation weight set is obtained by determining the interpolation weights of each pixel based on the comprehensive local gradient set. For the target missing pixel location, select the nearest preset number of valid pixels around it, and perform weighted correction on the pixel values ​​of all valid pixels according to the interpolation weight set. Based on the weighted correction of the valid pixel values, perform bilinear interpolation to calculate the estimated pixel value of the target missing pixel location; the target missing pixel location is the location of any missing pixel in the target sparse image. All estimated pixel values ​​are filled into the corresponding missing pixel positions, and together with the original valid pixel values ​​in the target sparse image, they form the initial decoded image. The initial decoded image set is obtained by counting all the initial decoded images.

[0009] This scheme obtains a sparse image set by downsampling the polarization image, and then calculates a comprehensive local gradient set by combining the target sparse image itself with the neighborhood gradients of adjacent polarization directions. This is used to determine the interpolation weight set, which can make full use of the multi-directional information and local structural features of the polarization image. At the location of missing pixels, neighboring effective pixels are selected and weighted correction and bilinear interpolation are performed to accurately reconstruct the missing pixel values. Finally, the effective pixels and estimated pixels are fused to obtain the initial decoded image. This not only effectively reduces the computational load of the initial decoding, but also significantly improves the reconstruction accuracy and detail integrity of the sparse image, providing a high-quality initial input for subsequent depolarization processing.

[0010] Optionally, reconstructing and fusing the initial decoded image set according to the relevant channel weight set to obtain a depolarized image includes: The initial decoded image set is input into a preset polarization channel difference model to obtain an intermediate estimated image set for each polarization direction; the intermediate estimated image set for each polarization direction contains intermediate estimated images for all other polarization directions except that polarization direction. The intermediate estimated images of the intermediate estimated image set for the target polarization direction are weighted and fused according to the relevant channel weight set to obtain the final decoded image; the target polarization direction is any polarization direction among all polarization directions; Calculate the Stokes vector and degree of linear polarization for each pixel based on the pixel values ​​of each polarization direction corresponding to the same spatial location in all the final decoded images; The depolarized image is obtained by calculating the pixel value of unpolarized light for each pixel based on the Stokes vector and linear polarization degree of each pixel.

[0011] This scheme generates intermediate estimated image sets for each polarization direction through a preset polarization channel difference model, and then performs weighted fusion by combining relevant channel weight sets. This fully utilizes the information correlation between different polarization directions and effectively suppresses decoding errors in a single polarization direction. Subsequently, Stokes vectors and linear polarization degrees are calculated based on pixel values ​​in each polarization direction, and finally, the pixel values ​​of unpolarized light are derived. This achieves accurate conversion of polarization information to depolarized images, which not only improves the reconstruction accuracy and detail fidelity of depolarized images, but also more comprehensively mines the multi-dimensional information of polarization imaging, providing more reliable and high-quality input for subsequent image processing tasks.

[0012] Optionally, the structure of the improved YOLOv8 model includes: Delete the zeroth layer Conv module of the original YOLOv8 backbone; The first layer Conv module, the second layer C2f module, the third layer Conv module, the fourth layer C2f module, the fifth layer Conv module, and the sixth layer C2f module of the original YOLOv8 backbone are merged and replaced with feature re-extraction modules. The feature re-extraction modules are used to re-extract and fuse features by downsampling without information loss to retain feature details, thereby strengthening the representation of small defect features. Replace the Concat modules in the fourteenth, seventeenth, and twentieth layers of the original YOLOv8 neck section with preset multi-scale attention modules; Add a C2f module between the preset multi-scale attention module of the fourteenth layer and the preset multi-scale attention module of the seventeenth layer in the original YOLOv8 neck part. Add an Upsample module after the C2f module. Add a preset multi-scale attention module between the Upsample module and the second feature re-extraction module of the YOLOv8 backbone part. Connect the preset multi-scale attention module to the C2f module of the fifteenth layer. After the original YOLOv8 neck layer 21 C2f module, add the Conv module, Concat module and a new C2f module in sequence, and connect the new C2f module to the target detection layer added in the detection head.

[0013] This solution enhances the ability to characterize small defects by simplifying the backbone layer module and replacing the feature re-extraction module. Combined with the replacement of the multi-scale attention module in the neck layer, the addition of C2f and upsampling modules, and the addition of a detection layer in the detection head layer, it optimizes the feature extraction, fusion, and detection process in multiple dimensions, significantly improving the accuracy and efficiency of detecting small defects on the surface of metal castings. At the same time, it achieves model lightweighting and adapts to edge industrial inspection scenarios.

[0014] Optionally, the working principle of the feature re-extraction module includes: Obtain input features; The input features are processed by SPDConv to obtain the basic features; The basic features are subjected to convolution, depthwise separable convolution, and max pooling respectively to obtain ordinary convolutional features, depthwise convolutional features, and global features; The ordinary convolutional features and the deep convolutional features are concatenated to obtain preliminary enhanced features; The enhanced features are input into Bottleneck for feature compression to obtain the enhanced features. The output feature is obtained by adding the basic feature, the global feature, and the enhanced feature element by element.

[0015] This approach extracts basic features through SPDConv processing, and then combines ordinary convolution, depthwise separable convolution, and max pooling to achieve multi-branch feature extraction. It not only utilizes different convolution operations to mine fine-grained features, but also obtains global context information through global pooling. Subsequently, feature concatenation, Bottleneck compression, and element-wise addition are used to achieve the fusion and enhancement of multi-dimensional features. Finally, through residual connection of basic features and re-extracted features, effective feature expression is enhanced while retaining the original feature information, effectively improving feature reuse rate and representation ability, and balancing computational efficiency and model performance.

[0016] In a second aspect of this invention, an artificial intelligence-based magnetic core winding quality inspection system is proposed, comprising: The acquisition module is used to perform a winding operation on the original magnetic material using preset winding parameters to obtain an initial magnetic core element, and to acquire a polarization image of the initial magnetic core element; the polarization image is composed of four sub-pixels with different polarization directions arranged in a superpixel array. A preliminary decoding module is used to perform preliminary decoding on the polarization image to obtain an initial decoded image set; The weight calculation module is used to calculate the adaptive polarization channel correlation weights between each pair of images in the initial decoded image set to obtain the correlation channel weight set; The reconstruction and fusion module is used to reconstruct and fuse the initial decoded image set according to the relevant channel weight set to obtain a depolarized image; The detection result generation module is used to input the depolarized image into a preset improved YOLOv8 model to perform defect detection and obtain detection results including defect category and location.

[0017] Optionally, the preliminary decoding module includes: Sparse image generation involves downsampling the polarization image and extracting sparse sampled images for each polarization direction to obtain a sparse image set. The gradient calculation module is used to calculate the neighborhood gradient of each pixel in its own polarization direction and the adjacent polarization direction for the target sparse image to obtain the first local gradient set and the second local gradient set; the target sparse sampled image is any sparse image in the sparse image set; The fusion module is used to perform weighted fusion of the first local gradient set and the second local gradient set to obtain a comprehensive local gradient set; The interpolation weight determination module is used to determine the interpolation weight of each pixel based on the comprehensive local gradient set to obtain the interpolation weight set; The estimated pixel value calculation module is used to select the nearest preset number of valid pixels around the target missing pixel location, perform weighted correction on the pixel values ​​of all valid pixels according to the interpolation weight set, and perform bilinear interpolation calculation based on the weighted correction of the valid pixel values ​​to obtain the estimated pixel value of the target missing pixel location; the target missing pixel location is the location of any missing pixel in the target sparse image; The initial decoded image generation module is used to fill all estimated pixel values ​​into the corresponding missing pixel positions, and together with the original effective pixel values ​​in the target sparse image, it constitutes the initial decoded image. The statistics module is used to count all the initial decoded images to obtain the initial decoded image set.

[0018] Optionally, the reconstruction and fusion module includes: An estimated image generation module is used to input the initial decoded image set into a preset polarization channel difference model to obtain an intermediate estimated image set for each polarization direction; the intermediate estimated image set for each polarization direction includes intermediate estimated images for all other polarization directions except that polarization direction. The final decoded image generation module is used to perform weighted fusion of the intermediate estimated images of the intermediate estimated image set of the target polarization direction according to the relevant channel weight set to obtain the final decoded image; the target polarization direction is any polarization direction among all polarization directions; The calculation module is used to calculate the Stokes vector and linear polarization degree for each pixel based on the polarization direction pixels corresponding to the same spatial location in all the final decoded images. The depolarization image generation module is used to calculate the pixel value of unpolarized light for each pixel based on the Stokes vector and linear polarization degree of each pixel to obtain a depolarization image.

[0019] Optionally, the structure of the improved YOLOv8 model includes: Delete the zeroth layer Conv module of the original YOLOv8 backbone; The first layer Conv module, the second layer C2f module, the third layer Conv module, the fourth layer C2f module, the fifth layer Conv module, and the sixth layer C2f module of the original YOLOv8 backbone are merged and replaced with feature re-extraction modules. The feature re-extraction modules are used to re-extract and fuse features by downsampling without information loss to retain feature details, thereby strengthening the representation of small defect features. Replace the Concat modules in the fourteenth, seventeenth, and twentieth layers of the original YOLOv8 neck section with preset multi-scale attention modules; Add a C2f module between the preset multi-scale attention module of the fourteenth layer and the preset multi-scale attention module of the seventeenth layer in the original YOLOv8 neck part. Add an Upsample module after the C2f module. Add a preset multi-scale attention module between the Upsample module and the second feature re-extraction module of the YOLOv8 backbone part. Connect the preset multi-scale attention module to the C2f module of the fifteenth layer. After the original YOLOv8 neck layer 21 C2f module, add the Conv module, Concat module and a new C2f module in sequence, and connect the new C2f module to the target detection layer added in the detection head.

[0020] Optionally, the working principle of the feature re-extraction module includes: Obtain input features; The input features are processed by SPDConv to obtain the basic features; The basic features are subjected to convolution, depthwise separable convolution, and max pooling respectively to obtain ordinary convolutional features, depthwise convolutional features, and global features; The ordinary convolutional features and the deep convolutional features are concatenated to obtain preliminary enhanced features; The enhanced features are input into Bottleneck for feature compression to obtain the enhanced features. The output feature is obtained by adding the basic feature, the global feature, and the enhanced feature element by element.

[0021] The beneficial effects of this invention are as follows: This invention proposes an artificial intelligence-based method for detecting the winding quality of magnetic cores. An initial magnetic core element is obtained by winding the original magnetic material using preset winding parameters. A polarization image, composed of four sub-pixels with different polarization directions arranged in a superpixel array, is acquired. After preliminary decoding to obtain an initial decoded image set, adaptive polarization channel correlation weights are calculated between each pair of images to construct a correlation channel weight set. Based on this, image reconstruction and fusion are performed to obtain a depolarized image. Finally, this image is input into an improved YOLOv8 model to complete defect detection and obtain defect category and location information. This method effectively eliminates glare and overexposure interference from the highly reflective surface of the magnetic core by utilizing polarization imaging combined with adaptive weight fusion. Simultaneously, the improved YOLOv8 model enhances the accuracy and efficiency of defect detection, thereby improving the accuracy of magnetic core detection. Attached Figure Description

[0022] The present invention will now be further described with reference to the accompanying drawings.

[0023] Figure 1 A flowchart illustrating an artificial intelligence-based magnetic core winding quality detection method provided in an embodiment of the present invention; Figure 2 The structure of the improved YOLOv8 model provided in the embodiments of the present invention; Figure 3 This is a flowchart illustrating the operation of the feature re-extraction module provided in this embodiment of the invention. Detailed Implementation

[0024] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0025] Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0026] This invention provides an artificial intelligence-based method for detecting the winding quality of magnetic cores. See also... Figure 1 , Figure 1 A flowchart illustrating an artificial intelligence-based magnetic core winding quality inspection method provided in this embodiment of the invention. The method includes the following steps: Based on the artificial intelligence-based magnetic core winding quality detection method provided in this embodiment of the invention, through... S101, the original magnetic material is wound using preset winding parameters to obtain an initial magnetic core element, and the polarization image of the initial magnetic core element is acquired; S102, Perform preliminary decoding on the polarization image to obtain an initial decoded image set; S103, calculate the adaptive polarization channel correlation weights between pairs of images in the initial decoded image set to obtain the correlation channel weight set; S104, Reconstruct and fuse the initial decoded image set according to the relevant channel weight set to obtain a depolarized image; S105, Input the depolarized image into the improved YOLOv8 model to perform defect detection and obtain detection results including defect category and location; The polarization image is composed of four sub-pixels with different polarization directions arranged in a superpixel array.

[0027] In one implementation, the preset winding parameters are set by technicians. A combination of parameters such as a winding speed of 8 r / s, 60 turns per layer, winding tension of 15 N, and interlayer spacing of 0.2 mm can be selected to standardize the winding and forming process of the original magnetic material and ensure the consistency of the winding shape of the initial magnetic core element.

[0028] In one implementation, the superpixel structure may introduce instantaneous field-of-view errors, affecting the quality of polarization image reconstruction and the accuracy of polarization information calculation. Therefore, local gradient information is first used to optimize bilinear interpolation to generate a high-quality initial decoded image, thereby suppressing edge blurring and texture distortion caused by superpixel sampling in the initial reconstruction stage. Subsequently, by combining normalized cross-correlation coefficients and guided filtering, an adaptive channel correlation weight that can dynamically adapt to the polarization characteristics of different scenes is constructed. Based on the polarization channel difference model, this weight is used to perform weighted fusion of multi-channel estimation results, thereby effectively compensating for and correcting the inter-channel registration deviation and intensity inconsistency caused by instantaneous field-of-view errors in the final reconstruction stage, significantly improving the reconstruction quality of polarization images and the accuracy of subsequent polarization parameter calculation.

[0029] In one implementation, under traditional imaging modes, the magnetic core surface is prone to strong specular reflection and glare, obscuring its true surface details. To address this, a polarization camera is used for image acquisition. The polarization camera's sensor is equipped with a micro-polarization array, allowing each pixel in the image to receive polarized light in only a single specific direction. This results in the simultaneous output of a mosaic image inlaid with polarization information from four directions: 0°, 45°, 90°, and 135°. Polarization imaging technology effectively suppresses reflected light and enhances diffuse reflection information, thereby more clearly revealing defects, material differences, and three-dimensional shape features on the magnetic core surface.

[0030] In one implementation, the calculation process of the adaptive polarization channel correlation weights involves selecting any two images with different polarization directions from the initial decoded image set as the first image and the second image. For each pixel position in the first image and the second image, a local neighborhood window is determined. Within each window, the pixel mean, variance, and covariance of the two images are calculated, and their normalized cross-correlation coefficient is calculated. Based on the guided filtering model, the guided filtering similarity measure within the window is calculated. The two are then fused to generate the adaptive polarization channel correlation weights between the two images at that pixel position. The complete weight distribution between the first image and the second image is obtained by traversing all pixel positions. All pairwise image combinations in the image set are traversed, and the above process is repeated. All weight distributions are then summarized to form the correlation channel weight set.

[0031] In one embodiment, preliminary decoding of the polarization image to obtain an initial decoded image set includes: The polarization image is downsampled, and sparse sampled images of each polarization direction are extracted to obtain a sparse image set; The first local gradient set and the second local gradient set are obtained by calculating the neighborhood gradient of each pixel in its own polarization direction and the adjacent polarization direction for the target sparse image; the target sparse sampling image is any sparse image in the sparse image set; A weighted fusion of the first and second local gradient sets yields a comprehensive local gradient set. The interpolation weight set is obtained by determining the interpolation weights of each pixel based on the comprehensive local gradient set; For the target missing pixel location, select the nearest preset number of valid pixels around it, and perform weighted correction on the pixel values ​​of all valid pixels according to the interpolation weight set. Based on the weighted correction of the valid pixel values, perform bilinear interpolation to calculate the estimated pixel value of the target missing pixel location; the target missing pixel location is the location of any missing pixel in the target sparse image. All estimated pixel values ​​are filled into the corresponding missing pixel positions, and together with the original valid pixel values ​​in the target sparse image, they form the initial decoded image. The initial decoded image set is obtained by counting all the initial decoded images.

[0032] In one implementation, the preset quantity is set by technical personnel.

[0033] In one implementation, the specific steps of downsampling are as follows: based on the micro-polarizer direction corresponding to each pixel position in the polarization image, the original polarization image is decomposed into four independent binary masks, each mask marking the pixel position corresponding to the polarization direction; each binary mask is multiplied pixel by pixel with the original polarization image to obtain four sparse sampled images that retain only the effective pixel value in the polarization direction and set the rest to zero, thus forming a sparse image set.

[0034] In one implementation, the gradient calculation process involves, for each pixel location in the target sparse image, calculating the absolute value of the intensity difference between it and its eight neighboring pixels spaced at two steps in its own polarization direction image, and averaging these values ​​to obtain the local gradient of its own channel at that location. Simultaneously, in the sparse images of adjacent polarization directions, calculating the intensity differences of adjacent pixels at that location in the horizontal, vertical, and two diagonal directions, and averaging these values ​​together to obtain the local gradient of the adjacent channel at that location. After traversing all pixels in the image, these are summarized to form a first local gradient set and a second local gradient set. The formula for calculating the local gradient in its own polarization direction is as follows: , This represents the pixel value of the pixel located at coordinates (i, j) in the polarized mosaic image. Let represent the pixel values ​​of the eight neighboring pixels centered at (i, j) with a step size of 2. This represents the local gradient value in its own polarization direction at the pixel point with coordinates (i, j) in the image; the formula for calculating the local gradient in adjacent polarization directions is... , and These represent the pixel values ​​of two adjacent pixels in the horizontal direction of the current pixel, used to calculate the horizontal gradient components. and These represent the pixel values ​​of two adjacent pixels in the vertical direction of the current pixel, used to calculate the vertical gradient components. and These represent the pixel values ​​of two adjacent pixels along the main diagonal of the current pixel. and These represent the intensity values ​​of two adjacent pixels along the sub-diagonal direction of the current pixel. This represents the local gradient value at coordinates (i, j) in adjacent polarization directions.

[0035] In one implementation, the process of determining the interpolation weight of each pixel is as follows: for the comprehensive local gradient value of each pixel in the comprehensive local gradient set, calculate the reciprocal of the gradient value and add a very small positive number to prevent division by zero. The resulting reciprocal is used as the interpolation weight of the pixel. After traversing all pixels, the interpolation weights of each pixel are summarized to form an interpolation weight set.

[0036] In one embodiment, reconstructing and fusing an initial decoded image set according to a relevant channel weight set to obtain a depolarized image includes: The initial decoded image set is input into the preset polarization channel difference model to obtain the intermediate estimated image set for each polarization direction; the intermediate estimated image set for each polarization direction contains the intermediate estimated images for all other polarization directions except for that polarization direction. The intermediate estimated images of the target polarization direction are weighted and fused according to the relevant channel weight set to obtain the final decoded image; the target polarization direction is any polarization direction among all polarization directions. Calculate the Stokes vector and degree of linear polarization for each pixel based on the pixel values ​​of each polarization direction corresponding to the same spatial location in all the final decoded images; The depolarized image is obtained by calculating the pixel value of unpolarized light for each pixel based on the Stokes vector and linear polarization degree of each pixel.

[0037] In one implementation, a pre-defined polarization channel difference model first uses images with different polarization directions in the initial decoded image set to calculate pixel-level difference images of the target channel and each other channel at known sampling points. These difference images reflect the intensity correlation and local smoothness characteristics between different polarization directions. Subsequently, an interpolation method based on local gradient optimization is used to reconstruct the sparse difference image at full resolution to obtain a complete inter-channel difference estimation map. Finally, the reconstructed difference estimation map is fused with the corresponding initial image of the auxiliary channel to generate multiple intermediate estimation images of the target channel inferred based on the relationship between different channels. Thus, through complementary optimization of multi-source difference information, the reconstruction error and edge artifacts introduced by single interpolation or fixed weight fusion are effectively suppressed.

[0038] In one implementation, for each spatial location in the image, the pixel value I0 corresponding to the polarization directions of 0°, 45°, 90°, and 135° in the four final decoded images is extracted. 45 I 90 I 135 ; Calculate the first three Stokes components at this position according to the definition of the Stokes vector: S0 = (I0 + I 45 +I 90 +I 135 ) / 2, S1=I0-I 90 S2=I 45 -I 135 Then, based on the obtained S0, S1, and S2, the degree of linear polarization at that location is calculated. The above calculations are performed by traversing all pixel positions to obtain the Stokes vector field and linear polarization degree image of the entire image.

[0039] In one embodiment, reference Figure 2 , Figure 2 The improved YOLOv8 model structure provided in this embodiment of the invention includes: Delete the zeroth layer Conv module of the original YOLOv8 backbone; The first layer Conv module, the second layer C2f module, the third layer Conv module, the fourth layer C2f module, the fifth layer Conv module, and the sixth layer C2f module of the original YOLOv8 backbone are merged and replaced with feature re-extraction modules. The feature re-extraction modules are used to re-extract and fuse features by downsampling without information loss to retain feature details, thereby strengthening the representation of small defect features. Replace the Concat modules in the fourteenth, seventeenth, and twentieth layers of the original YOLOv8 neck section with preset multi-scale attention modules; Add a C2f module between the preset multi-scale attention module of the fourteenth layer and the preset multi-scale attention module of the seventeenth layer in the original YOLOv8 neck part. Add an Upsample module after the C2f module. Add a preset multi-scale attention module between the Upsample module and the second feature re-extraction module of the YOLOv8 backbone part. Connect the preset multi-scale attention module to the C2f module of the fifteenth layer. After the original YOLOv8 neck layer 21 C2f module, add the Conv module, Concat module and a new C2f module in sequence, and connect the new C2f module to the target detection layer added in the detection head.

[0040] In one implementation, the pre-defined multi-scale attention module works by first concatenating high-level and low-level features along the channel dimension to form an inter-scale correlation matrix. Then, using a channel attention mechanism that includes global average pooling and point convolution, the importance of features is dynamically calibrated through Hadamard product operations. Next, the calibrated features are fused with the original features of the parallel branches element-wise, embedding contextual semantics through residual learning while preserving the spatial topology. Finally, the channel attention submodule models cross-channel dependencies through channel gating, and the spatial attention submodule constructs a position-aware mask through spatial convolution. The fusion weights are then derived through adaptive parameterization, achieving hierarchical integration and context-guided adaptation of multi-scale features, thereby enhancing the detection capability of defects at different scales in complex backgrounds.

[0041] In one implementation, the feature re-extraction module resolves the contradiction between feature loss and efficiency imbalance in traditional CNNs for detecting minute defects, achieving synergistic optimization of fine-grained feature retention and model lightweighting. This module uses SPDConv as its core technology. By reconstructing the feature processing logic, it completely avoids the high-resolution detail loss problem caused by traditional downsampling operations. Unlike traditional stride convolutions or pooling layers, which easily lose key information about minute defects down to 4 pixels when compressing spatial dimensions, SPDConv reorganizes the spatial dimension of the feature map into channel depth. With a dual downsampling mechanism that achieves no information loss, it expands the number of channels to four times the original size while maximizing the retention of fine-grained features required for detecting minute surface defects, providing more complete feature support for downstream modules to identify small defects such as edge indentations and short scratches.

[0042] In one implementation, the original YOLOv8 suffers from shortcomings in industrial defect detection scenarios, such as loss of fine-grained features (e.g., small casting defects), insufficient cross-scale feature integration, and weak discrimination in complex backgrounds. Furthermore, it struggles to balance accuracy and lightweight deployment requirements. The improved version, by replacing the backbone CBS and part of C2f with feature re-extraction modules and adding a Conv module, maximizes the preservation of fine-grained features of small defects while controlling model size and improving feature extraction capabilities. The multi-scale attention module added between the backbone and neckline enhances cross-scale feature fusion and the focus on key information, reducing interference from complex backgrounds. The addition of C2f and Conv modules to the neckline, along with the removal of redundant modules, further optimizes the feature transfer path. These improvements not only compensate for the original model's adaptability deficiencies in vertical scenarios but also achieve a synergistic improvement in accuracy, lightweight design, and scenario robustness. These optimizations are necessary to make YOLOv8 more suitable for specialized tasks such as industrial inspection.

[0043] In one embodiment, reference Figure 3 , Figure 3 This is a flowchart illustrating the operation of the feature re-extraction module provided in this embodiment of the invention. The working principle of the feature re-extraction module includes: Obtain input features; The basic features are obtained by processing the input features using SPDConv. By performing convolution, depthwise separable convolution, and max pooling on the basic features, we obtain ordinary convolutional features, depthwise convolutional features, and global features. The initial enhanced features are obtained by concatenating ordinary convolutional features and deep convolutional features; The enhanced features are input into Bottleneck for feature compression to obtain the enhanced features. The output feature is obtained by adding the basic features, global features, and enhanced features element by element.

[0044] In one implementation, SPDConv works by reconstructing the spatial and channel dimensions to achieve lossless downsampling. It first divides the input feature map into multiple non-overlapping sub-feature blocks according to a preset downsampling ratio, and then concatenates and integrates these sub-blocks along the channel dimension, reducing the spatial size of the feature map proportionally while expanding the number of channels to the square of the original number of channels. This transforms the detailed information of the spatial dimension into the feature representation of the channel dimension. Then, a non-staggered convolutional layer is connected. While maintaining the current spatial resolution, the expanded number of channels is adjusted to the target dimension, completing the integration of features and dimensional adaptation. The whole process replaces the traditional staggered convolution or pooling layer, which avoids the loss of fine-grained information and retains the key features of small targets or minor defects, providing more complete feature input for subsequent modules.

[0045] In one implementation, the initial enhanced features are input into Bottleneck through the following process: First, the channel dimension of the initial enhanced features is compressed using a 1×1 convolution to reduce the amount of parameter computation and achieve dimensionality reduction mapping of the feature dimension. Then, a 3×3 convolution is used to perform nonlinear transformation and detail refinement of the features. Finally, another 1×1 convolution is used to restore the channel dimension, forming a more representative enhanced feature after compression. This process, through a compact structure of dimensionality reduction-refinement-dimensionality increase, effectively removes redundant information in the features and reduces computational complexity while strengthening the aggregation expression of key discriminative features. This avoids model redundancy caused by excessive feature dimension and improves feature transmission efficiency, helping the model accurately capture the core features of minute defects in metal castings while maintaining lightweight design. This provides more efficient and high-quality feature support for subsequent feature fusion and detection tasks.

[0046] The foregoing has described one embodiment of the present invention in detail, but this content is merely a preferred embodiment and should not be considered as limiting the scope of the present invention. All equivalent variations and modifications made within the scope of the claims of this invention should still fall within the scope of the claims of this invention.

Claims

1. A method for detecting the winding quality of magnetic cores based on artificial intelligence, characterized in that, The method includes: An initial magnetic core element is obtained by winding the original magnetic material using preset winding parameters, and a polarization image of the initial magnetic core element is acquired; the polarization image is composed of four sub-pixels with different polarization directions arranged in a superpixel array. The polarization image is initially decoded to obtain an initial decoded image set; The adaptive polarization channel correlation weights between each pair of images in the initial decoded image set are calculated to obtain the correlation channel weight set; Based on the relevant channel weight set, the initial decoded image set is reconstructed and fused to obtain a depolarized image; The depolarized image is input into the improved YOLOv8 model for defect detection to obtain detection results that include defect category and location.

2. The method for detecting the winding quality of magnetic cores based on artificial intelligence according to claim 1, characterized in that, The initial decoded image set obtained by performing preliminary decoding on the polarization image includes: The polarization image is downsampled, and sparse sampled images of each polarization direction are extracted to obtain a sparse image set; The first local gradient set and the second local gradient set are obtained by calculating the neighborhood gradient of each pixel in its own polarization direction and the adjacent polarization direction for the target sparse image; the target sparse sampled image is any sparse image in the sparse image set; A weighted fusion of the first local gradient set and the second local gradient set is obtained to obtain a comprehensive local gradient set. The interpolation weight set is obtained by determining the interpolation weights of each pixel based on the comprehensive local gradient set. For the target missing pixel location, select the nearest preset number of valid pixels around it, and perform weighted correction on the pixel values ​​of all valid pixels according to the interpolation weight set. Based on the weighted correction of the valid pixel values, perform bilinear interpolation to calculate the estimated pixel value of the target missing pixel location; the target missing pixel location is the location of any missing pixel in the target sparse image. All estimated pixel values ​​are filled into the corresponding missing pixel positions, and together with the original valid pixel values ​​in the target sparse image, they form the initial decoded image. The initial decoded image set is obtained by counting all the initial decoded images.

3. The method for detecting the winding quality of magnetic cores based on artificial intelligence according to claim 1, characterized in that, The depolarized image is obtained by reconstructing and fusing the initial decoded image set according to the relevant channel weight set, including: The initial decoded image set is input into a preset polarization channel difference model to obtain an intermediate estimated image set for each polarization direction; the intermediate estimated image set for each polarization direction contains intermediate estimated images for all other polarization directions except that polarization direction. The intermediate estimated images of the intermediate estimated image set for the target polarization direction are weighted and fused according to the relevant channel weight set to obtain the final decoded image; the target polarization direction is any polarization direction among all polarization directions; Calculate the Stokes vector and degree of linear polarization for each pixel based on the pixel values ​​of each polarization direction corresponding to the same spatial location in all the final decoded images; The depolarized image is obtained by calculating the pixel value of unpolarized light for each pixel based on the Stokes vector and linear polarization degree of each pixel.

4. The method for detecting the winding quality of magnetic cores based on artificial intelligence according to claim 1, characterized in that, The structure of the improved YOLOv8 model includes: Delete the zeroth layer Conv module of the original YOLOv8 backbone; The first layer Conv module, the second layer C2f module, the third layer Conv module, the fourth layer C2f module, the fifth layer Conv module, and the sixth layer C2f module of the original YOLOv8 backbone are merged and replaced with feature re-extraction modules. The feature re-extraction modules are used to re-extract and fuse features by downsampling without information loss to retain feature details, thereby strengthening the representation of small defect features. Replace the Concat modules in the fourteenth, seventeenth, and twentieth layers of the original YOLOv8 neck section with preset multi-scale attention modules; Add a C2f module between the preset multi-scale attention module of the fourteenth layer and the preset multi-scale attention module of the seventeenth layer in the original YOLOv8 neck part. Add an Upsample module after the C2f module. Add a preset multi-scale attention module between the Upsample module and the second feature re-extraction module of the YOLOv8 backbone part. Connect the preset multi-scale attention module to the C2f module of the fifteenth layer. After the original YOLOv8 neck layer 21 C2f module, add the Conv module, Concat module and a new C2f module in sequence, and connect the new C2f module to the target detection layer added in the detection head.

5. The method for detecting the winding quality of magnetic cores based on artificial intelligence according to claim 4, characterized in that, The working principle of the feature re-extraction module includes: Obtain input features; The input features are processed by SPDConv to obtain the basic features; The basic features are subjected to convolution, depthwise separable convolution, and max pooling respectively to obtain ordinary convolutional features, depthwise convolutional features, and global features; The ordinary convolutional features and the deep convolutional features are concatenated to obtain preliminary enhanced features; The enhanced features are input into Bottleneck for feature compression to obtain the enhanced features. The output feature is obtained by adding the basic feature, the global feature, and the enhanced feature element by element.

6. A magnetic core winding quality inspection system based on artificial intelligence, characterized in that, The system includes: The acquisition module is used to perform a winding operation on the original magnetic material using preset winding parameters to obtain an initial magnetic core element, and to acquire a polarization image of the initial magnetic core element; the polarization image is composed of four sub-pixels with different polarization directions arranged in a superpixel array. A preliminary decoding module is used to perform preliminary decoding on the polarization image to obtain an initial decoded image set; The weight calculation module is used to calculate the adaptive polarization channel correlation weights between each pair of images in the initial decoded image set to obtain the correlation channel weight set; The reconstruction and fusion module is used to reconstruct and fuse the initial decoded image set according to the relevant channel weight set to obtain a depolarized image; The detection result generation module is used to input the depolarized image into a preset improved YOLOv8 model to perform defect detection and obtain detection results including defect category and location.

7. The magnetic core winding quality inspection system based on artificial intelligence according to claim 6, characterized in that, The preliminary decoding module includes: Sparse image generation involves downsampling the polarization image and extracting sparse sampled images for each polarization direction to obtain a sparse image set. The gradient calculation module is used to calculate the neighborhood gradient of each pixel in its own polarization direction and the adjacent polarization direction for the target sparse image to obtain the first local gradient set and the second local gradient set; the target sparse sampled image is any sparse image in the sparse image set; The fusion module is used to perform weighted fusion of the first local gradient set and the second local gradient set to obtain a comprehensive local gradient set; The interpolation weight determination module is used to determine the interpolation weight of each pixel based on the comprehensive local gradient set to obtain the interpolation weight set; The estimated pixel value calculation module is used to select the nearest preset number of valid pixels around the target missing pixel location, perform weighted correction on the pixel values ​​of all valid pixels according to the interpolation weight set, and perform bilinear interpolation calculation based on the weighted correction of the valid pixel values ​​to obtain the estimated pixel value of the target missing pixel location; the target missing pixel location is the location of any missing pixel in the target sparse image; The initial decoded image generation module is used to fill all estimated pixel values ​​into the corresponding missing pixel positions, and together with the original effective pixel values ​​in the target sparse image, it constitutes the initial decoded image. The statistics module is used to count all the initial decoded images to obtain the initial decoded image set.

8. The magnetic core winding quality inspection system based on artificial intelligence according to claim 6, characterized in that, The reconstruction and fusion module includes: An estimated image generation module is used to input the initial decoded image set into a preset polarization channel difference model to obtain an intermediate estimated image set for each polarization direction; the intermediate estimated image set for each polarization direction includes intermediate estimated images for all other polarization directions except that polarization direction. The final decoded image generation module is used to perform weighted fusion of the intermediate estimated images of the intermediate estimated image set of the target polarization direction according to the relevant channel weight set to obtain the final decoded image; the target polarization direction is any polarization direction among all polarization directions; The calculation module is used to calculate the Stokes vector and linear polarization degree for each pixel based on the polarization direction pixels corresponding to the same spatial location in all the final decoded images. The depolarization image generation module is used to calculate the pixel value of unpolarized light for each pixel based on the Stokes vector and linear polarization degree of each pixel to obtain a depolarization image.

9. The magnetic core winding quality inspection system based on artificial intelligence according to claim 6, characterized in that, The structure of the improved YOLOv8 model includes: Delete the zeroth layer Conv module of the original YOLOv8 backbone; The first layer Conv module, the second layer C2f module, the third layer Conv module, the fourth layer C2f module, the fifth layer Conv module, and the sixth layer C2f module of the original YOLOv8 backbone are merged and replaced with feature re-extraction modules. The feature re-extraction modules are used to re-extract and fuse features by downsampling without information loss to retain feature details, thereby strengthening the representation of small defect features. Replace the Concat modules in the fourteenth, seventeenth, and twentieth layers of the original YOLOv8 neck section with preset multi-scale attention modules; Add a C2f module between the preset multi-scale attention module of the fourteenth layer and the preset multi-scale attention module of the seventeenth layer in the original YOLOv8 neck part. Add an Upsample module after the C2f module. Add a preset multi-scale attention module between the Upsample module and the second feature re-extraction module of the YOLOv8 backbone part. Connect the preset multi-scale attention module to the C2f module of the fifteenth layer. After the original YOLOv8 neck layer 21 C2f module, add the Conv module, Concat module and a new C2f module in sequence, and connect the new C2f module to the target detection layer added in the detection head.

10. The magnetic core winding quality inspection system based on artificial intelligence according to claim 9, characterized in that, The working principle of the feature re-extraction module includes: Obtain input features; The input features are processed by SPDConv to obtain the basic features; The basic features are subjected to convolution, depthwise separable convolution, and max pooling respectively to obtain ordinary convolutional features, depthwise convolutional features, and global features; The ordinary convolutional features and the deep convolutional features are concatenated to obtain preliminary enhanced features; The enhanced features are input into Bottleneck for feature compression to obtain the enhanced features. The output feature is obtained by adding the basic feature, the global feature, and the enhanced feature element by element.