Industrial material surface topography measurement and analysis method based on visual language prompt learning
Through the method of visual language prompt learning, combined with the dual-channel parallel adversarial network and the visual language multi-modal information fusion network, it solves the problem that the surface topography measurement method of industrial materials cannot adapt to multiple precision and understanding measurement systems, and realizes the measurement of industrial materials. Flexible and accurate measurement of surface topography.
Patent Information
- Application Number
- CN202410753569.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-09-27
AI Technical Summary
Existing industrial material surface morphology measurement methods cannot adapt to various measurement accuracy, and cannot understand the corresponding relationship between indicators and industrial material surface morphology characteristics under different measurement systems.
Using a method based on visual language cue learning, through a dual-channel parallel adversarial network and a visual language multi-modal information fusion network, multi-scale feature extraction and multi-modal feature fusion of material surface images are carried out, combined with the channel-space fusion attention mechanism and Cross-modal feature adapter enables quantitative analysis of surface morphology of industrial materials.
It achieves compatibility with multiple measurement systems, can adapt to changes in accuracy levels, and establishes the corresponding relationship between indicators and surface morphology characteristics of industrial materials under different measurement systems, reducing dependence on expensive imaging equipment and improving measurement accuracy. and flexibility.
Smart Images

Figure CN118710602A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of target recognition and defect detection algorithms in industrial machine vision, and specifically to a method for measuring and analyzing the surface morphology of industrial materials based on visual language cue learning. Background Art
[0002] Industrial material surface topography analysis refers to the qualitative and quantitative study and analysis of the characteristics, structure, morphology and geometry of the surface of a material or object, aiming to understand and describe the microscopic and macroscopic characteristics of the surface, including surface flatness, roughness, shape, texture, defects, etc. In industrial applications, the measurement and analysis of material surface topography is crucial for evaluating the quality, performance, function and usability of materials, and guiding product design, process improvement and quality control.
[0003] Surface morphology abnormality refers to the degree or size of small, irregular structural features such as depressions, protrusions, grooves and other impurities on the surface of the material. It is generally caused by the processing methods used in the processing process and other factors, such as mechanical actions such as cutting, grinding, milling or polishing, physical properties such as hardness and toughness of the material, and external environmental conditions such as high temperature and high humidity. Common surface morphology quantitative analysis is achieved by using equipment such as optical microscopes, scanning electron microscopes or surface profilers.
[0004] With the rise of deep learning technology in the field of industrial vision, existing surface morphology measurement methods use machine vision equipment to acquire images and detect and identify morphological anomalies on the material surface in the acquired images. However, these methods have certain limitations: 1) The morphology measurement capability of the material surface is fixed and cannot adapt to changes in the accuracy level; 2) Without the input of semantic information, it is impossible to understand the correspondence between indicators and surface morphological characteristics of industrial materials under different measurement systems.
[0005] Therefore, how to provide a method that can adapt to multiple measurement accuracies, understand the correspondence between indicators and surface morphology characteristics of industrial materials under different measurement systems, and realize industrial material surface morphology measurement and analysis based on visual language prompt learning is an urgent problem to be solved in this field. Summary of the invention
[0006] The present invention proposes a method for measuring and analyzing the surface morphology of industrial materials based on visual language prompt learning. This system realizes the quantitative analysis of the texture characteristics of the surface of rail wheel steel and surface morphology anomalies such as black skin and scratches, and can realize the measurement of various measurement systems according to visual language prompts.
[0007] The technical solution of the present invention is as follows:
[0008] A method for measuring and analyzing the surface morphology of industrial materials based on visual language cue learning comprises the following steps: A1 For the surface images of rail wheel steel and various materials provided by the heavy machinery manufacturing group, cropping is performed to unify the image size, the input image is adjusted to a size of 512×512, and image-text pairs with different labels are sorted out according to the measurement index requirements of industrial needs;
[0009] A2 processes labeled image-text pairs into a dataset containing positive and negative examples, and divides the dataset into training, validation, and test sets;
[0010] A3 The material surface image is input into a two-way parallel adversarial network for feature extraction;
[0011] The A4 morphological feature text template and material surface image are input into the visual language multimodal information fusion network to measure and analyze the surface morphology of industrial materials, and obtain the multimodal and multi-granular fusion feature F;
[0012] After A5 obtains the multi-modal and multi-granularity fusion feature F, it is judged by the feature discriminator to achieve the measurement and analysis of the surface morphology of industrial materials;
[0013] The step A3 comprises the following steps:
[0014] A31 input image enters the multi-scale block for multi-scale feature extraction
[0015] Assume that the input image feature is f, Conv() represents 1×1 convolution, and w i×i represents i×i convolution, Concat() represents feature map merging, and the output feature is f ′ , then the operation of the multi-scale block is as follows:
[0016] f ′ =Concat(f,Conv(f),w 3×3 Conv(f),w 5×5 Conv(f)
[0017] A32 inputs multi-scale features into the channel-space fusion attention block for attention mechanism learning
[0018] w x ,x=1,2,3,4,5 represents 3×3 convolution, f c represents the channel feature, f s Represents the spatial feature, and the calculation of the guiding feature p is shown in the formula:
[0019] f c =fw 1 , f s =fw 2,p=Sigmoid(fw 3 +Conv(f c )+Conv(f s ))
[0020] In the above formula, Represents image features, C represents the number of image channels, H represents the image height, and W represents the image width;
[0021] Use channel feature f c and spatial characteristics f s Calculate the channel attention w separately c and spatial attention w s , channel feature f c By keeping the channel unchanged, average pooling is performed on the H×W plane, and then a fully connected layer is used to obtain the channel attention w c , spatial feature f s By keeping the H×W plane unchanged, we perform maximum pooling and average pooling in the channel direction at the same time, merge the two results, and then use 1×1 convolution to get the spatial attention w s ; AvgPool() represents average pooling, FC() represents fully connected layer, MaxPool() represents maximum pooling, channel attention w c and spatial attention w s The calculation is shown in the formula:
[0022] w c =FC(AvgPool(f c ))
[0023] w s =Conv(Concat(MaxPool(f s ),AvgPool(f s )))
[0024] Finally, the new channel feature f is calculated using the guided feature p and attention c ′ and spatial characteristics f s ′ , merge these two feature maps and perform 3×3 convolution to obtain the new image feature f ′ , calculated as shown in the formula:
[0025]
[0026] f ′ =Concat(f c ′ ,f s ′ )4
[0027] In the above formula, represents the multiplication of corresponding elements,
[0028] A33 obtains the image feature f in A32 ′ , the roughness classification label l is obtained through 4 convolutional layers and 2 fully connected layers c , use the gradient descent algorithm to update the parameters, W 4 () indicates 4 layers of convolution, MLP 2 () indicates 2 fully connected layers, l c The calculation is shown in the formula:
[0029] l c =MLP 2 (W 4 (f ′ ))
[0030] A34 obtains the image feature f in A32 ′ , through 3 convolutional layers and 3 fully connected layers, the material domain classification label l is obtained d , through the gradient reversal layer, the gradient descent algorithm is used to update the parameters, W 3 () indicates 3 layers of convolution, MLP 3 () indicates 3 fully connected layers, l d The calculation is shown in the formula:
[0031] l d =MLP 3 (W 3 (f ′ ))
[0032] A35 uses the gradient descent algorithm for adversarial training to complete model training. The image feature extraction module E can realize feature extraction and eliminate the differences between material domains, so that the surface texture features of the materials are aligned.
[0033] The step A4 comprises the following steps:
[0034] A41 inputs a set of text templates into the shape feature visual language prompt module to encode and obtain the shape feature prompt text feature T
[0035] Input a set of text templates Text consisting of pre-trained text templates and morphological feature measurement index names, first convert this set of text templates Text into unique tags, and then pass them through the linear embedding layer to obtain word embedding t ′ ; Tokenize() represents tokenization, Emb() represents the linear embedding layer, and the calculation is shown in the formula:
[0036] t′ =Emb(Tokenize(Text))
[0037] In word embedding t ′ Insert n learnable hint components into the jth component of i , i=1,…,N represents the i-th component of word embedding, Insert() represents inserting a learnable hint component, x i , i = 1, ..., n represents the i-th learnable hint component of word embedding, calculated as shown in the formula:
[0038] t ′ =[t 1 t 2 …t N-1 t N ]
[0039] t=Insert(t ′ )
[0040] t=[t 1 …t j-1 x 1 …x n t j …t N ]
[0041] Finally, the word vector t is calculated through the pre-trained CLIP text encoder Text Encoder to obtain the morphological feature prompt text feature T, Encoder() represents the CLIP text encoder Text Encoder, and the calculation is shown in the formula:
[0042] T=Encoder(t)
[0043] A42 multimodal features enter the cross-modal feature adapter for attention mechanism learning
[0044] In step A3, multiple image feature extraction modules are obtained, and multi-granularity image features I are obtained through the image feature extraction modules. s , s=1,2,…,n; Assume there are two image feature extraction modules, and get image feature I s , s=i,j,I s After convolution, the corresponding elements are added to obtain the intermediate feature F 1 , intermediate feature F 1 After convolution, we get the attention feature T s , attention feature T s After Sigmoid function activation and image feature I s The corresponding elements of j are multiplied after convolution, and then the corresponding elements of the roughness hint text feature T are added after convolution to obtain the single-scale modality fusion feature Fs , single-scale modality fusion feature F s After convolution, the corresponding elements are added to obtain the intermediate feature F 2 , intermediate feature F 2 With attention feature T s The corresponding elements are added, activated by the Sigmoid function, and then fused with the single-scale modality feature F s The corresponding elements are multiplied, and finally all the corresponding elements of the features are added to obtain the multi-modal and multi-granularity fusion feature F;
[0045] represents the convolution operation, It means the corresponding elements are added, and the calculation is as shown in the formula:
[0046]
[0047] The step A5 comprises the following steps:
[0048] The discrimination result D of the morphological feature text prompt T is obtained through 4 convolutional layers, 2 fully connected layers and Softmax function, and the parameters W are updated using the gradient descent algorithm. 4 () indicates 4 layers of convolution, MLP 2 () indicates 2 fully connected layers, and the calculation of D is shown in the formula:
[0049] D = Softmax(MLP 2 (W 4 (F)))
[0050] The network model is trained using a gradient descent algorithm, and the parameters in the modal multi-granularity fusion network module are updated according to the gradient direction to complete the model training, so that the visual language multi-modal information fusion network can measure the surface roughness of the material.
[0051] The beneficial effects of the present invention are:
[0052] It can be seen from the above technical solutions that compared with the prior art, the present invention constructs and trains a model for measuring and analyzing the surface morphology of industrial materials based on visual language cue learning. The model is improved based on the CLIP visual text multimodal network, and the model is trained using various industrial material surface images. The trained model is compatible with various image acquisition devices and can be flexibly arranged in various material production scenes to assist production operators in performing fast and accurate material surface morphology measurements. At the same time, the model solves the problem of fixed morphology measurement capabilities on the surface of materials, and can adapt to changes in the accuracy level; it introduces the input of semantic information and establishes a corresponding relationship between indicators and surface morphology characteristics of industrial materials under different measurement systems. The results of the present invention will be applied to multiple fields, and end users do not need to invest a lot of money to purchase expensive imaging equipment to complete the accurate measurement of material surface morphology characteristics, thereby reducing cost expenditure. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 It is a schematic diagram of the overall process of the industrial material surface morphology measurement and analysis method based on visual language prompt learning of the present invention;
[0054] Figure 2 It is a specific flow chart of the multi-scale block of the present invention;
[0055] Figure 3 It is a specific flow chart of the channel-spatial fusion attention block of the present invention;
[0056] Figure 4 It is a specific flow chart of the morphological feature visual language prompt module of the present invention;
[0057] Figure 5 is a specific flow chart of the cross-modal feature adapter of the present invention;
[0058] Figure 6 Partial images of the data set used in the industrial material surface morphology measurement and analysis method based on visual language prompt learning of the present invention;
[0059] Figure 7 It is the visualization of the measurement results of the industrial material surface morphology measurement and analysis method based on visual language prompt learning of the present invention;
[0060] Figure 8 This is a comparison chart of the accuracy of the industrial material surface morphology measurement and analysis method based on visual language cue learning and the other two methods;
[0061] Fig. 9 ROC curves of the industrial material surface morphology measurement and analysis method for visual language cue learning and two other methods; DETAILED DESCRIPTION
[0062] The present invention is described in detail below in conjunction with specific embodiments.
[0063] A method for measuring and analyzing the surface morphology of industrial materials based on visual language cue learning. The overall process is as follows Figure 1 As shown, the surface morphology of industrial materials is as follows Figure 6 As shown, including the following:
[0064] A1 crops the surface images of rail wheel steel and various materials provided by the heavy machinery manufacturing group and unifies the image size. The input image is adjusted to 512×512 size, and image-text pairs with different labels are sorted out according to the measurement index requirements of industrial needs;
[0065] A2 processes labeled image-text pairs into a dataset containing positive and negative examples, and divides the dataset into training, validation, and test sets;
[0066] A3 The material surface image is input into a two-way parallel adversarial network for feature extraction;
[0067] Step A3: Two-way adversarial parallel network Figure 1 As shown, the network is used to input the material image into the image feature extraction module for feature extraction, and the image feature extraction module inputs the image into the multi-scale block, such as Figure 2 As shown in , 1×1 convolution is first used to reduce the number of channel dimensions, and then convolution kernels of different sizes are used to extract multi-scale features, and residual connections are used. Finally, the multi-scale features are connected to obtain the multi-scale features f. The multi-scale features are input into the channel-space fusion attention block, as shown in Figure 3 As shown, the multi-scale feature f enters the channel-space fusion attention block and first uses a 3×3 convolution to generate the channel feature f c , spatial features f s , image features are convolved by 3×3, channel features f c and spatial characteristics f s Perform 1×1 convolution, add the obtained features, and use the Sigmoid function for activation to obtain the guide feature p. Channel feature f c Perform average pooling, pass through the fully connected layer and use the Sigmoid function for activation to obtain the channel attention weight w c , guide feature p to channel feature f c Weighted, after 1×1 convolution, use the channel attention weight w c Weighted, get the channel feature f c ′ . Spatial characteristics f sAfter the maximum pooling and average pooling of the distribution, the features are merged, and then a 1×1 convolution is performed and activated using the Sigmoid function to obtain the spatial attention weight w s , guide feature 1-p to channel feature f s Weighted, after 1×1 convolution, use the spatial attention weight w s Weighted, we get the spatial feature f s ′ . The channel feature f c ′ and spatial characteristics f s ′ Merge and perform 3×3 convolution to obtain image feature f ′ After obtaining the image features, the dual-path parallel adversarial network uses a surface texture roughness classifier for classification, and enables the feature extractor to extract roughness features through back propagation. On the other hand, the material domain classifier is used for domain classification, and the material surface texture features are aligned through the gradient reversal layer.
[0068] The specific steps of step A3 are as follows:
[0069] A31 input image enters the multi-scale block for multi-scale feature extraction
[0070] like Figure 2 As shown, Figure 2 In the example, assuming that the input image feature is f, Conv() represents a 1×1 convolution, and w i×i represents i×i convolution, Concat() represents feature map merging, and the output feature is f ′ , then the operation of the multi-scale block is as follows:
[0071] f ′ =Concat(f,Conv(f),w 3×3 Conv(f),w 5×5 Conv(f)
[0072] A32 inputs multi-scale features into the channel-space fusion attention block for attention mechanism learning
[0073] like Figure 3 As shown, Figure 3 In, w x ,x=1,2,3,4,5 represents 3×3 convolution, f c represents the channel feature, f s Represents the spatial feature, and the calculation of the guiding feature p is shown in the formula:
[0074] f c =fw 1 , f s =fw 2,p=Sigmoid(fw 3 +Conv(f c )+Conv(f s ))
[0075] In the above formula, Represents image features, C represents the number of image channels, H represents the image height, and W represents the image width.
[0076] Use channel feature f c and spatial characteristics f s Calculate the channel attention w separately c and spatial attention w s , channel feature f c By keeping the channel unchanged, average pooling is performed on the H×W plane, and then a fully connected layer is used to obtain the channel attention w c , spatial feature f s By keeping the H×W plane unchanged, we perform maximum pooling and average pooling in the channel direction at the same time, merge the two results, and then use 1×1 convolution to get the spatial attention w s AvgPool() represents average pooling, FC() represents the fully connected layer, MaxPool() represents the maximum pooling, and channel attention w c and spatial attention w s The calculation is shown in the formula:
[0077] w c =FC(AvgPool(f c ))
[0078] w s =Conv(Concat(MaxPool(f s ),AvgPool(f s )))
[0079] Finally, the new channel feature f is calculated using the guided feature p and attention c ′ and spatial characteristics f s ′ , merge these two feature maps and perform 3×3 convolution to obtain the new image feature f ′ , calculated as shown in the formula:
[0080]
[0081] f ′ =Concat(f c ′ ,f s ′ )4
[0082] In the above formula, represents the multiplication of corresponding elements,
[0083] A33 obtains the image feature f in A32 ′ , the roughness classification label l is obtained through 4 convolutional layers and 2 fully connected layers c , use the gradient descent algorithm to update the parameters, W 4 () indicates 4 layers of convolution, MLP 2 () indicates 2 fully connected layers, l c The calculation is shown in the formula:
[0084] l c =MLP 2 (W 4 (f ′ ))
[0085] A34 obtains the image feature f in A32 ′ , through 3 convolutional layers and 3 fully connected layers, the material domain classification label l is obtained d , through the gradient reversal layer, the gradient descent algorithm is used to update the parameters, W 3 () indicates 3 layers of convolution, MLP 3 () indicates 3 fully connected layers, l d The calculation is shown in the formula:
[0086] l d =MLP 3 (W 3 (f ′ ))
[0087] A35 uses the gradient descent algorithm for adversarial training to complete model training. The image feature extraction module E can realize feature extraction and eliminate the differences between material domains, so that the surface texture features of the materials are aligned.
[0088] A4 morphological feature text template and material surface image are input into the visual language multimodal information fusion network for industrial material surface morphology measurement and analysis
[0089] The specific steps of step A4 are as follows:
[0090] Step A4: Visual language multimodal information fusion network Figure 1 As shown in Figure 2, the network is used to input the multi-granularity image into the feature extractor to obtain the image features, and the material surface morphology feature description is input into the morphology feature visual language prompt module, as shown in Figure 2. Figure 4As shown in , a set of defined morphological feature text templates are input, tokenized, passed through a linear embedding layer, and then the learnable prompts are inserted into the learnable word vectors. The obtained text word vectors are input into the frozen pre-trained CLIP text encoder to obtain the morphological feature prompt text features; after obtaining the multimodal features of industrial materials, they are input into the cross-modal feature adapter, as shown in Figure 5 As shown in Figure 2, after the multimodal features are obtained, the image features of each scale are convolved to achieve downsampling to unify the spatial dimensions of the image features, and the corresponding elements of the image features are added to obtain the intermediate features F. 1 , the intermediate feature F 1 After convolution, we get the attention feature T s , use the Sigmoid function to activate and multiply the corresponding elements of the convolved image features, and then add them to the corresponding elements of the morphological features and the text features to obtain the single-scale modality fusion feature F s , each fusion feature F s After convolution, the corresponding elements are added to obtain the intermediate feature F 2 , the intermediate feature F 2 After convolution, with T s The corresponding elements are added, and then activated by the Sigmoid function to fuse the features F of each single-scale modality s The corresponding elements are multiplied, and finally all the corresponding elements of the results are added to obtain the multi-modal and multi-granularity fusion feature F.
[0091] The specific steps of step A4 are as follows:
[0092] A41 inputs a set of text templates into the shape feature visual language prompt module to encode and obtain the shape feature prompt text feature T
[0093] like Figure 4 As shown, in Figure 4 In , a set of text templates Text consisting of pre-trained text templates and morphological feature measurement index names is input, for example, a set of visual language prompts "a material surface image with a morphological feature of [feature]". First, this set of text templates Text is converted into unique tags, and then the word embedding t is obtained through the linear embedding layer. ′ Tokenize() represents tokenization, Emb() represents the linear embedding layer, and the calculation is shown in the formula:
[0094] t ′ =Emb(Tokenize(Text))
[0095] In word embedding t ′ Insert the learnable hint component at the fixed position of t to obtain the word vector t. For example, in the word embedding t ′ Insert n learnable hint components into the jth component ofi , i=1,…,N represents the i-th component of word embedding, Insert() represents inserting a learnable hint component, x i , i = 1, ..., n represents the i-th learnable hint component of word embedding, calculated as shown in the formula:
[0096] t ′ =[t 1 t 2 …t N-1 t N ]
[0097] t=Insert(t ′ )
[0098] t=[t 1 …t j-1 x 1 …x n t j …t N ]
[0099] Finally, the word vector t is calculated through the pre-trained CLIP text encoder Text Encoder to obtain the morphological feature prompt text feature T, Encoder() represents the CLIP text encoder Text Encoder, and the calculation is shown in the formula:
[0100] T=Encoder(t)
[0101] A42 multimodal features enter the cross-modal feature adapter for attention mechanism learning
[0102] like Figure 5 As shown, Figure 5 In step A3, multiple image feature extraction modules are obtained, and multi-granularity image features I are obtained through the image feature extraction modules. s , s=1,2,…,n; In order to simplify the description process, it is assumed that there are two image feature extraction modules to obtain the image feature I s , s=i,j,I s After convolution, the corresponding elements are added to obtain the intermediate feature F 1 , intermediate feature F 1 After convolution, we get the attention feature T s , attention feature T s After Sigmoid function activation and image feature I s The corresponding elements of j are multiplied after convolution, and then the corresponding elements of the roughness hint text feature T are added after convolution to obtain the single-scale modality fusion feature F s , single-scale modality fusion feature F s After convolution, the corresponding elements are added to obtain the intermediate feature F2 , intermediate feature F 2 With attention feature T s The corresponding elements are added, activated by the Sigmoid function, and then fused with the single-scale modality feature F s The corresponding elements are multiplied, and finally the corresponding elements of all features are added to obtain the multi-modal and multi-granularity fusion feature F. x=1,2,3,4,5 represents the convolution operation, It means the corresponding elements are added, and the calculation is as shown in the formula:
[0103]
[0104] After A5 obtains the multi-modal and multi-granularity fusion feature F, it is judged by the feature discriminator to achieve the measurement and analysis of the surface morphology of industrial materials.
[0105] The specific steps of step A5 are as follows:
[0106] In step A4, the cross-modal feature adapter obtains the multi-modal and multi-granular fusion feature F, and obtains the discrimination result D of the morphological feature text prompt T through 4 convolutional layers, 2 fully connected layers and Softmax function. The gradient descent algorithm is used to update the parameters, W 4 () indicates 4 layers of convolution, MLP 2 () indicates 2 fully connected layers, and the calculation of D is shown in the formula:
[0107] D = Softmax(MLP 2 (W 4 (F)))
[0108] The network model is trained using a gradient descent algorithm, and the parameters in the modal multi-granularity fusion network module are updated according to the gradient direction to complete the model training, so that the visual language multi-modal information fusion network can measure the surface roughness of the material.
[0109] A method for measuring and analyzing the surface morphology of industrial materials based on visual language cue learning, including a dual-path parallel adversarial network and a visual language multimodal information fusion network:
[0110] Two-way parallel adversarial network: The two-way parallel adversarial network includes an image feature extraction module, a surface texture roughness classifier and a material domain classifier, which is used to input the material image into the image feature extraction module for feature extraction. After the two-way parallel adversarial network obtains the image features, on the one hand, the surface texture roughness classifier is used for classification, and the feature extractor can extract the roughness features through back propagation. On the other hand, the material domain classifier is used for domain classification, and the material surface texture features are aligned through the gradient reversal layer;
[0111] The two-way parallel adversarial network includes:
[0112] Image feature extraction module: It includes four groups of operation blocks, which are composed of two multi-scale blocks and one channel-spatial fusion attention block in sequence;
[0113] Surface texture roughness classifier: The feature map after feature extraction enters the surface texture roughness classifier, and after passing through 4 convolutional layers and 2 fully connected layers, the roughness classification prediction is obtained;
[0114] Material domain classifier: The feature map after feature extraction enters the material domain classifier, and after passing through 3 convolutional layers and 3 fully connected layers, the material domain classification prediction is obtained;
[0115] The image feature extraction module includes:
[0116] Multi-scale block: The image features enter the multi-scale block, first using 1×1 convolution to reduce the channel dimension, then using convolution kernels of different sizes to extract multi-scale features, and using residual connection, and finally connecting the multi-scale features;
[0117] Channel-spatial fusion attention block: The image feature f enters the channel-spatial fusion attention block and first uses a 3×3 convolution to generate the channel feature f c , spatial features f s , image features are convolved by 3×3, channel features f c and spatial characteristics f s Perform 1×1 convolution, add the obtained features, and use the Sigmoid function for activation to obtain the guide feature p. Channel feature f c Perform average pooling, pass through the fully connected layer and use the Sigmoid function for activation to obtain the channel attention weight w c , guide feature p to channel feature f c Weighted, after 1×1 convolution, use the channel attention weight w c Weighted, get the channel feature f c ′ . Spatial characteristics f s After the maximum pooling and average pooling of the distribution, the features are merged, and then a 1×1 convolution is performed and activated using the Sigmoid function to obtain the spatial attention weight w s , guide feature 1-p to channel feature f s Weighted, after 1×1 convolution, use the spatial attention weight w s Weighted, we get the spatial feature f s ′ . The channel feature f c ′ and spatial characteristics f s ′Merge and perform 3×3 convolution to obtain image feature f ′ ;
[0118] The method for measuring and analyzing the surface morphology of industrial materials based on visual language cue learning, the dual-path parallel adversarial network, selects CNN (Convolutional Neural Networks, CNN) as the backbone network, introduces multi-scale features, residual network and attention mechanism on this basis, and sets two-path classifiers for adversarial training;
[0119] The method for measuring and analyzing the surface morphology of industrial materials based on visual language prompt learning, the image feature extraction module, the multi-scale block: Assume that the input image feature is f, Conv() represents 1×1 convolution, w i×i represents i×i convolution, Concat() represents feature map merging, and the output feature is f ′ , then the operation of the multi-scale block is as follows:
[0120] f ′ =Concat(f,Conv(f),w 3×3 Conv(f),w 5×5 Conv(f)
[0121] The method for measuring and analyzing the surface morphology of industrial materials based on visual language cue learning, the image feature extraction module, and the channel-space fusion attention block: x ,x=1,2,3,4,5 represents 3×3 convolution, f c represents the channel feature, f s Represents the spatial feature, and the calculation of the guiding feature p is shown in the formula:
[0122] f c =fw 1 , f s =fw 2 ,p=Sigmoid(fw 3 +Conv(f c )+Conv(f s ))
[0123] In the above formula, Represents image features, C represents the number of image channels, H represents the image height, and W represents the image width.
[0124] The channel-spatial fusion attention block uses the channel feature f c and spatial characteristics f s Calculate the channel attention w separately c and spatial attention ws , channel feature f c By keeping the channel unchanged, average pooling is performed on the H×W plane, and then a fully connected layer is used to obtain the channel attention w c , spatial feature f s By keeping the H×W plane unchanged, we perform maximum pooling and average pooling in the channel direction at the same time, merge the two results, and then use 1×1 convolution to get the spatial attention w s AvgPool() represents average pooling, FC() represents the fully connected layer, MaxPool() represents the maximum pooling, and channel attention w c and spatial attention w s The calculation is shown in the formula:
[0125] w c =FC(AvgPool(f c ))
[0126] w s =Conv(Concat(MaxPool(f s ),AvgPool(f s )))
[0127] Finally, the channel-spatial fusion attention block uses the guided feature p and attention to calculate the new channel feature f c ′ and spatial characteristics f s ′ , merge these two feature maps and perform 3×3 convolution to obtain the new image feature f ′ , calculated as shown in the formula:
[0128]
[0129]
[0130] f ′ =Concat(f c ′ ,f s ′ ) 4
[0131] In the above formula, represents the multiplication of corresponding elements,
[0132] The method for measuring and analyzing the surface morphology of industrial materials based on visual language prompt learning, the surface texture roughness classifier: obtains the image feature f ′ , the roughness classification label l is obtained through 4 convolutional layers and 2 fully connected layers c, use the gradient descent algorithm to update the parameters, W 4 () indicates 4 layers of convolution, MLP 2 () indicates 2 fully connected layers, l c The calculation is shown in the formula:
[0133] l c =MLP 2 (W 4 (f ′ ))
[0134] The method for measuring and analyzing the surface morphology of industrial materials based on visual language prompt learning, the material domain classifier: obtains the image feature f ′ , through 3 convolutional layers and 3 fully connected layers, the material domain classification label l is obtained d , through the gradient reversal layer, the gradient descent algorithm is used to update the parameters, W 3 () indicates 3 layers of convolution, MLP 3 () indicates 3 fully connected layers, l d The calculation is shown in the formula:
[0135] l d =MLP 3 (W 3 (f ′ ))
[0136] The adversarial training is performed using the gradient descent algorithm to complete the model training. The image feature extraction module E can realize feature extraction and eliminate the differences between material domains so that the surface texture features of the materials are aligned.
[0137] Visual language multimodal information fusion network: The visual language multimodal information fusion network includes a morphological feature visual language prompt module, a cross-modal feature adapter and a feature discriminator, which is used to input a multi-granularity image into a feature extractor, and input a material surface morphological feature description into the morphological feature visual language prompt module. After the visual language multimodal information fusion network obtains the multimodal features of industrial materials, it inputs them into the cross-modal feature adapter, and the visual language multimodal information fusion network finally uses the feature discriminator for discrimination;
[0138] The visual language multimodal information fusion network includes:
[0139] Morphological feature visual language prompt module: input a set of defined morphological feature text templates, tokenize them, pass them through a linear embedding layer, insert learnable prompts into learnable word vectors, and input the obtained text word vectors into the frozen pre-trained CLIP text encoder to obtain morphological feature prompt text features;
[0140] Cross-modal feature adapter: After the image features and morphological features prompt the text features, convolution is performed on the image features of each scale to achieve downsampling to unify the spatial dimensions of the image features, and the corresponding elements of the image features are added to obtain the intermediate feature F 1 , the intermediate feature F 1 After convolution, we get the attention feature T s , use the Sigmoid function to activate and multiply the corresponding elements of the convolved image features, and then add them to the corresponding elements of the morphological features and the text features to obtain the single-scale modality fusion feature F s , each fusion feature F s After convolution, the corresponding elements are added to obtain the intermediate feature F 2 , the intermediate feature F 2 After convolution, with T s The corresponding elements are added, and then activated by the Sigmoid function to fuse the features F of each single-scale modality s The corresponding elements are multiplied, and finally all the corresponding elements of the results are added to obtain the multi-modal and multi-granularity fusion feature F;
[0141] Feature discriminator: After the cross-modal feature adapter, the multi-modal multi-granularity fusion feature F is obtained, and the discrimination of the morphological feature text prompt is obtained using 4 convolutional layers, 2 fully connected layers and the Softmax function;
[0142] The method for measuring and analyzing the surface morphology of industrial materials based on visual language prompt learning, the morphology feature visual language prompt module: input a set of text templates Text consisting of pre-trained text templates and morphology feature measurement index names, for example, a set of visual language prompts of "a material surface image with a morphology feature of [feature]". First, this set of text templates Text is converted into unique tags, and then the word embedding t is obtained through the linear embedding layer. ′ Tokenize() represents tokenization, Emb() represents the linear embedding layer, and the calculation is shown in the formula:
[0143] t ′ =Emb(Tokenize(Text))
[0144] In word embedding t ′ Insert the learnable hint component at the fixed position of t to obtain the word vector t. For example, in the word embedding t ′ Insert n learnable hint components into the jth component of i , i=1,…,N represents the i-th component of word embedding, Insert() represents inserting a learnable hint component, x i , i = 1, ..., n represents the i-th learnable hint component of word embedding, calculated as shown in the formula:
[0145] t ′ =[t 1 t 2 …t N-1 t N ]
[0146] t=Insert(t ′ )
[0147] t=[t 1 …t j-1 x 1 …x n t j …t N ]
[0148] Finally, the word vector t is calculated through the pre-trained CLIP text encoder Text Encoder to obtain the morphological feature prompt text feature T, Encoder() represents the CLIP text encoder Text Encoder, and the calculation is shown in the formula:
[0149] T=Encoder(t)
[0150] The method for measuring and analyzing the surface morphology of industrial materials based on visual language prompt learning, the cross-modal feature adapter: the dual-path parallel adversarial network, the image feature extraction module, after multiple pre-training, obtains multiple image feature extraction modules, and obtains multi-granularity image features through the image feature extraction module. s , s=1,2,…,n; In order to simplify the description process, it is assumed that there are two image feature extraction modules to obtain the image feature I s , s=i,j,I s After convolution, the corresponding elements are added to obtain the intermediate feature F 1 , intermediate feature F 1 After convolution, we get the attention feature T s , attention feature T s After Sigmoid function activation and image feature I s The corresponding elements of j are multiplied after convolution, and then the corresponding elements of the roughness hint text feature T are added after convolution to obtain the single-scale modality fusion feature F s , single-scale modality fusion feature F s After convolution, the corresponding elements are added to obtain the intermediate feature F 2 , intermediate feature F 2 With attention feature T s The corresponding elements are added, activated by the Sigmoid function, and then fused with the single-scale modality feature F s The corresponding elements are multiplied, and finally the corresponding elements of all features are added to obtain the multi-modal and multi-granularity fusion feature F. represents the convolution operation, It means the corresponding elements are added, and the calculation is as shown in the formula:
[0151]
[0152] The method for measuring and analyzing the surface morphology of industrial materials based on visual language prompt learning, the feature discriminator: obtains the multi-modal multi-granularity fusion feature F by the cross-modal feature adapter, obtains the discrimination result D of the morphological feature text prompt T through 4 convolutional layers, 2 fully connected layers and Softmax function, and uses the gradient descent algorithm to update the parameters, W 4 () indicates 4 layers of convolution, MLP 2 () indicates 2 fully connected layers, and the calculation of D is shown in the formula:
[0153] D = Softmax(MLP 2 (W 4 (F)))
[0154] The network model is trained using a gradient descent algorithm, and the parameters in the modal multi-granularity fusion network module are updated according to the gradient direction to complete the model training, so that the visual language multi-modal information fusion network can measure the surface roughness of the material.
[0155] Figure 7 In order to visualize the measurement results of the industrial material surface morphology measurement and analysis method based on visual language prompt learning in the present invention, we display the surface morphologies of several common industrial materials and the measurement results under different indicators.
[0156] Figure 8 This is a comparison chart of the accuracy of the industrial material surface morphology measurement and analysis method based on visual language prompt learning of the present invention and the other two systems. Method 1 adopts a discriminative joint reconstruction anomaly embedding method composed of a reconstruction subnetwork and a discriminative subnetwork, and method 2 adopts a UniAD model composed of a multi-layer perceptron, a convolutional neural network and a tranformer block. It can be seen that the method proposed in the present invention can achieve the highest accuracy. As the number of indicators increases, the accuracy rate only decreases slightly, and the accuracy rate is stable.
[0157] Fig. 9 The ROC curves of the industrial material surface morphology measurement and analysis method based on visual language prompt learning and the other two systems are shown in Figure 2. Figure 8 It can be seen that the AUC value of the present invention reaches 0 968. Compared with the other two methods, the overall accuracy, generalization ability and robustness of the system are stronger.
[0158] It should be understood that those skilled in the art can make improvements or changes based on the above description, and all these improvements and changes should fall within the scope of protection of the appended claims of the present invention.
Claims
1. A method for measuring and analyzing the surface morphology of industrial materials based on visual language prompt learning, characterized in that: The following steps are involved: A1 performs cropping on the surface images of industrial materials, unifies the image size, and sorts out image-text pairs with different labels according to the measurement index requirements of industrial needs; A2 processes labeled image-text pairs into a dataset containing positive and negative examples, and divides the dataset into training, validation, and test sets; A3 The material surface image is input into a two-way parallel adversarial network for feature extraction; The A4 morphological feature text template and material surface image are input into the visual language multimodal information fusion network to measure and analyze the surface morphology of industrial materials, and obtain the multimodal and multi-granular fusion feature F; After A5 obtains the multi-modal and multi-granularity fusion feature F, it is judged by the feature discriminator to achieve the measurement and analysis of the surface morphology of industrial materials.
2. The method according to claim 1, characterized in that The step A3 comprises the following steps: A31 input image enters the multi-scale block for multi-scale feature extraction Assume that the input image feature is f, Conv() represents 1×1 convolution, and w i×i represents i×i convolution, Concat() represents feature map merging, and the output feature is f ′ , then the operation of the multi-scale block is as follows: f ′ =Concat(f,Conv(f),w 3×3 Conv(f),w 5×5 Conv(f)) A32 inputs multi-scale features into the channel-space fusion attention block for attention mechanism learning w x ,x=1,2,3,4,5 represents 3×3 convolution, f c represents the channel feature, f s Represents the spatial feature, and the calculation of the guiding feature p is shown in the formula: f c =fw1,f s =fw2,p=Sigmoid(fw3+Conv(f c )+Conv(f s )) In the above formula, Represents image features, C represents the number of image channels, H represents the image height, and W represents the image width; Use channel feature f c and spatial characteristics f s Calculate the channel attention w separately c and spatial attention w s , channel feature f c By keeping the channel unchanged, average pooling is performed on the H×W plane, and then a fully connected layer is used to obtain the channel attention w c , spatial feature f s By keeping the H×W plane unchanged, we perform maximum pooling and average pooling in the channel direction at the same time, merge the two results, and then use 1×1 convolution to get the spatial attention w s ; AvgPool() represents average pooling, FC() represents fully connected layer, MaxPool() represents maximum pooling, channel attention w c and spatial attention w s The calculation is shown in the formula: w c =FC(AvgPool(f c )) w s =Conv(Concat(MaxPool(f s ),AvgPool(f s ))) Finally, the new channel feature f is calculated using the guided feature p and attention c ′ and spatial characteristics f s ′ , merge these two feature maps and perform 3×3 convolution to obtain the new image feature f ′ , calculated as shown in the formula: f ′ =Concat(f c ′ ,f s ′ )w4 In the above formula, represents the multiplication of corresponding elements, A33 obtains the image feature f in A32 ′ , the roughness classification label l is obtained through 4 convolutional layers and 2 fully connected layers c , use the gradient descent algorithm to update the parameters, W4() represents 4 layers of convolution, MLP2() represents 2 layers of fully connected layers, l c The calculation is shown in the formula: the c =MLP2(W4(f ′ )) A34 obtains the image feature f in A32 ′ , through 3 convolutional layers and 3 fully connected layers, the material domain classification label l is obtained d , through the gradient reversal layer, the gradient descent algorithm is used to update the parameters. W3() represents 3 layers of convolution, MLP3() represents 3 layers of fully connected layers, l d The calculation is shown in the formula: <h2 style=";text-align:left;direction:ltr">l<h2 style=";text-align:left;direction:ltr"> d <h2 style=";text-align:left;direction:ltr"> =MLP3(W3(f<h2 style=";text-align:left;direction:ltr"> ′ <h2 style=";text-align:left;direction:ltr"> )) A35 uses the gradient descent algorithm for adversarial training to complete model training. The image feature extraction module E can realize feature extraction and eliminate the differences between material domains, so that the surface texture features of the materials are aligned.
3. The method according to claim 2, characterized in that The step A4 comprises the following steps: A41 inputs a set of text templates into the shape feature visual language prompt module to encode and obtain the shape feature prompt text feature T Input a set of text templates Text consisting of pre-trained text templates and morphological feature measurement index names, first convert this set of text templates Text into unique tags, and then pass them through the linear embedding layer to obtain word embedding t ′ ; Tokenize() represents tokenization, Emb() represents the linear embedding layer, and the calculation is shown in the formula: t ′ =Emb(Tokenize(Text)) In word embedding t ′ Insert n learnable hint components into the jth component of i , i=1,…,N represents the i-th component of word embedding, Insert() represents inserting a learnable hint component, x i , i = 1, ..., n represents the i-th learnable hint component of word embedding, calculated as shown in the formula: t ′ =[t1t2…t N-1 t N ] t=Insert(t ′ ) t=[t1…t j-1 x1…x n t j ...t N ] Finally, the word vector t is calculated through the pre-trained CLIP text encoder Text Encoder to obtain the morphological feature prompt text feature T, Encoder() represents the CLIP text encoder Tt Encoder, and the calculation is shown in the formula: T=Encoder(t) A42 multimodal features enter the cross-modal feature adapter for attention mechanism learning In step A3, multiple image feature extraction modules are obtained, and multi-granularity image features I are obtained through the image feature extraction modules. s , s=1,2,…,n; Assume there are two image feature extraction modules, and get image feature I s , s=i,j,I s After convolution, the corresponding elements are added to obtain the intermediate feature F1, and the intermediate feature F1 is convolved to obtain the attention feature T s , attention feature T s After Sigmoid function activation and image feature I s The corresponding elements of j are multiplied after convolution, and then the corresponding elements of the roughness hint text feature T are added after convolution to obtain the single-scale modality fusion feature F s , single-scale modality fusion feature F s After convolution, the corresponding elements are added to obtain the intermediate feature F2. The intermediate feature F2 and the attention feature T s The corresponding elements are added, activated by the Sigmoid function, and then fused with the single-scale modality feature F s The corresponding elements are multiplied, and finally all the corresponding elements of the features are added to obtain the multi-modal and multi-granularity fusion feature F; x=1,2,3,4,5 represents the convolution operation, ⊕ represents the addition of corresponding elements, and the calculation is shown in the formula:
4. The method according to claim 3, characterized in that: The step A5 comprises the following steps: The multi-modal and multi-granular fusion feature F is obtained, and then the discrimination result D of the morphological feature text prompt T is obtained through 4 convolution layers, 2 fully connected layers and Softmax function. The parameters are updated using the gradient descent algorithm. W4() represents 4 layers of convolution, MLP2() represents 2 layers of fully connected layers, and the calculation of D is shown in the formula: D = Softmax(MLP2(W4(F))) The network model is trained using a gradient descent algorithm, and the parameters in the modal multi-granularity fusion network module are updated according to the gradient direction to complete the model training, so that the visual language multi-modal information fusion network can measure the surface roughness of the material.
Citation Information
Cited By
Image anomaly detection model training method, image anomaly detection method and device
CN119540230A
Small sample anomaly detection and classification framework based on reconstruction guide cross-modal alignment
CN119762847A
Tuna quality grading intelligent detection method based on multivariate information feature fusion
CN119832543A
Industrial defect detection method based on vision-language prompt
CN119887681A
Industrial defect detection method based on vision-language cues
CN119887681B
