Self-Supervised Anomaly Detection Method and System for Steel Sections Based on Dynamic Negative Sample Mining

Through the self-supervised learning method of dynamic negative sample mining, a multi-branch network model is constructed to generate synthetic abnormal samples, solving the problems of high training difficulty and high sample demand in steel surface defect detection, and achieving efficient and accurate defect detection.

CN119991655BActive Publication Date: 2025-07-25FUZHOU UNIV +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510457255.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-14
Publication Date
2025-07-25
Estimated Expiration
2045-04-14

AI Technical Summary

Technical Problem

The prior art has problems such as high training difficulty, large sample demand, slow detection speed and limited recognition ability of micro defects in steel surface defect detection, which is difficult to meet the needs of efficient and precise detection of modern industries.

Method used

Using a self-supervised learning method based on dynamic negative sample mining, a multi-branch network model is constructed, and synthetic anomaly samples are generated using anomaly-free samples, and global anomaly samples at the feature level are dynamically generated, and self-supervised anomaly detection of steel cross-sections is performed.

Benefits of technology

It is easy to train when there are small samples and many defect categories, has high detection ability and excellent detailed processing ability, and is suitable for steel surface defect detection, improving the efficiency and accuracy of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119991655B_ABST
    Figure CN119991655B_ABST
Patent Text Reader

Abstract

The present invention proposes a self-supervised anomaly detection method and system for steel sections based on dynamic negative sample mining. The steps of the method are as follows: S1. Construct a multi-branch network model; S2. The anomaly-free sample images of the steel sections are intercepted for the significant regions through edge saliency analysis to obtain anomaly-free sample sub-images and edge saliency binary images; S3. The random Berlin noise images are combined with the edge saliency binary images. After generating a synthetic mask one according to the minimum intersection principle, an anomaly mask is obtained through anomaly region screening and smoothing processing; Synthetic anomaly images are generated using texture data, the anomaly mask, and the anomaly-free sample sub-images; S4. The multi-branch network model is trained using the anomaly-free sample sub-images and the synthetic anomaly samples to obtain a trained multi-branch network model for anomaly detection of steel section sample images. The present invention is applicable to complex situations with few samples, many defect categories, and difficult training, and has the advantages of easy training, high detection ability, and excellent detail processing ability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of machine vision surface defect detection, and in particular to a steel cross-section self-supervised anomaly detection method and system based on dynamic negative sample mining. Background Art

[0002] In the process of steel production, the analysis of elemental composition is crucial. The mechanical properties (such as strength, hardness, toughness) and corrosion resistance of steel are closely related to its chemical composition. In order to ensure that the various properties of steel meet the standards, its elemental composition needs to be accurately analyzed and controlled during the steel production process. Among them, spark spectroscopy is widely used in the elemental analysis of steel due to its high efficiency and rapidity. This method identifies the chemical element composition of steel by inducing spark discharge on the steel surface and analyzing the spectral signal generated by the spark. However, this method has high requirements for the surface quality of steel. The surface must be smooth, flat, clean and free of contaminants to ensure the stability of spark discharge and the accuracy of spectral signals. If there are defects or impurities on the steel surface, it will affect the discharge process, resulting in unstable spectral signals, which in turn affects the accurate measurement of elemental composition. Therefore, determining the optimal spark excitation position through surface defect detection plays an important role in improving the accuracy of elemental analysis of steel.

[0003] Although traditional surface defect methods are effective in some cases, they cannot meet the needs of modern industry for efficient and accurate defect detection due to their reliance on manual operation, slow detection speed and limited ability to identify tiny defects. With the development of automation technology and artificial intelligence technology, surface defect detection technologies based on machine vision, deep learning and other methods have gradually been widely used, which can overcome the shortcomings of traditional methods and provide more efficient and accurate detection methods. However, due to the large initial labor costs required for the construction of steel surface defect training data and defect location annotation, they often face the problems of high training difficulty and excessive sample demand, and it is still difficult to meet current actual needs. Summary of the invention

[0004] The purpose of the present invention is to propose a self-supervised anomaly detection method and system for steel cross-sections based on dynamic negative sample mining. The method adopts self-supervised learning and does not require abnormal samples. It is suitable for complex situations with a small number of samples, many defect categories and difficult training. It has the advantages of easy training, high detection capability and excellent detail processing capability.

[0005] To achieve the above object, the technical solution of the present invention is as follows:

[0006] A self-supervised anomaly detection method for steel sections based on dynamic negative sample mining, the method comprising the following steps:

[0007] Step S1: Construct a multi-branch network model, which includes a feature extraction layer E , a linear mapping layer L , a multi-branch feature extraction layer M , an adaptive parameter generation layer P and a discrimination layer D ;

[0008] Step S2: The anomaly-free sample map of the steel section is used to intercept the significant region through edge saliency analysis to obtain an anomaly-free sample sub-map I P and an edge saliency binary map M e ;

[0009] Step S3: Use the anomaly-free sample sub-map I P obtained in Step S2 as the base map for synthesizing abnormal samples. First, generate a random Perlin noise map, and combine it with the significant binary map M e obtained in Step S2 to generate a synthetic mask one according to the minimum intersection principle. The synthetic mask one is subjected to abnormal region screening and smoothing processing to obtain an abnormal mask mask. Then, obtain texture data from the DTD texture database, and mix the texture data with the anomaly-free sample sub-map I P in the abnormal mask region according to a preset distribution ratio to obtain a synthetic abnormal sample I N (image-level abnormal sample);

[0010] Step S4: Use the anomaly-free sample sub-map I P and the synthetic abnormal sample I N obtained in Steps S2 and S3 as the input of the multi-branch network model for model training, and obtain a trained multi-branch network model for anomaly detection of steel section sample maps;

[0011] Step S5: Input the steel section sample map to be detected into the feature extraction layer E , and sequentially pass through the feature extraction layer E and the linear mapping layer L to obtain a high-dimensional feature vector v , with a shape of ( B , C ), B is the output batch size of the feature extraction layer, and C represents the output dimension of the linear mapping layer;

[0012] The high-dimensional feature vector v is input into the multi-branch feature extraction layer MAmong them, the output branch feature vector V , with a shape of ( B , C , N ), N indicating the number of branches of the branch network;

[0013] According to the branch feature vector V obtain the input D of the discriminant layer V o :

[0014]

[0015] Among them, represents that the vector A is concatenated with the vector B in the vector dimension d , represents taking the expectation of the vector x along the dimension d , represents the expected value of the branch feature vector V along dimension 3;

[0016] Input V o into the discriminant layer D to obtain an anomaly score, with a shape of ( B , 1), where 1 represents; reshape the said shape to a size of ( b , h , w ) to obtain the spatial anomaly mask of the image to be detected, where b , h and w respectively represent the input batch, the height of the anomaly mask map, and the width of the anomaly mask map.

[0017] Preferably, the multi-branch feature extraction layer M has a settable number of branches N , and each branch adopts an asymmetric coding network structure with a 4-fold dimensionality reduction first and then a 2-fold dimensionality increase.

[0018] Preferably, the step S2 is specifically: perform edge saliency analysis on the anomaly-free sample image, and generate a k × k grid saliency matrix through average pooling; after normalizing the matrix to a discrete probability distribution, select the saliency center according to this probability distribution, and crop the anomaly-free sample image according to the saliency center and a given size to obtain the anomaly-free sample sub-image I P ; obtain the edge saliency binary map by performing morphological operations and adaptive binarization operations on the saliency probability mapM e .

[0019] Preferably, the step S4 is specifically as follows:

[0020] Step S4.1: Input the subgraph of the non-abnormal sample I P and the synthesized abnormal sample I N into the feature extraction layer E in sequence, and pass through the feature extraction layer E and the linear mapping layer L to obtain high-dimensional feature vectors v p and v S ;

[0021] Step S4.2: Input the high-dimensional feature vectors v p and v S into the multi-branch feature extraction layer M to output the non-abnormal feature V P and the synthesized abnormal feature V S (image-level abnormal feature), with the shape of ( B , C , N );

[0022] Step S4.3: Calculate the standard deviation of the feature vectors of the non-abnormal features V P output by each branch as the input of the adaptive parameter generation layer to obtain the dynamic adjustment coefficient P ; ;

[0023] Step S4.4: Based on the difference in the feature distributions of the synthesized abnormal feature M output by the branch feature extraction layer V S and the non-abnormal feature V P , construct the aggregation-divergence loss to guide the feature space distribution of the multi-branch network model, and dynamically generate global negative example Gaussian samples V P based on the non-abnormal feature G n as the Gaussian abnormal feature V G (feature-level abnormal feature), with the shape of ( B , C , N), and guiding the branch network model to learn differential features through the clustering loss;

[0024] Step S4.5: According to the non-abnormal features V P , synthesize abnormal features V S and Gaussian abnormal features V G to obtain the input of the discriminant layer D ; V' o ;

[0025] Step S4.6: Input V' o into the discriminant layer D . The features output by the discriminant layer D are D m , with a shape of (3 B , 1), where 3 B represents the dimension occupied by each sample in the 3 samples during the training phase B ; Reshape D m into (3, b , h , w ), and the reshaped dimension 1 corresponds to the mask outputs of Gaussian abnormal samples, synthetic abnormal samples, and non-abnormal samples D P respectively; For Gaussian abnormal samples and non-abnormal samples, binary cross-entropy loss is used; For synthetic abnormal samples, focal loss is used; Construct the final network mask loss D G to train the model. D S and D P ; maskloss Preferably, the adaptive parameter generation layer

[0026] is composed of a Z-score normalization module of the branch standard deviation and a single-layer fully connected layer; The obtaining of the dynamic adjustment coefficient P is specifically: The standard deviation of the feature vector of the non-abnormal feature V P is Z-score normalized by the Z-score normalization module, and then input into the single-layer fully connected layer to obtain the dynamic adjustment coefficient . ;

[0027] Preferably, according to the non-abnormal features V P , synthetic abnormal featuresV S and Gaussian anomaly features V G Obtain the discriminant layer D input V' o ; Specifically:

[0028] The non - anomaly features V P , synthetic anomaly features V S and Gaussian anomaly features V G are concatenated on vector dimension 1 to obtain a comprehensive feature V' , and the expected value of the comprehensive feature is calculated on vector dimension 3 to obtain the mean value V' ; The input of the discriminant layer is D input V' o satisfies:

[0029]

[0030] Among them, represents the vector A、 vector B is concatenated with the vector C on the vector dimension d .

[0031] Preferably, the difference in the feature distribution between the synthetic anomaly features M output by the branch feature extraction layer V S and the non - anomaly features V P is used to construct a clustering - separation loss to guide the feature space distribution of the multi - branch network model, and based on the non - anomaly features V P dynamically generate global negative example Gaussian samples G n ; Specifically:

[0032]

[0033] Among them, and are respectively the non - anomaly features (positive sample feature vectors) at the multi - branch feature extraction layer e in the e - th round of training and the global negative example Gaussian samples generated according to the non - anomaly features M , is the standard deviation of the feature vector of the non - anomaly features in the e - th round of training, ​is the adaptive parameter generation layer in the e-th round of training P The dynamically adjusted coefficient output and are respectively e The learnable adjustment parameter and the learning rate corresponding to the learnable adjustment parameter in the round of training is 、 and The product of and represents The random noise part in, Z is a standard Gaussian distribution, satisfying , is the gradient of the Gaussian abnormal sample loss of the discriminant layer with respect to the feature vector x

[0034] Preferably, the clustering loss adrloss Is generated at the multi-branch feature extraction layer M And is used to guide the branch network model to learn differential features. The clustering loss adrloss Satisfy:

[0035]

[0036] Among them, Is the gradient value of the direction noise; is The standard deviation of dimension 3, updated with the network; is The mean along dimension 3, N Is the number of network branches, and Are respectively the standard deviations of the feature vectors of the anomaly-free feature V P And the synthetic anomaly feature V S , and Respectively represent the learnable adjustment parameter and the dynamic adjustment coefficient.

[0037] Preferably, the network mask loss maskloss Specifically:

[0038]

[0039] Among them, and Are respectively the binary cross-entropy loss and the focal loss of the vectors x and y , mask Is the anomaly mask of the synthetic anomaly sample. 1 and 0 respectively represent the 1-filled vector and the 0-filled vector of the same size as the input vector.

[0040] ​A self-supervised anomaly detection system for steel sections based on dynamic negative sample mining, comprising a processor, a memory, and a computer program stored on the memory. When the processor executes the computer program, it specifically executes the steps in the above-mentioned self-supervised anomaly detection method for steel sections based on dynamic negative sample mining.

[0041] Compared with the prior art, the present invention has the following beneficial effects:

[0042] The present invention proposes a new multi-branch network and a self-supervised anomaly detection method based on dynamic negative sample mining of this network. This method dynamically generates global anomaly samples at the feature level through the feature deviation between normal samples and image-level local anomaly samples generated therefrom. It is applicable to complex situations with few samples, many defect categories, and difficult training. It has the advantages of easy training, high detection ability, and excellent detail processing ability, and does not require additional anomaly samples, thus having high practicality and broad application prospects in the field of surface defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 It is a detection result diagram of a multi-branch network model for samples with different anomaly ranges after 200 rounds of training using 25 defect-free steel section pictures in an embodiment of the present invention;

[0044] Figure 2 It is a schematic diagram of the synthesis strategy of image-level anomaly samples in an embodiment of the present invention;

[0045] Figure 3 It is an architecture diagram of a multi-branch network applicable to dynamic negative sample mining in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0046] The following will specifically describe the technical solutions of the present invention in conjunction with the attached Figures 1-3 , diagrams.

[0047] It should be noted that the following detailed description is exemplary and is intended to provide further illustration of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present application belongs.

[0048] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0049] The present invention proposes a self-supervised anomaly detection method for steel sections based on dynamic negative sample mining, referring to Figures 2-3 , the method includes the following steps:

[0050] Step S1: Construct a multi-branch network model, the multi-branch network model includes a feature extraction layer E , a linear mapping layer L , a multi-branch feature extraction layer M , an adaptive parameter generation layer P and a discriminant layer D ;

[0051] Step S2: The anomaly-free sample map of the steel section intercepts the significant region through edge saliency analysis to obtain an anomaly-free sample sub-map I P and an edge saliency binary map M e ;

[0052] Step S3: Use the anomaly-free sample sub-map I P obtained in step S2 as the base map for synthesizing anomaly samples; First, generate a random Berlin noise map, and combine it with the significant binary map M e obtained in step S2, and generate a synthetic mask one according to the minimum intersection principle; The synthetic mask one is subjected to anomaly region screening and smoothing processing to obtain an anomaly mask mask; Then, obtain texture data from the DTD texture database, and according to a preset distribution ratio (for example, according to distribution ratio) mix the texture data with the anomaly-free sample sub-map I P in the anomaly mask area in proportion to obtain a synthetic anomaly sample I N (image-level anomaly sample);

[0053] Step S4: Use the anomaly-free sample sub-map I P and the synthetic anomaly sample I N obtained in steps S2 and S3 as the input of the multi-branch network model for model training, and obtain a trained multi-branch network model for anomaly detection of steel section sample maps;

[0054] Step S5: Input the steel section sample map to be detected into the feature extraction layer E , and successively pass through the feature extraction layer E and the linear mapping layer L to obtain a high-dimensional feature vector v , with a shape of ( B , C ),B The output batch size of the feature extraction layer is denoted as, and C represents the output dimension of the linear mapping layer;

[0055] High-dimensional feature vector v Input multi-branch feature extraction layer M Among them, the output branch feature vector V , with a shape of ( B , C , N ), N indicating the number of branches of the branch network;

[0056] According to the branch feature vector V obtain the input of the discrimination layer D : V o :

[0057]

[0058] Among them, represents the vector A concatenated with the vector B at the vector dimension d , represents taking the expectation of the vector x along the dimension d , represents the expected value of the branch feature vector V along dimension 3;

[0059] Input V o into the discrimination layer D to obtain the anomaly score, with a shape of ( B , 1), where 1 represents; reshape the said shape to a size of ( b , h , w ) to obtain the spatial anomaly mask of the image to be detected, where b , h and w respectively represent the input batch, the height of the anomaly mask map, and the width of the anomaly mask map.

[0060] In this embodiment, the multi-branch feature extraction layer M has a settable number of branches N , and each branch adopts an asymmetric coding network structure with a 4-fold dimensionality reduction first and then a 2-fold dimensionality increase.

[0061] In this embodiment, step S2 is specifically: perform edge saliency analysis on the anomaly-free sample image, and generate k × kGrid (e.g., 8×8 grid) saliency matrix; after normalizing the matrix into a discrete probability distribution, select the saliency center according to this probability distribution, and crop the anomaly-free sample image according to the saliency center and the given size to obtain an anomaly-free sample sub-image I P ; Obtain the edge saliency binary map by performing morphological operations and adaptive binarization operations on the saliency probability map M e .

[0062] In this embodiment, the specific steps of step S4 are as follows:

[0063] Step S4.1: Input the anomaly-free sample sub-image I P and the synthetic anomaly sample I N into the feature extraction layer E in turn, and pass through the feature extraction layer E and the linear mapping layer L to obtain high-dimensional feature vectors v p and v S ;

[0064] Step S4.2: Input the high-dimensional feature vectors v p and v S into the multi-branch feature extraction layer M to output the anomaly-free feature V P and the synthetic anomaly feature V S (image-level anomaly feature), with the shape of ( B , C , N );

[0065] Step S4.3: Calculate the standard deviation of the feature vectors of the anomaly-free features V P output by each branch as the input of the adaptive parameter generation layer to obtain the dynamic adjustment coefficient P ; ;

[0066] Step S4.4: Dynamically generate a global negative example Gaussian sample M S V as the Gaussian anomaly feature according to the difference distribution between the synthetic anomaly feature V P output by the branch feature extraction layerand the anomaly-free feature G n ​V G (Feature-level abnormal feature), with a shape of ( B , C , N ), and guiding the branch network model to learn differential features through the clustering loss;

[0067] Step S4.5: Obtain the input V P of the discriminant layer V S according to the non-abnormal feature V G and the Gaussian abnormal feature D ; V' o ;

[0068] Step S4.6: Input V' o into the discriminant layer D . The feature output by the discriminant layer D is D m , with a shape of (3 B , 1), where 3 B represents the dimension occupied by each of the 3 samples in the training stage B ; Reshape D m to (3, b , h , w ). The reshaped dimension 1 corresponds to the mask outputs D P of the Gaussian abnormal sample, the synthetic abnormal sample, and the non-abnormal sample D G , D S and D P respectively; For the Gaussian abnormal sample and the non-abnormal sample, use binary cross-entropy loss; For the synthetic abnormal sample, use focal loss; Construct the final network mask loss maskloss for model training.

[0069] In this embodiment, the adaptive parameter generation layer P is composed of a Z-score normalization module of the branch standard deviation and a single-layer fully connected layer; The obtaining of the dynamic adjustment coefficient is specifically: performing Z-score normalization on the standard deviation V P of the feature vector of the non-abnormal feature through the Z-score normalization module, and then inputting it into the single-layer fully connected layer to obtain the dynamic adjustment coefficient .

[0070] In this embodiment, the discriminant layer V P , synthetic anomaly features V S and Gaussian anomaly features V G are used to obtain the input D ; specifically: V' o ; specifically:

[0071] The non - anomaly features V P , synthetic anomaly features V S and Gaussian anomaly features V G are concatenated on vector dimension 1 to obtain a comprehensive feature V' , and the expected value of the comprehensive feature V' is calculated on vector dimension 3 to obtain the mean ; the input D of the discriminant layer V' o satisfies:

[0072]

[0073] where represents the vector A、 vector B and the vector C are concatenated on the vector dimension d .

[0074] In this embodiment, based on the difference in the feature distributions between the synthetic anomaly features M output by the branch feature extraction layer V S and the non - anomaly features V P , a clustering - separation loss is constructed to guide the feature space distribution of the multi - branch network model, and global negative example Gaussian samples V P are dynamically generated based on the non - anomaly features G n ; specifically:

[0075]

[0076] where and are respectively the non - anomaly features (positive sample feature vectors) at the multi - branch feature extraction layer e in the M round of training and the non - anomaly features according to The generated global negative Gaussian samples is the standard deviation of the feature vector without abnormal features in the e-th round of training is the dynamically adjusted coefficient output by the adaptive parameter generation layer in the e-th round of training P and are respectively the learnable adjustment parameter and the learning rate corresponding to the learnable adjustment parameter in the e th round of training, is , and 's product and represents the random noise part in , Z is a standard Gaussian distribution, satisfying , is the gradient of the discriminant layer Gaussian anomaly sample loss with respect to the feature vector x

[0077] In this embodiment, the aggregation and repulsion loss adrloss (Aggregation and Repulsion loss) is generated at the multi-branch feature extraction layer M and is used to guide the branch network model to learn differential features. The aggregation and repulsion loss adrloss satisfies:

[0078]

[0079] where, is the gradient value of the direction noise; is the standard deviation of dimension 3, which changes with the network update; is the mean along dimension 3, N is the number of network branches, and are respectively the standard deviations of the feature vectors of the non-abnormal feature V P and the synthetic abnormal feature V S , and respectively represent the learnable adjustment parameter and the dynamically adjusted coefficient.

[0080] In this embodiment, the network mask loss maskloss is specifically:

[0081]

[0082] where, and ​​​They are the binary cross-entropy loss and the focal loss of vectors x and y respectively. mask It is the anomaly mask for synthesizing anomaly samples. 1 and 0 represent the 1-filled vector and 0-filled vector with the same size as the input vector respectively.

[0083] The present invention also provides a self-supervised steel section anomaly detection system based on dynamic negative sample mining, including a processor, a memory, and a computer program stored on the memory. When the processor executes the computer program, it specifically executes the steps in the above-mentioned self-supervised steel section anomaly detection method based on dynamic negative sample mining.

[0084] In summary, the present invention relates to a dynamic negative sample mining strategy for unsupervised networks, which is applicable to the detection of cylindrical steel section defects. This strategy is based on a multi-branch network and dynamically generates global anomaly samples at the feature level according to the feature deviation between non-anomaly samples and image-level local anomaly samples generated therefrom. This method is particularly applicable to complex situations with few samples, many defect categories, and difficult training. Compared with the static noise strategy, the dynamic noise strategy proposed by the present invention shows excellent performance in terms of training speed, detection rate, and detail processing ability, and has significant practical application value in the field of surface defect detection. As Figure 1 shown (where the pictures in groups a, b, c, and d are the detection result pictures of non-anomaly samples, large-range anomaly samples, medium-range anomaly samples, and small-range anomaly samples respectively), under the harsh condition of only 25 defect-free steel section pictures, the present invention can still effectively detect steel section defects after 200 rounds of training, showing good detection effects.

[0085] The above are only the preferred embodiments of the present invention, and the present invention is not limited to other forms. Any person skilled in the art may use the disclosed technical content to make changes or modifications into equivalent embodiments with equivalent changes. However, any simple modification, equivalent change, and modification made to the above embodiments based on the technical essence of the present invention without departing from the technical solution content of the present invention still fall within the protection scope of the technical solution of the present invention.

Claims

1. A self-supervised anomaly detection method for steel sections based on dynamic negative sample mining, characterized in that The method includes the following steps: Step S1: Construct a multi-branch network model, where the multi-branch network model includes a feature extraction layer E, a linear mapping layer L, a multi-branch feature extraction layer M, an adaptive parameter generation layer P, and a discriminant layer D; Step S2: The non-abnormal sample diagram of the steel section intercepts the significant region through edge significance analysis to obtain the non-abnormal sample sub-diagram I P and the significant binary diagram M e ; Step S3: Use the anomaly-free sample sub-graph I obtained in Step S2 P as the base graph for synthesizing anomaly samples; First, generate a random Perlin noise graph and combine it with the saliency binary graph M obtained in Step S2 e , and generate the first synthesis mask according to the minimum intersection principle; The first synthesis mask is obtained through anomaly region screening and smoothing to obtain the anomaly mask mask; Then, obtain texture data from the DTD texture database, and mix the texture data and the anomaly-free sample sub-graph I P proportionally in the anomaly mask region to obtain the synthesized anomaly sample I N ; Step S4: Use the anomaly-free sample subgraph I obtained in Step S2 and Step S3 P and the synthesized anomaly sample I N as the input of the multi-branch network model for model training, and obtain a trained multi-branch network model for anomaly detection of steel section sample diagrams; Step S5: Input the steel cross-section sample image to be detected into the feature extraction layer E, and obtain a high-dimensional feature vector v after passing through the feature extraction layer E and the linear mapping layer L in sequence. The shape of v is (B, C), where B is the output batch size of the feature extraction layer, and C represents the output dimension of the linear mapping layer; The high-dimensional feature vector v is input into the multi-branch feature extraction layer M, and the branch feature vector V is output. The shape of V is (B, C, N), where N represents the number of branches of the branch network; Obtain the input V of the discrimination layer D according to the branch feature vector V o : Among them, indicates that vector μ and vector are concatenated in vector dimension 2, indicates taking the expectation of vector V along dimension 3, indicates taking the expectation of vector (V - μ) 2 along dimension 3, and μ represents the expected value of branch feature vector V along dimension 3; Input V o into the input discrimination layer D to obtain an anomaly score; reshape its size to (b, h, w) to obtain the spatial anomaly mask of the image to be detected, where b, h, and w represent the input batch, the height of the anomaly mask map, and the width of the anomaly mask map, respectively.

2. The self-supervised anomaly detection method for steel sections based on dynamic negative sample mining according to claim 1, wherein The multi-branch feature extraction layer M has a settable number of branches N, and each branch adopts an asymmetric encoding network structure with a 4-fold dimensionality reduction first and then a 2-fold dimensionality increase; 3. The self-supervised anomaly detection method for steel sections based on dynamic negative sample mining according to claim 1, characterized in that, The specific steps of step S2 are as follows: perform edge saliency analysis on the anomaly-free sample images, and generate a k×k grid saliency matrix through average pooling; after normalizing the matrix into a discrete probability distribution, select the saliency center according to this probability distribution, and crop the anomaly-free sample images according to the saliency center and the given size to obtain the anomaly-free sample sub-images I P ; obtain the edge saliency binary map M by performing morphological operations and adaptive binarization operations on the saliency probability map e .

4. The self-supervised anomaly detection method for steel sections based on dynamic negative sample mining according to claim 2, characterized in that, The specific content of step S4 is as follows: Step S4.1: Input the non-abnormal sample sub-graph I P and the synthesized abnormal sample I N into the feature extraction layer E respectively, and sequentially pass through the feature extraction layer E and the linear mapping layer L to obtain the high-dimensional feature vectors v p and v S ; Step S4.2: Input the high-dimensional feature vectors v p and v S into the multi-branch feature extraction layer M, and output the non-abnormal feature V P and the synthesized abnormal feature V S , with the shape of (B, C, N); Step S4.3: Calculate the standard deviation σ of the eigenvector of the anomaly-free feature V output by each branch P as the input of the adaptive parameter generation layer P to obtain the dynamic adjustment coefficient α; P ​ Step S4.4: Extract the synthesized anomaly feature V output by the branch feature extraction layer M S and the feature distribution difference from the anomaly-free feature V P to construct a clustering and separation loss for guiding the feature space distribution of the multi-branch network model, and dynamically generate a global negative example Gaussian sample G P based on the anomaly-free feature V n as the Gaussian anomaly feature V G , with the shape of (B, C, N); Step S4.5: According to the non-abnormal feature V P , synthesize the abnormal feature V S and the Gaussian abnormal feature V G to obtain the input V' of the discriminant layer D o ; Step S4.6: Take V' o as the input to discriminant layer D. The feature output by discriminant layer D is D m , with a shape of (3B, 1), where 3B means that each of the 3 samples in the training stage occupies a dimension of B; reshape D m into (3, b, h, w). The reshaped dimension 1 corresponds to the mask outputs D G , D S and D P of the Gaussian anomaly sample, the synthetic anomaly sample, and the non - anomaly sample in sequence; for the Gaussian anomaly sample and the non - anomaly sample, use binary cross - entropy loss; for the synthetic anomaly sample, use focal loss; construct the final network mask loss maskloss for model training.

5. The self-supervised anomaly detection method for steel sections based on dynamic negative sample mining according to claim 4, characterized in that, The adaptive parameter generation layer P is composed of a Z-score normalization module for the standard deviation of branches and a single-layer fully connected layer; specifically, obtaining the dynamic adjustment coefficient α is as follows: the feature vector standard deviation σ of the anomaly-free feature V P is subjected to Z-score normalization, and then input into the single-layer fully connected layer to obtain the dynamic adjustment coefficient α. p ​ 6. The self-supervised anomaly detection method for steel sections based on dynamic negative sample mining according to claim 4, wherein The said according to the non-abnormal feature V P , synthesize the abnormal feature V S and the Gaussian abnormal feature V G to obtain the input V' of the discrimination layer D o ; specifically: The non-abnormal feature V P , the synthetic abnormal feature V S and the Gaussian abnormal feature V G are concatenated on the vector dimension 1 to obtain the comprehensive feature V', and the expected value of the comprehensive feature V' is calculated on the vector dimension 3 to obtain the mean μ'; the input V' of the discriminant layer D o satisfies: Among them, V G ||1V S ||1V P represents the vector V G , the vector V S and the vector V P are concatenated along the vector dimension 1; represents the concatenation of the vector μ' and the vector along the vector dimension 3; represents taking the expectation of the vector V' along dimension 3; represents taking the expectation of the vector (V' - μ') 2 along dimension 3.

7. The self-supervised anomaly detection method for steel sections based on dynamic negative sample mining according to claim 4, characterized in that, The synthetic anomaly feature V output by the branch feature extraction layer M S and the anomaly-free feature V P are used to construct a clustering and separation loss based on the difference in feature distribution, so as to guide the feature space distribution of the multi-branch network model. And based on the anomaly-free feature V P dynamically generate a global negative example Gaussian sample G n ; specifically: Among them, and respectively represent the initial anomaly-free feature and the initial global negative example Gaussian sample; λ (0) is the initial learnable adjustment parameter, α (0) is the initial dynamic adjustment coefficient, is the standard deviation of the feature vector of the initial anomaly-free feature , (λασ p ) (0) is the product of λ (0) , α (0) and and represents the random noise part in; Z is a standard Gaussian distribution, satisfying λ (e) is the learnable adjustment parameter in the e-th round of training; lr λ is the learning rate corresponding to the learnable adjustment parameter; is the gradient of the discriminative layer Gaussian anomaly sample loss with respect to the feature vector ; is the global negative example Gaussian sample generated from the anomaly-free features in the e-th round of training; and are the anomaly-free features at the multi-branch feature extraction layer M in the (e + 1)-th round of training and the global negative example Gaussian samples generated according to the anomaly-free features respectively; λ (e+1) is the learnable adjustment parameter in the (e + 1)-th round of training, and α (e+1) is the dynamic adjustment coefficient output by the adaptive parameter generation layer P in the (e + 1)-th round of training; is the standard deviation of the feature vector of the anomaly-free features in the (e + 1)-th round of training ; (λασ p ) (e+1) is the product of λ (e+1) , α (e+1) and and represents the random noise part in .

8. The self-supervised anomaly detection method for steel sections based on dynamic negative sample mining according to claim 4, wherein The aggregation divergence loss adrloss is generated at the multi-branch feature extraction layer M and is used to guide the multi-branch network model to learn differential features. The aggregation divergence loss adrloss satisfies: Among them, is the gradient value of the directional noise; β is the standard deviation of dimension 3, which is updated with the network; μ g is the mean along dimension 3, N is the number of network branches, σ p and σ n are respectively the standard deviations of the eigenvectors of the non - abnormal feature V P and the synthesized abnormal feature V S ; λ and α respectively represent the learnable adjustment parameter and the dynamic adjustment coefficient.

9. The self-supervised anomaly detection method for steel sections based on dynamic negative sample mining according to claim 4, characterized in that, The specific content of the network mask loss maskloss is as follows: maskloss = Bceloss(D G , 1) + Focalloss(D S , mask) + Bceloss(D P , 0) Among them, Bceloss(D G , 1) is the binary cross-entropy loss between vector D G and vector 1; Focalloss(D S , mask) is the focal loss between vector D S and the anomaly mask mask. mask is the anomaly mask for synthesizing anomaly samples, and 1 and 0 represent the 1-filled vector and 0-filled vector of the same size as the input vector, respectively.

10. A self-supervised anomaly detection system for steel sections based on dynamic negative sample mining, characterized in that, It includes a processor, a memory, and a computer program stored on the memory. When the processor executes the computer program, it specifically executes the steps in the steel cross-section self-supervised anomaly detection method based on dynamic negative sample mining as described in any one of claims 1-9.

Citation Information

Patent Citations

  • Self-supervised anomaly detection method based on comparative learning

    CN117456272A

  • Supermarket cargo outer package anomaly detection method based on multi-branch feature extraction and foreground mining

    CN119785040A