A magnet tile surface defect detection method for industrial online quality inspection
By constructing a semantic cue set for magnetic tile defects and a multi-scale fusion mechanism, the problems of sample dependence and stability in magnetic tile defect detection were solved, realizing automatic detection and localization of defects on the surface of magnetic tiles, and improving detection efficiency and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENYANG UNIVERSITY OF TECHNOLOGY
- Filing Date
- 2026-04-10
- Publication Date
- 2026-05-29
AI Technical Summary
Existing magnetic tile defect detection technologies suffer from problems such as strong dependence on defect samples, insufficient domain adaptability, difficulty in identifying and locating minute defects, and poor detection stability, making it difficult to achieve efficient and stable detection, especially in complex industrial scenarios.
A set of semantic prompts for defects in magnetic tiles is constructed. By combining visual feature extraction and text semantic matching, image-level anomaly discrimination scores and local anomaly response maps are generated. Through multi-scale fusion and local enhancement mechanisms, automatic detection and localization of defects on the surface of magnetic tiles are achieved.
Without requiring a large number of defect-labeled samples, it improves the ability to identify and detect defects on the surface of magnetic tiles, reduces data labeling costs, enhances adaptability to complex industrial scenarios, and improves detection efficiency and accuracy.
Smart Images

Figure CN122115994A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial visual inspection technology, and in particular to a method for detecting surface defects of magnetic tiles for industrial online quality inspection. Background Technology
[0002] As crucial functional components in motors, sensors, and electromechanical equipment, the surface quality of magnetic tiles directly impacts product performance, assembly accuracy, and lifespan. Quality issues in industrial production typically lead to additional costs such as scrapping, rework, failure analysis, repair, and returns. The American Society for Quality (ASQ) defines these costs incurred due to poor quality as inferiority costs. With the manufacturing industry's shift towards digitalization and intelligentization, online visual inspection and sensor quality control have become essential tools for improving inspection coverage, reducing scrap and rework, and supporting real-time quality decision-making.
[0003] Current methods for detecting defects in magnetic tiles largely rely on manual visual inspection, which suffers from low efficiency, high labor intensity, strong subjectivity, and poor consistency, making it difficult to meet the requirements of high throughput, high stability, and low false negative rate for online quality inspection in industry. Especially for fine-grained defects such as microcracks and edge damage, manual inspection is prone to missed detections and misjudgments. Existing detection methods based on traditional image processing typically employ threshold segmentation, edge detection, texture analysis, or template matching. While relatively simple to implement, these methods are poorly adaptable to changes in lighting, background interference, and defect morphology, making it difficult to maintain stable detection results in complex industrial scenarios. In recent years, supervised detection methods based on deep learning have improved detection accuracy to some extent, but they usually rely on a large number of labeled defect samples. However, in real-world industrial scenarios, obtaining magnetic tile defect samples is difficult, there is class imbalance, and it is difficult to cover new defects, limiting their engineering applications.
[0004] Furthermore, defects in magnetic tiles are characterized by diverse types, small scale, obvious edge aggregation, and complex morphological variations. Additionally, differences in material, texture, and imaging conditions between different batches of products can easily lead to a decrease in the stability of the detection model. Therefore, there is an urgent need for a method that can reduce dependence on defect samples, adapt to complex industrial conditions, and achieve stable detection of surface defects in magnetic tiles. Summary of the Invention
[0005] In view of the shortcomings of the prior art, the purpose of this invention is to provide a method for detecting surface defects of magnetic tiles for industrial online quality inspection, which aims to solve the problems of strong dependence on defect samples, insufficient field adaptability, difficulty in identifying and locating small defects, and poor detection stability of existing magnetic tile surface defect detection technologies in industrial quality inspection applications.
[0006] To achieve the above objectives, the present invention adopts the following technical solution: A method for detecting surface defects in magnetic tiles for industrial online quality inspection, the method comprising: Step 1: Obtain images of the magnetic tile surface during the production line conveying process, and preprocess the magnetic tile surface images to obtain standardized input images; Step 2: Based on the normal surface condition, defect type, defect morphology characteristics and defect location description of the magnetic tile, construct a set of semantic hints for magnetic tile defects; Step 3: Extract visual features from the standardized input image to extract global image features and local region features of the magnetic tile surface; extract text features from the set of semantic prompts for magnetic tile defects to extract corresponding text semantic features. Step 4: Based on the matching relationship between global image features and text semantic features, generate image-level anomaly discrimination scores for the magnetic tile surface, and construct local anomaly response maps based on local region features; Step 5: Fuse the image-level anomaly discrimination score with the local anomaly response map to generate a thermal map of defects on the magnetic tile surface and a comprehensive anomaly score; Step 6: Set a preset or adaptive judgment threshold, compare the comprehensive abnormal score with the judgment threshold, and determine whether the magnetic tile surface is normal or abnormal. Step 7: Output the defect location, defect type, and defect severity information, and output the detection results to the industrial online quality inspection department to perform defect alarm, product classification, sorting, or rejection of non-conforming products.
[0007] Furthermore, in step 3, the input magnetic tile surface image is processed. Visual feature extraction was performed to obtain global image features of the magnetic tile surface. and local region feature set ,in, This represents the number of local regions obtained after dividing the input image; simultaneously, text feature extraction is performed on the pre-constructed set of semantic cues for magnetic tile defects to obtain normal state text features. and abnormal state text feature set ,in, The number of categories representing semantic hints for abnormal defects; The image features and text features are normalized separately. The normalized features are represented as follows: ; in, This represents the L2 norm.
[0008] Furthermore, in step 4, the image-level anomaly detection score is calculated based on the similarity between global image features and text semantic features, while the normal matching score... Represented as: ; Abnormal matching score Represented as: ; in, This is a temperature coefficient used to adjust the smoothness of the similarity distribution; Based on the normal matching score and the abnormal matching score, an image-level anomaly detection score is obtained. : ; Mapped to the normalized anomaly probability form: ; in, This represents the Sigmoid function.
[0009] Furthermore, in step 4, the local anomaly response map is constructed by matching the local region features with the text semantic features, thus dividing the input image into... After the first local region, the second Abnormal response values of local regions Represented as: ; The local anomaly response map is composed of the anomaly response values of all local regions. : ; Since defects in magnetic tiles are more likely to occur in edge areas, corner areas, or areas with contour changes, local enhancement weights are applied to key areas. The weighted local anomaly response values are obtained as follows: ; in, When the first When a local area is located at the edge, corner, or abrupt change in the contour of the magnetic tile... Take an enhancement weight greater than 1; when the th When a local region is located within a normal region Improve the detection sensitivity and positioning accuracy of local defects such as chipped edges, missing corners, and edge cracks.
[0010] Furthermore, in step 5, to accommodate the detection needs of defects at different scales, multi-scale fusion is performed on the local anomaly response map, assuming the first... The local anomaly response map at each scale is as follows: A total of At each scale, the fused local anomaly response map Represented as: ; in, For the first The fusion weights at each scale satisfy: ; Image-level anomaly discrimination score With the fused local anomaly response map A joint weighted fusion is performed to obtain a comprehensive anomaly score. : ; in, This is the balance coefficient between global outlier scores and local outlier scores. This represents the maximum response value in the merged local anomaly response graph.
[0011] Furthermore, in step 6, a preset or adaptively determined judgment threshold is used to compare the comprehensive abnormal score with the judgment threshold to determine whether the magnetic tile surface is normal or abnormal. The judgment threshold is adaptively determined based on the distribution of normal samples, and the mean of the statistical distribution of abnormal scores for normal magnetic tile samples is [value missing]. The standard deviation is Then determine the threshold. Represented as: ; in, This is the threshold adjustment coefficient, used to control the detection sensitivity; When the comprehensive abnormal score is satisfied If the current magnetic tile sample is abnormal, it is considered normal; otherwise, it is considered normal.
[0012] Furthermore, in step 6, when the detection result is abnormal, the severity level of the defect is output, assuming the area ratio of the abnormal region is... The abnormal response intensity is The defect location weight is The defect category weight is Then the severity score of the defect Represented as: ; in, For the corresponding weight coefficients, and satisfying: ; Based on ratings The range of values is used to classify the surface defects of magnetic tiles into minor defects, medium defects, and severe defects, for use in quality grading, production line alarm prompts, or non-conforming product sorting control.
[0013] Furthermore, before defect detection, the visual feature extraction and text feature extraction in step 3 are jointly optimized using image-text alignment loss and local anomaly constraint loss. The total loss function is expressed as: ; in, This represents the global image-text alignment loss. This represents the loss due to local anomaly constraints. These are the loss weighting coefficients; The global image-text alignment loss is expressed as: ; The loss due to local anomaly constraints can be expressed as: ; in, Indicates the first The target anomaly response value or monitoring guidance value corresponding to each local area; By jointly optimizing the loss function, the matching accuracy between image features and text semantic features is improved, and the representation ability of local abnormal regions is enhanced.
[0014] Furthermore, in step 2, the set of semantic prompts for magnetic tile defects includes normal state prompts, abnormal state prompts, and shape location prompts. Among them, normal state prompts are used to describe the surface of defect-free magnetic tiles, abnormal state prompts are used to describe one or more defects such as pores, fractures, cracks, wear, and unevenness, and shape location prompts are used to describe the location of defects in edge regions, corner regions, central regions, texture abrupt regions, or contour destruction regions. The set of semantic prompts for magnetic tile defects is generated using a template-based construction method, including generating prompt statements based on the combination of predefined semantic templates and a defect lexicon.
[0015] The technical solution adopted in this invention has the following beneficial effects: This method addresses the challenges of obtaining defect samples for magnetic tiles in industrial online quality inspection scenarios, including uneven category distribution and difficulty in early coverage of novel defects. By constructing an anomaly perception scheme for detecting defects on the surface of magnetic tiles, it achieves automatic detection and localization of abnormal defects on the surface of magnetic tiles without relying on a large number of defect-labeled samples, thereby reducing data labeling costs.
[0016] By introducing a set of semantic prompts for defects in magnetic tiles, the normal state, defect type, defect morphology features, and defect location descriptions are integrated into the detection process, enhancing the ability to identify various defects such as nozzles, fractures, cracks, wear, and unevenness, and improving the domain adaptability in complex industrial scenarios.
[0017] By combining image-level anomaly discrimination scores with local anomaly response maps, and employing multi-scale fusion and local enhancement mechanisms, it is possible not only to achieve overall determination of defects on the surface of magnetic tiles, but also to improve the detection sensitivity and positioning accuracy of minute defects, edge defects, and local weak anomalies, thereby enhancing the detection stability under complex working conditions.
[0018] By adopting an adaptive threshold determination method based on the statistical distribution of abnormal scores in normal samples, the method can adapt to the online detection needs of different batches of magnetic tile products, different imaging conditions, and different surface textures, thereby improving the robustness and generalization ability of the method in industrial field applications.
[0019] This method can also output information on defect location, defect type, and defect severity, and can be linked with the production line control unit to realize defect alarm, quality classification, product sorting, or rejection of non-conforming products, thereby improving the efficiency of online quality inspection in industry and reducing the burden of manual inspection. Attached Figure Description
[0020] Figure 1 This is a flowchart of the method of the present invention; Figure 2 This is an image display of the surface of the magnetic tile; Figure 3 These are example images of typical defects on the surface of magnetic tiles; Figure 4 This is a diagram illustrating typical defects on the surface of magnetic tiles; Figure 5 This is a diagram showing the training and test sets; Figure 6 This is a structural diagram of the image feature extraction, text feature extraction, and anomaly detection model of the present invention; Figure 7 This is a diagram showing the effect of generating defect heatmaps on the model of this invention using the test set; Figure 8 This is a graph showing the detection results of the test set on the test model; Figure 9 It is a graph showing the performance of the comparison method on the test set for each metric; Figure 10 It is a graph of the total loss function during the training process; Figure 11 It is a graph of the loss function due to local anomaly constraints during the training process. Detailed Implementation
[0021] This invention provides a method for detecting surface defects in magnetic tiles for industrial online quality inspection, applicable to online quality inspection scenarios in magnetic tile production lines. The method utilizes an industrial camera to acquire images of the magnetic tile surface, combining visual feature extraction with textual semantic prompt matching mechanisms to achieve automatic detection, location, and quality assessment of defects such as perforations, fractures, cracks, wear, and unevenness on the magnetic tile surface.
[0022] like Figure 1 As shown, the method flow of this invention mainly includes the following steps: magnetic tile surface image acquisition and preprocessing, construction of training sample dataset and test sample dataset, construction of magnetic tile defect semantic prompt set, image feature and text feature extraction, generation of image-level anomaly discrimination score, construction of local anomaly response map, multi-scale fusion, calculation of comprehensive anomaly score, and output of detection results. Figure 1 It is understood that the present invention does not rely solely on a single image classification result for discrimination, but rather organically combines global anomaly discrimination, local anomaly localization, and result output to form a complete detection closed loop suitable for industrial online quality inspection scenarios.
[0023] S1, collect images of the magnetic tile surface and build training sample dataset and test sample dataset.
[0024] The acquired images of the magnetic tile surface are as follows Figure 2 As shown. By Figure 2 As can be seen, the surface of the magnetic tile has a certain regular texture and contour structure, but subtle anomalies may exist in local areas, especially in edge areas, corner areas, and areas with texture changes, where small defects are more likely to appear. This indicates that the detection of defects on the surface of magnetic tiles is characterized by small defect scale, weak local differences, and high sensitivity to details. The acquisition device can be deployed above the conveying mechanism or at the gripping station of the robotic arm to acquire surface images of the magnetic tile to be inspected in real time. To reduce the influence of ambient light changes, reflections, and shadows on the detection results, it is preferable to use a ring light source, a strip light source, or a coaxial light source for auxiliary illumination.
[0025] In this embodiment, the main working surface of the magnetic tile is preferably selected as the detection area. Typical examples of defects on the surface of the magnetic tile are as follows: Figure 3 As shown, the defects include one or more forms such as nozzles, fractures, cracks, wear, and unevenness. Furthermore, different defects exhibit significant differences in shape, size, location, and texture. Some defects manifest as localized dark spots, fine cracks, or edge damage, demonstrating considerable complexity and diversity. This indicates that relying solely on traditional human experience or simple image processing methods is insufficient for stable identification.
[0026] For the acquired magnetic tile surface images, background removal, target region extraction, pose correction, and size unification are performed first, and then training sample datasets and test sample datasets are constructed respectively.
[0027] The training sample dataset preferably consists of images of defect-free, normal magnetic tile surfaces, used to train the anomaly detection model's ability to represent normal sample distributions. The test sample dataset consists of images of both normal and defective magnetic tile surfaces, used to verify the model's anomaly detection performance. Furthermore, both training and test sample images are uniformly scaled to a resolution of 518×518. Examples of the training and test sets are shown below. Figure 5 As shown, this invention employs a training method primarily based on normal samples. The training set mainly consists of images of defect-free magnetic tile surfaces, while the test set includes both normal and abnormal samples. This data organization method reduces reliance on a large number of defect-annotated samples, better reflecting the reality that defect samples are difficult to obtain adequately in industrial settings.
[0028] In this embodiment, the training sample dataset may contain 952 images of defect-free magnetic tile surfaces; the test sample dataset includes images of normal magnetic tile surfaces and images of magnetic tile surfaces with defects such as pores, fractures, cracks, wear, and unevenness. To facilitate visualization and comparison of the detection results, a labeling tool is used to annotate the defective regions in the test set. This annotation result is only used for effect comparison and performance evaluation and does not participate in model training. The annotation results for typical defective regions are shown below. Figure 4 As shown, the spatial distribution and area of various defects on the surface of the magnetic tile are not consistent, with some defects concentrated in the edge areas, corner areas, or areas of abrupt texture changes. This phenomenon indicates that the defects on the surface of the magnetic tile have strong locality and non-uniformity, and also provides a basis for subsequent local enhancement of edge areas, corner areas, and contour change areas in the model.
[0029] S2, construct a set of semantic hints for defects in magnetic tiles.
[0030] Unlike traditional methods that rely solely on image texture features for discrimination, this invention introduces a set of semantic clues for magnetic tile defects. It incorporates descriptions of the normal state of the magnetic tile surface, abnormal defect types, defect morphology features, and defect location into the detection process, thereby enhancing the model's semantic perception of fine-grained defects in industrial scenarios.
[0031] The semantic hint set for magnetic tile defects includes three categories: normal state hints, abnormal state hints, and morphological location hints. Among them, normal state hints are used to describe the surface of defect-free magnetic tiles; abnormal state hints are used to describe typical defects in magnetic tiles; and morphological location hints are used to describe the location and appearance characteristics of defects.
[0032] To enhance the stability of semantic expression, the semantic prompt set is preferably constructed using a template-based approach. Specifically, several semantic templates can be pre-defined, and defect lexicons, location lexicons, and appearance lexicons can be substituted into the templates to form multiple sets of text prompts. For the same defect category, multiple sets of synonymous expressions can also be constructed to enhance semantic robustness.
[0033] S3 extracts image and text features and generates image-level anomaly detection scores and local anomaly response maps.
[0034] Let the input image of the magnetic tile surface be... The image After preprocessing, the image is input into the visual feature extraction module to extract the global image features of the magnetic tile surface. and local region feature set ,in, This represents the number of local regions obtained after dividing the input image. Simultaneously, a pre-constructed set of semantic cues regarding magnetic tile defects is input into the text feature extraction module to extract normal-state text features. and abnormal state text feature set ,in, This indicates the number of categories of semantic hints for abnormal defects.
[0035] To mitigate the impact of different feature dimensions and numerical scales on the matching results, preferably, the image features and text features are normalized separately, and the normalized features are represented as follows: ; in, This represents the L2 norm.
[0036] The image-level anomaly detection score is calculated based on the similarity between global image features and text semantic features. Specifically, the normal matching score... Represented as: ; Abnormal matching score Represented as: ; in, The temperature coefficient is used to adjust the smoothness of the similarity distribution. Based on the normal matching score and the abnormal matching score, an image-level anomaly detection score is obtained. : ; Alternatively, it can be mapped to a normalized anomaly probability form: ; in, This represents the Sigmoid function.
[0037] The local anomaly response map is constructed by matching local region features with text semantic features. The input image is divided into... After the first local region, the second Abnormal response values of local regions Represented as: ; A local anomaly response map can be constructed from the anomaly response values of all local regions. : ; S4, enhances local anomaly regions and performs multi-scale fusion to generate defect heatmaps and comprehensive anomaly scores. The local anomaly response results of test defect samples on the model of this invention are as follows: Figure 7 As shown. Figure 7 This is used to demonstrate the abnormal response distribution obtained after inputting defect samples into the model of this invention during the testing phase. Figure 7 It can be seen that the model of the present invention has a good response capability to abnormal defect areas on the surface of magnetic tiles. It can form relatively obvious response areas at the locations of defects such as nozzles, cracks, fractures, wear, or unevenness. This indicates that the method can effectively extract local abnormal features on the surface of magnetic tiles and provide support for subsequent comprehensive abnormality score calculation and defect localization.
[0038] Since defects in magnetic tiles are more likely to occur in edge areas, corner areas, or areas with contour changes, local enhancement weights are further applied to the key areas. Thus, the weighted local anomaly response values are obtained: ; in, When the first When a local area is located at the edge, corner, or abrupt change in the contour of the magnetic tile... Take an enhancement weight greater than 1; when the th When a local region is located within a normal region This improves the detection sensitivity and positioning accuracy of local defects such as chipped edges, missing corners, and edge cracks.
[0039] To accommodate the detection needs of defects at different scales, the local anomaly response map is fused at multiple scales. Let the first... The local anomaly response map at each scale is as follows: A total of At each scale, the fused local anomaly response map Represented as: ; in, For the first The fusion weights at each scale satisfy: ; Based on this, the image-level anomaly detection score is... With the fused local anomaly response map A joint weighted fusion is performed to obtain a comprehensive anomaly score. : ; in, This serves as a balance between global and local anomaly scores. By employing this method, we can maintain the overall ability to identify anomalies in the entire magnetic tile image while highlighting the spatial location information of minute and local defects.
[0040] S5 outputs the detection results based on the comprehensive anomaly score and judgment threshold, and links with the production line control unit. The detection results of the test set on the test model are as follows: Figure 8 As shown. By Figure 8 As can be seen, when defects such as nozzles, cracks, fractures, wear, or unevenness exist on the surface of the magnetic tile, the model of this invention can form a relatively obvious high-response area at the corresponding defect location and output the corresponding comprehensive anomaly score. Combined with the defect semantic cue set, this invention can further output information on defect location, defect category, and defect severity, demonstrating that this method can not only achieve anomaly detection but also defect localization and a certain degree of semantic understanding.
[0041] Let the mean of the statistical distribution of abnormal scores in normal magnetic tile samples be . The standard deviation is Then determine the threshold. It can be represented as: ; in, This is the threshold adjustment coefficient, used to control the detection sensitivity. When the following conditions are met... If the current magnetic tile sample is abnormal, it is considered normal; otherwise, it is considered normal.
[0042] When the detection result is abnormal, this invention can also output a defect severity level. Let the area ratio of the abnormal region be... The abnormal response intensity is The defect location weight is The defect category weight is Then the severity score of the defect It can be represented as: ; in, For the corresponding weight coefficients, and satisfying: ; Based on ratings The range of values allows for the classification of surface defects in magnetic tiles into minor, moderate, and severe defects. The detection results are further input to the production line control unit for quality grading, production line alarm alerts, or non-conforming product sorting control, thus forming a complete closed loop across industries.
[0043] Based on the above methods, an anomaly detection model for industrial online quality inspection is established. The model includes a visual feature extraction module, a text feature extraction module, an anomaly score generation module, a local anomaly enhancement module, a multi-scale fusion module, and a result output module. The visual feature extraction module extracts global image features and local region features from the input magnetic tile image; the text feature extraction module extracts text semantic features corresponding to the set of semantic cues for magnetic tile defects; the anomaly score generation module establishes the matching relationship between image features and text semantic features to obtain an image-level anomaly discrimination score; the local anomaly enhancement module and the multi-scale fusion module generate local anomaly response maps and defect heatmaps, and output a comprehensive anomaly score; the result output module determines the detection result based on a threshold. The overall structure of the anomaly detection model is as follows: Figure 6 As shown, this invention combines the visual feature extraction process of magnetic tile surface images with the text feature extraction process of defect semantic cues. It generates image-level anomaly discrimination scores and local anomaly response maps through the matching relationship between image features and text features. Then, through local enhancement and multi-scale fusion, a comprehensive anomaly score and defect heatmap are obtained. Therefore, this invention can not only achieve a holistic determination of whether the magnetic tile surface is abnormal, but also take into account both defect location expression and category semantic expression, thereby improving the accuracy and interpretability of the detection results.
[0044] Example 1: Dataset and Related Parameter Settings The dataset in this embodiment is a dataset of surface defect images of magnetic tiles. This magnetic tile dataset is used to train and validate the applicability of the method in online quality inspection scenarios for magnetic tiles.
[0045] The dataset of images of defects on the surface of magnetic tiles is as follows: 1) Training dataset The training dataset consists of 952 images of the surface of defect-free magnetic tiles, which are preprocessed and uniformly set to 518×518 resolution to form the training sample dataset.
[0046] 2) Test dataset The test dataset includes images of normal magnetic tile surfaces and images of magnetic tile surfaces with defects. The defective images include at least one or more of the following: pores, fractures, cracks, wear, and inhomogeneities. The total number of images in the test set is 1344. To more intuitively demonstrate the detection results, a labeling tool can be used to annotate the defective regions in the test images. This annotation information is only used for visualizing the detection results and evaluating performance and does not participate in model training.
[0047] (3) Parameter setting and model training weight saving Considering the computing power and memory limitations of computers, the following parameters can be set during model training: batch size = 8, learning rate lr = 0.001, and first-order momentum coefficient. =0.9, second momentum coefficient =0.999, number of local regions =1369, Number of abnormal semantic prompt categories =5, number of multi-scale fusion scales =3, training epochs =30. After training, the optimal model weights are retained as parameters for the test model.
[0048] During the testing phase, the surface image of the magnetic tile to be inspected is input into the trained testing model, which outputs a comprehensive anomaly score, defect heatmap, defect location, and defect category information. The batch size for the testing phase is set to 1 to accommodate online piece-by-piece inspection requirements.
[0049] (4) Experimental platform configuration The experimental platform can be configured as follows: Intel Xeon E5-2680 v4 7-core processor, RTX 3090 graphics card, 30GB of memory, Ubuntu 22.04 operating system, Python 3.10 programming environment, and PyTorch 2.2.1 deep learning framework. Example 2: Model Performance Evaluation To evaluate the detection performance of the method, AUROC and AP metrics were used. A higher AUROC value indicates a stronger ability of the model to distinguish between normal and abnormal samples; a higher AP value indicates better model detection performance.
[0050] In the test set, normal and abnormal samples are input into the trained test model to obtain a comprehensive anomaly score. Based on this score, the AUROC and AP metrics are calculated. The curves of each metric on the test set are shown below. Figure 9 As shown in the figure. Combined with the experimental results, it can be seen that the method of the present invention achieves superior results in both pixel-level and image-level metrics, with a pixel-level AUROC of 91.9% and a pixel-level AP of 87.2%, and an image-level AUROC of 91.1% and an image-level AP of 86.6%. Figure 9 It can be seen that the present invention is superior to most comparative methods in terms of both local defect localization capability and overall anomaly discrimination capability, indicating that the constructed magnetic tile defect semantic prompt set, local anomaly enhancement mechanism and multi-scale fusion strategy are effective.
[0051] Example 3: Effectiveness comparison with the comparison method To verify the effectiveness of the proposed method, existing industrial anomaly detection methods were selected as comparative models, such as the original CLIP, U-Net, DeepLabV3, WinCLIP, AdaCLIP, and VAND visual language anomaly detection methods, and comparative experiments were conducted under the same experimental conditions. The experiments are shown in the table below.
[0052]
[0053] The results in the table show that the proposed method achieves superior results in both pixel-level and image-level detection metrics. In terms of pixel-level metrics, the proposed method achieves an AUROC of 91.9% and an AP of 87.2%, both higher than the original CLIP, U-Net, DeepLabV3, WinCLIP, AdaCLIP, and VAND, indicating that the proposed method has a strong ability to detect anomalies in localized defect areas on the magnetic tile surface and can more accurately locate defect areas. In terms of image-level metrics, the proposed method achieves an AUROC of 91.1% and an AP of 86.6%, also outperforming most of the comparison methods, indicating that the proposed method has good detection performance in the overall sample normal / abnormality determination task.
[0054] Further analysis reveals that traditional single-modal methods such as U-Net and DeepLabV3 perform relatively poorly in scenarios with complex defects on magnetic tile surfaces, while methods based on visual language modeling, such as WinCLIP, AdaCLIP, and VAND, show improved overall performance. Compared to the aforementioned methods, the proposed method introduces a set of semantic cues for magnetic tile defects and combines image-level anomaly discrimination scores with local anomaly response maps for joint modeling. It also performs local enhancements on edge regions, corner regions, and contour change regions, demonstrating better adaptability in detecting minute defects, edge defects, and weak local anomalies, thus achieving superior overall detection results.
[0055] Example 4: Training Process Analysis To further illustrate the optimization stability of the model during the training phase, the changes in the total loss function and the local anomaly constraint loss function during training are analyzed. The total loss function curve during training is shown below. Figure 10 As shown, the total loss function generally decreases with increasing training rounds, gradually stabilizing in the later stages of training, indicating that the model of this invention exhibits good convergence and stability during training. The local anomaly constraint loss function curve during training is shown in the figure. Figure 11As shown, the local anomaly constraint loss decreases continuously during training and eventually stabilizes, indicating that the model's ability to represent local anomaly regions gradually improves, and it becomes more sensitive to anomalies in edge regions, corner regions, and regions with contour changes. This further verifies that the local anomaly enhancement mechanism and local constraint strategy designed in this invention can effectively improve the detection sensitivity and localization accuracy of minute defects, edge defects, and weak local anomalies, thereby improving the overall detection performance.
[0056] This invention validated the method on a magnetic tile defect dataset. Experimental results show that the image-level AUROC reaches 91.1% on the magnetic tile dataset, which is 2.3% higher than the existing method AnomalyCLIP; the AP reaches 86.6%, which is 4.3% higher than the existing method. This method has high detection accuracy, good detection stability, and good engineering application value, and can effectively improve the automation level of industrial online quality inspection.
[0057] In summary, the magnetic tile surface defect detection method proposed in this invention for industrial online quality inspection can achieve stable detection and accurate localization of magnetic tile surface defects under conditions of limited defect samples, complex defect types, and variable industrial operating conditions. By constructing a set of semantic clues for magnetic tile defects and combining image-level anomaly discrimination, local anomaly enhancement, and multi-scale fusion mechanisms, this invention effectively improves the detection capability for various types of defects such as nozzles, fractures, cracks, wear, and inhomogeneities, while also possessing good robustness, interpretability, and industrial application value.
Claims
1. A method for detecting surface defects in magnetic tiles for industrial online quality inspection, characterized in that, The detection methods include: Step 1: Obtain images of the magnetic tile surface during the production line conveying process, and preprocess the magnetic tile surface images to obtain standardized input images; Step 2: Based on the normal surface condition, defect type, defect morphology characteristics and defect location description of the magnetic tile, construct a set of semantic hints for magnetic tile defects; Step 3: Extract visual features from the standardized input image to extract global image features and local region features of the magnetic tile surface; extract text features from the set of semantic prompts for magnetic tile defects to extract corresponding text semantic features. Step 4: Based on the matching relationship between global image features and text semantic features, generate image-level anomaly discrimination scores for the magnetic tile surface, and construct local anomaly response maps based on local region features; Step 5: Fuse the image-level anomaly discrimination score with the local anomaly response map to generate a thermal map of defects on the magnetic tile surface and a comprehensive anomaly score; Step 6: Set a preset or adaptive judgment threshold, compare the comprehensive abnormal score with the judgment threshold, and determine whether the magnetic tile surface is normal or abnormal. Step 7: Output the defect location, defect type, and defect severity information, and output the detection results to the industrial online quality inspection department to perform defect alarm, product classification, sorting, or rejection of non-conforming products.
2. The method for detecting surface defects of magnetic tiles for industrial online quality inspection according to claim 1, characterized in that, In step 3, the input magnetic tile surface image is processed. Visual feature extraction was performed to obtain global image features of the magnetic tile surface. and local region feature set ,in, This represents the number of local regions obtained after dividing the input image; simultaneously, text feature extraction is performed on the pre-constructed set of semantic cues for magnetic tile defects to obtain normal state text features. and abnormal state text feature set ,in, The number of categories representing semantic hints for abnormal defects; The image features and text features are normalized separately. The normalized features are represented as follows: ; in, This represents the L2 norm.
3. The method for detecting surface defects of magnetic tiles for industrial online quality inspection according to claim 1, characterized in that, In step 4, the image-level anomaly detection score is calculated based on the similarity between global image features and text semantic features, while the normal matching score is calculated based on the similarity between these features. Represented as: ; Abnormal matching score Represented as: ; in, This is a temperature coefficient used to adjust the smoothness of the similarity distribution; Based on the normal matching score and the abnormal matching score, an image-level anomaly detection score is obtained. : ; Mapped to the normalized anomaly probability form: ; in, This represents the Sigmoid function.
4. The method for detecting surface defects of magnetic tiles for industrial online quality inspection according to claim 1, characterized in that, In step 4, the local anomaly response map is constructed by matching the local region features with the text semantic features, thus dividing the input image into... After the first local region, the second... Abnormal response values of local regions Represented as: ; The local anomaly response map is composed of the anomaly response values of all local regions. : ; Since defects in magnetic tiles are more likely to occur in edge areas, corner areas, or areas with contour changes, local enhancement weights are applied to key areas. The weighted local anomaly response values are obtained as follows: ; in, When the first When a local area is located at the edge, corner, or abrupt change in the contour of the magnetic tile... Take an enhancement weight greater than 1; when the... When a local region is located within a normal region Improve the detection sensitivity and positioning accuracy of local defects such as chipped edges, missing corners, and edge cracks.
5. The method for detecting surface defects of magnetic tiles for industrial online quality inspection according to claim 1, characterized in that, Step 5: To accommodate the detection needs of defects at different scales, multi-scale fusion is performed on the local anomaly response map. Let the first... The local anomaly response map at each scale is as follows: A total of At each scale, the fused local anomaly response map Represented as: ; in, For the first The fusion weights at each scale satisfy: ; Image-level anomaly discrimination score With the fused local anomaly response map A joint weighted fusion is performed to obtain a comprehensive anomaly score. : ; in, This is the balance coefficient between global outlier scores and local outlier scores. This represents the maximum response value in the merged local anomaly response graph.
6. The method for detecting surface defects of magnetic tiles for industrial online quality inspection according to claim 1, characterized in that, In step 6, a preset or adaptively determined judgment threshold is used to compare the comprehensive abnormal score with the judgment threshold, and the magnetic tile surface is judged as normal / abnormal. The judgment threshold is adaptively determined based on the distribution of normal samples, and the mean of the statistical distribution of abnormal scores of normal magnetic tile samples is [value missing]. The standard deviation is Then determine the threshold. Represented as: ; in, This is the threshold adjustment coefficient, used to control the detection sensitivity; When the comprehensive abnormal score is satisfied If the current magnetic tile sample is abnormal, it is considered normal; otherwise, it is considered normal.
7. The method for detecting surface defects of magnetic tiles for industrial online quality inspection according to claim 1, characterized in that, In step 6, when the detection result is abnormal, the severity level of the defect is output, assuming the area ratio of the abnormal region is... The abnormal response intensity is The defect location weight is The defect category weight is Then the severity score of the defect Represented as: ; in, For the corresponding weight coefficients, and satisfying: ; Based on ratings The range of values is used to classify the surface defects of magnetic tiles into minor defects, medium defects, and severe defects, for use in quality grading, production line alarm prompts, or non-conforming product sorting control.
8. The method for detecting surface defects of magnetic tiles for industrial online quality inspection according to claim 1, characterized in that, Before defect detection, the visual feature extraction and text feature extraction in step 3 are jointly optimized using image-text alignment loss and local anomaly constraint loss. The total loss function is expressed as: ; in, This represents the global image-text alignment loss. This represents the loss due to local anomaly constraints. These are the loss weighting coefficients; The global image-text alignment loss is expressed as: ; The loss due to local anomaly constraints can be expressed as: ; in, Indicates the first The target anomaly response value or monitoring guidance value corresponding to each local area; By jointly optimizing the loss function, the matching accuracy between image features and text semantic features is improved, and the representation ability of local abnormal regions is enhanced.
9. The method for detecting surface defects of magnetic tiles for industrial online quality inspection according to claim 1, characterized in that, In step 2, the set of semantic prompts for magnetic tile defects includes normal state prompts, abnormal state prompts, and shape location prompts. Among them, normal state prompts are used to describe the surface of defect-free magnetic tiles, abnormal state prompts are used to describe one or more defects such as pores, fractures, cracks, wear, and unevenness, and shape location prompts are used to describe the location of defects in edge regions, corner regions, central regions, texture abrupt regions, or contour destruction regions. The set of semantic prompts for magnetic tile defects is generated using a template-based construction method, including generating prompt statements based on the combination of predefined semantic templates and a defect lexicon.