An alloy heat treatment defect detection and repair method based on image recognition

By combining multi-level feature extraction and material physical constraints with a comparative diffusion model, the problems of image noise pollution and feature distortion during the heat treatment of high-temperature alloys are solved, and the accurate detection and repair of defects in high-temperature alloys are achieved.

CN121147178BActive Publication Date: 2026-05-15CHENYANG JIAJIA TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHENYANG JIAJIA TECHNOLOGY CO LTD
Filing Date
2025-09-17
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

During the heat treatment of high-temperature alloys, the acquired alloy surface images suffer from severe noise pollution and feature distortion due to factors such as high-temperature environment, metal surface reflection, and thermal radiation interference. Traditional image processing methods are unable to accurately identify defects such as cracks, pores, and inclusions.

Method used

A multi-level feature extraction network is used to extract features layer by layer. Defect features and noise interference are separated by material physical constraints. An enhanced feature representation is generated by a comparative diffusion model. Finally, defect detection is performed through a feature pyramid network.

Benefits of technology

It effectively separates noise interference from real defect features under high temperature conditions, improves the accuracy and reliability of defect detection, and overcomes the problem of noise and defect feature confusion in traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121147178B_ABST
    Figure CN121147178B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of image enhancement and feature learning, and discloses an alloy heat treatment defect detection and repair method based on image recognition, which comprises the following steps: acquiring original image data of a high-temperature alloy heat treatment process and extracting multi-level feature representation; performing feature purification processing based on the extracted multi-level features, so as to generate purified defect features; inputting the purified defect features into a contrast diffusion model to generate enhanced feature representation; applying a feature-image bidirectional mapping network to establish a mapping relationship between the enhanced features and reconstructed images; adjusting the step length and noise level of the diffusion process based on a material knowledge base; selecting adaptive feature enhancement parameters for different defect types; performing defect detection based on the enhanced feature representation and outputting a detection result; and effectively separating noise interference from real defect features in a high-temperature environment, so that the problem of noise and defect feature confusion in traditional methods is overcome.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image enhancement and feature learning technology, and more specifically, to a method for detecting and repairing defects in alloy heat treatment based on image recognition. Background Technology

[0002] During the heat treatment of high-temperature alloys, the acquired alloy surface images often suffer from severe noise pollution and feature distortion due to factors such as high-temperature environment, metal surface reflection, and thermal radiation interference. These interfering factors cause defect features to be masked or distorted, making it difficult for traditional image processing methods to accurately identify heat treatment defects such as cracks, pores, and inclusions.

[0003] Existing image enhancement and feature learning methods typically employ a separate processing approach, where image enhancement is performed first, followed by feature extraction and defect detection. This separate approach presents the following technical problems: First, the image enhancement process lacks targeted optimization for subsequent feature extraction tasks, potentially sacrificing useful details for defect detection while denoising. Second, the enhancement process does not consider the constraints of material physical properties, potentially generating false features that do not conform to the principles of materials science. Finally, there is a lack of synergistic optimization methods between image reconstruction quality and feature representation capability, leading to a mismatch between reconstruction results and detection performance. Summary of the Invention

[0004] This invention provides a method for detecting and repairing defects in alloy heat treatment based on image recognition, solving the technical problem of defect detection in the heat treatment process of high-temperature alloys in related technologies.

[0005] This invention provides a method for detecting and repairing defects in alloy heat treatment based on image recognition, comprising the following steps:

[0006] The original image data of the high-temperature alloy heat treatment process is acquired, and feature representations at different abstract levels are extracted layer by layer through a multi-level feature extraction network. The multi-level feature extraction network contains multiple feature extraction layers, each of which corresponds to a different receptive field size. Low-level detailed features are preserved through a residual connection structure.

[0007] The multi-level feature representation is input into the feature purification module, and defect features are separated from noise interference by introducing material physical constraints. The physical constraints include the continuity constraints of the metallic material, the geometric constraints of the defect morphology, and the temperature field distribution constraints of the heat treatment process.

[0008] The purified defect features are input into the contrastive diffusion model. Noise is added to the features through the forward diffusion process, and then the features are reconstructed through the reverse denoising process. In this process, the contrastive learning objective is incorporated to generate an enhanced feature representation.

[0009] The enhanced feature representation is input into the defect detection network for defect detection. The defect detection network adopts a feature pyramid network structure and outputs the defect category probability distribution and defect bounding box coordinates for each pixel location.

[0010] Furthermore, the multi-level feature extraction network includes:

[0011] The input layer is used to receive RGB images and perform data preprocessing, including pixel value normalization.

[0012] Convolutional coding layers contain multiple convolutional blocks, each containing two convolutional layers, processed by batch normalization and activation functions;

[0013] The residual connection layer adds the output of each convolutional block to the input through skip connections, and performs dimension matching when the feature map spatial size and the number of channels are inconsistent.

[0014] The multi-scale feature output layer extracts feature maps from different levels and generates the final multi-level feature representation through feature fusion operations.

[0015] Furthermore, the feature purification module includes:

[0016] The feature decomposition layer decomposes the input multi-level features into defect features and noise features;

[0017] The physical constraint layer applies physical constraints to the decomposed features. Continuity constraints are achieved by calculating the L1 norm of the feature gradient, geometric constraints are achieved by comparing the radius of curvature at the calculated location with a geometric threshold, and temperature field constraints are calculated based on the temperature gradient distribution characteristics during the heat treatment process.

[0018] The feature reconstruction layer reconstructs and cleans features through a fully connected layer.

[0019] Furthermore, the feature purification process achieves feature separation through iterative optimization, including:

[0020] Initialize defect and noise characteristics;

[0021] In each iteration, the features are updated by gradient descent, minimizing the joint loss function of the degree of physical constraint violation and feature reconstruction error;

[0022] The updated features are projected onto the physical constraint space, and the constraint projection problem is solved using the Lagrange multiplier method.

[0023] The iteration stops when the change in the feature is less than a preset threshold.

[0024] Furthermore, the comparative diffusion model includes:

[0025] The diffusion encoder forward diffuses the input features and adds Gaussian noise at each time step. The noise scheduling parameters adopt a linear scheduling strategy.

[0026] The denoising network adopts the U-Net architecture, which includes encoder and decoder paths and incorporates temporal embedding and conditional information through residual block processing.

[0027] The contrastive learning head extracts features at different diffusion steps for contrastive learning, and maps the intermediate layer features to the contrastive learning feature representation through a multilayer perceptron.

[0028] Furthermore, the contrastive diffusion process incorporates contrastive learning into the reverse denoising stage, including:

[0029] Construct comparative sample pairs: for each defect feature, select positive samples from defects of the same type and a set of negative samples from defects of different types;

[0030] Perform the forward diffusion process simultaneously on all samples to obtain the diffusion state at the same time step;

[0031] Feature representations are extracted from the intermediate layer of the denoising network, the contrastive loss is calculated, and the similarity between features is measured by cosine similarity.

[0032] The contrast loss is calculated at different time steps, and the final multi-scale contrast loss is obtained by weighted summation.

[0033] Furthermore, the defect detection network includes:

[0034] The feature pyramid network constructs multi-scale feature representations, including bottom-up and top-down paths, and fuses features of different scales through lateral connections.

[0035] The detection head network applies a shared detection head to each pyramid level, including classification and regression branches;

[0036] The output layer maps the output of the detection head to the final prediction, outputting the class probability and bounding box coordinates.

[0037] The bounding box decoding layer decodes the bounding box regression values ​​output by the network into actual coordinates.

[0038] Furthermore, it also includes:

[0039] A feature-image bidirectional mapping network is applied to establish the mapping relationship between enhanced features and reconstructed images, including feature-to-image branch and image-to-feature branch, and the mapping relationship is optimized by minimizing the bidirectional reconstruction error;

[0040] Based on the materials knowledge base, physical property parameters are queried according to the alloy material type, and the step size and noise level of the diffusion model are dynamically adjusted.

[0041] For different defect types, the parameter configuration of feature enhancement is adaptively adjusted based on the defect type distribution in the preliminary detection results.

[0042] Furthermore, the feature-image bidirectional mapping network ensures the reversible transformation between features and images through cycle consistency constraints, including:

[0043] Feature coding normalization normalizes enhanced features to a specified range;

[0044] Progressive image generation generates images of different resolutions through multi-stage upsampling;

[0045] Feature reconstruction verification involves reconstructing features from the generated image using an encoder and calculating the reconstruction error.

[0046] Semantic consistency is maintained by ensuring that the semantic information of defects is preserved during the mapping process through semantic loss.

[0047] This invention provides an image recognition-based alloy heat treatment defect detection and repair system, used to execute the aforementioned image recognition-based alloy heat treatment defect detection and repair method, comprising:

[0048] The image acquisition module is used to acquire raw image data of the high-temperature alloy heat treatment process;

[0049] The multi-level feature extraction module is used to extract feature representations at different levels of abstraction through a multi-level feature extraction network.

[0050] The feature purification module is used to separate defect features from noise interference through physical constraints.

[0051] The contrastive diffusion processing module is used to generate enhanced feature representations through the contrastive diffusion model;

[0052] The defect detection module is used to perform defect detection based on enhanced features and output the detection results.

[0053] The beneficial effects of this invention are that it effectively separates noise interference from real defect features under high temperature conditions, overcoming the problem of confusion between noise and defect features in traditional methods. Attached Figure Description

[0054] Figure 1 This is a flowchart of the image recognition-based alloy heat treatment defect detection and repair method of the present invention. Detailed Implementation

[0055] The subject matter described herein will now be discussed with reference to exemplary embodiments. It should be understood that these embodiments are discussed only to enable those skilled in the art to better understand and implement the subject matter described herein, and changes may be made to the function and arrangement of the elements discussed without departing from the scope of this specification. Various processes or components may be omitted, substituted, or added as needed in the examples. Furthermore, some features described in the examples may be combined in other examples.

[0056] This invention provides a method for detecting and repairing defects in alloy heat treatment based on image recognition, comprising the following steps:

[0057] Step 1: Obtain the raw image data of the high-temperature alloy heat treatment process and extract multi-level feature representations;

[0058] The acquired raw images of the high-temperature alloy surface are input into a multi-level feature extraction network, which extracts feature representations at different levels of abstraction layer by layer. The multi-level feature extraction network contains multiple feature extraction layers, each corresponding to a different receptive field size, thereby capturing multi-scale features from local texture to global structure.

[0059] It should be noted that the multi-level feature extraction network adopts a residual connection structure. The output of each feature extraction layer is not only passed to the next layer, but also retained in the final feature fusion stage through skip connections, ensuring that low-level detailed features are not lost in the deep network.

[0060] The aforementioned multi-level feature extraction network comprises the following components:

[0061] Input layer: Receiver size is RGB image, where and These represent the height and width of the input image, respectively. The input image needs to undergo data preprocessing, including pixel value normalization. scope:

[0062]

[0063] in These are the original image pixel values;

[0064] Convolutional coding layer: contains The nth convolutional block, the nth A convolutional block contains two convolutional layers, and its calculation process is as follows:

[0065]

[0066] in, and For the first Convolution weights of the layer, This represents the convolution operation. Indicates batch normalization, Indicates the activation function;

[0067] Furthermore, the specific parameter configurations for each convolutional layer are as follows:

[0068] First convolutional layer use The convolution kernel has a stride of 1, padding of 1, and an output channel count of 1. ;

[0069] Second convolutional layer Similarly, The convolution kernel has a stride of 2 (for downsampling), padding of 1, and the number of output channels is the same as the first layer.

[0070] Normalization The parameters include momentum coefficient 0.9 and value .

[0071] This configuration ensures that the feature maps can effectively extract multi-scale information at each layer and reduce spatial dimensions.

[0072] Residual connections: The output of each convolutional block is added to the input via skip connections. ;

[0073] Furthermore, since the spatial dimensions and number of channels of the feature maps in each layer are different, the residual connections need to undergo dimension matching processing:

[0074] when and When the spatial dimensions are inconsistent, Apply average pooling operation Make its space size and Matching; when the number of channels is inconsistent, for application convolution Perform channel number transformation.

[0075] The specific steps are as follows:

[0076]

[0077] The kernel size and step size of the average pooling are dynamically determined based on the size difference:

[0078]

[0079]

[0080] Multi-scale feature output layer: extracting feature maps from different levels This constitutes a multi-level feature representation. The output layer generates the final multi-level features through feature fusion operations:

[0081]

[0082] in, Adjust feature maps of different scales to the target size. , This indicates a splicing operation along the channel dimension.

[0083] Furthermore, The operation uses bilinear interpolation to achieve size transformation for the input feature map:

[0084]

[0085] Output feature map Middle position The value is obtained by weighted calculation of the four nearest neighbor pixels:

[0086]

[0087] in , These are floating-point coordinates mapped to the input feature map. The weights are bilinear, and the calculation formula is as follows:

[0088]

[0089] in , For the decimal part, Let Kronecker function be used.

[0090] Furthermore, target size The feature map size is set to the maximum downsampling factor of the input image.

[0091]

[0092]

[0093] in This represents the total number of convolutional coding layers. This is a rounding up operation.

[0094] This size selection ensures that features at different levels have the same spatial resolution during fusion, while maintaining sufficient spatial detail for subsequent defect localization tasks.

[0095] The aforementioned multi-level feature extraction network was trained using supervised learning, employing an image dataset with defect annotations. The optimization strategy used the Adam optimizer, with an initial learning rate of [value missing]. And a cosine annealing scheduling strategy is adopted. The training loss function is:

[0096]

[0097] in, For the first Predictive features of the layer These are reference features obtained through a pre-trained model. For the first Layer weight coefficients.

[0098] Furthermore, to reflect the temporal evolution characteristics during training, a time dimension constraint term is added to the loss function:

[0099]

[0100] in To train time steps, For the first Step training Predictive features of the layer This is the time consistency weighting coefficient.

[0101] This time constraint ensures the continuity of features extracted in adjacent training steps, avoiding feature jumps and instability during training. Time step:

[0102]

[0103] in The total number of training rounds. This represents the number of batches in each round.

[0104] Furthermore, reference features The features are obtained by using the corresponding layer features of a ResNet-50 model pre-trained on the ImageNet dataset. The specific steps are as follows:

[0105] Input image Input into the pre-trained ResNet-50 model;

[0106] Extract the first The output of the convolutional block is used as a reference feature. ;

[0107] The final reference feature is obtained through feature alignment transformation: ;

[0108] in For specially trained Aligned convolutional layers are used to adjust the number of channels and distribution of pre-trained features to match the current network.

[0109] This design leverages general visual feature representations learned by pre-trained models on large-scale data to provide effective supervision signals for the feature extraction network.

[0110] Furthermore, the total number of convolutional coding layers A value of 5 corresponds to five different levels of feature extraction, capturing multi-scale information from pixel-level texture (layer 1) to semantic-level defect patterns (layer 5). The weight coefficients for each layer are... Use a decreasing setting, specifically: , , , , This reflects the decreasing importance of features from lower to higher levels.

[0111] Step 2: Based on the extracted multi-level features, perform physical constraint feature purification processing to generate purified defect features;

[0112] The multi-level features obtained in step 1 are input into the feature purification module, which separates defect features from noise interference by introducing material physical constraints. The physical constraints include: continuity constraints of the metallic material, geometric constraints of the defect morphology, and temperature field distribution constraints of the heat treatment process.

[0113] In this embodiment, to more accurately separate defect features, the feature purification process employs an iterative optimization approach, achieved by minimizing the joint loss function of the degree of physical constraint violation and feature reconstruction error.

[0114]

[0115] in, Indicates feature reconstruction error. Indicates the degree of violation of physical constraints. This is the balance coefficient.

[0116] The aforementioned feature purification module comprises the following components:

[0117] Feature decomposition layer: decomposes the input multi-level features Decomposed into defect features and noise characteristics :

[0118]

[0119] Furthermore, multi-level features The dimension parameter is defined as: , These are the height and width of the target feature map determined in step 1 above. The number of feature channels after fusion is calculated as follows:

[0120]

[0121] in For the first The number of channels in the layer feature.

[0122] This dimension setting ensures the mathematical consistency of the feature decomposition process.

[0123] Furthermore, the number of feature channels in each layer Based on the increasing network depth setting, specifically:

[0124]

[0125] The number of channels corresponding to layers 1 through 5 are 64, 128, 256, 512, and 1024 respectively. Therefore, the total number of channels after fusion is:

[0126]

[0127] This channel configuration follows the design principle of deep networks: "shallow features are rich in detail, deep features are rich in semantics," ensuring that multi-level feature fusion can simultaneously preserve both detailed and semantic information. express Convolutional layer This indicates a segmentation operation along the channel dimension, specifically:

[0128]

[0129] Tensor to be input It is evenly divided into two parts along the channel dimension;

[0130] Physical constraint layer: applies physical constraints to the decomposed features, including:

[0131] Continuity constraints:

[0132]

[0133] Geometric constraints:

[0134]

[0135] in, Indicates position The radius of curvature at a given point is calculated using the eigenvalues ​​of the Hessian matrix:

[0136]

[0137] in , These are the two eigenvalues ​​of the Hessian matrix at this position. The Hessian matrix at this position is:

[0138]

[0139] The pixel spacing is used to maintain dimensional consistency (pixel units). This is the geometric threshold.

[0140] Furthermore, geometric threshold Based on the physical properties of alloy heat treatment defects, its value range is set as follows: The unit is pixels; the specific value is determined based on the defect type.

[0141] For crack-type defects, due to their sharp edge characteristics, a setting is required. ;

[0142] For porosity defects, due to their nearly circular smooth boundaries, a... ;

[0143] For inclusion defects, since their shape is between the former two, a setting is made... .

[0144] This threshold setting ensures that geometric constraints can effectively distinguish different types of defect morphological features.

[0145] Feature Reconstruction Layer: Reconstructing and purifying features through a fully connected layer.

[0146]

[0147] in, , This is the weight matrix. , This is the bias vector.

[0148] The aforementioned feature refinement module employs an end-to-end training model, using a multi-task learning strategy to simultaneously optimize feature reconstruction and physical constraint satisfaction. The optimization strategy utilizes the SGD optimizer with a learning rate of [missing information - likely a specific value]. The momentum parameter is 0.9. The physical constraint loss function during training is specifically defined as follows:

[0149]

[0150] in, For temperature field constraints, , , These are the weighting coefficients for each constraint term.

[0151] Furthermore, to reflect the time evolution characteristics of the heat treatment process, a time dimension constraint is added to the physical constraint loss function:

[0152]

[0153] in For time evolution constraints, This represents the weight of the second-order time derivative. The time derivative is calculated using finite differences:

[0154]

[0155] in This is the time step. This constraint ensures that the temporal changes of defect characteristics conform to physical laws, avoiding non-physical abrupt changes. The weighting coefficients are set to... .

[0156] Furthermore, temperature field constraint The calculation based on the temperature gradient distribution characteristics during the heat treatment process involves the following specific steps:

[0157] Defect characteristics Using a two-dimensional Gaussian filter Smoothing is performed to simulate the thermal diffusion effect:

[0158]

[0159] The standard deviation of the filter pixel unit;

[0160] Calculate the temperature gradient field:

[0161]

[0162] The gradient is calculated using the Sobel operator:

[0163]

[0164] Calculate the constraint terms based on the physical laws of heat conduction:

[0165]

[0166] in This is the maximum allowable temperature gradient threshold determined based on the thermal conductivity of the alloy material. This constraint ensures that the characteristic distribution conforms to the physical temperature field characteristics during heat treatment. The weighting coefficients are set to... , , .

[0167] The aforementioned feature purification process achieves feature separation through iterative optimization, specifically including the following steps:

[0168] Initialization: Set the number of iterations Initialize defect features and noise characteristics ;

[0169] Iterative separation: in the first In the next iteration, the features are updated using gradient descent:

[0170]

[0171]

[0172] in, This is the step size parameter;

[0173] Furthermore, the number of iterations Empirical analysis has shown that this number of iterations achieves the optimal balance between computational efficiency and convergence accuracy. Step size parameter. Adaptive setting is adopted, with the initial value being... And adjust based on the rate of change of the loss function after each iteration:

[0174] when When, set To improve convergence stability;

[0175] When this ratio is greater than 0.1, set To accelerate convergence, but not exceeding the upper limit of 0.1.

[0176] Constraint projection: Projecting the updated features onto the physical constraint space.

[0177]

[0178] in, , , This is the constraint threshold;

[0179] Furthermore, the complete constrained projection problem is solved using the Lagrange multiplier method, and the Lagrange function is constructed as follows:

[0180]

[0181] in It is a Lagrange multiplier.

[0182] The optimization process employs the Alternating Direction Multiplier Method (ADMM):

[0183] With the Lagrange multiplier fixed, update features using gradient descent. ;

[0184] Update the Lagrange multiplier based on KKT conditions:

[0185]

[0186] in The step size parameter is set to... .

[0187] Convergence criterion: When Stop iterating if the iteration stops, otherwise return to step (2).

[0188] Furthermore, constraint threshold , and The threshold for continuity constraint is determined based on the statistical characteristics of the training data.

[0189]

[0190] Geometric constraint threshold:

[0191]

[0192] Temperature field constraint threshold:

[0193]

[0194] in These are genuine defect characteristics. These are the actual geometric constraint values. These are the actual temperature field constraint values. The standard deviation function. Convergence threshold. Set as This value is determined through cross-validation to ensure that the algorithm achieves sufficient accuracy while avoiding excessive iteration.

[0195] Step 3: Input the purified defect features into the contrast diffusion model to generate enhanced feature representations;

[0196] The purified features obtained in step 2 are used as input conditions into the contrastive diffusion model. The contrastive diffusion model gradually adds noise to the features through a forward diffusion process, and then reconstructs the features through a reverse denoising process, incorporating the contrastive learning objective in the process.

[0197] It should be noted that the training objective function for the comparative diffusion model is:

[0198]

[0199] in, Indicates the first The diffusion state of the step, This indicates the added noise. This represents a denoising network. Indicates conditional information, Indicates comparative loss, These are the weighting coefficients.

[0200] Furthermore, time dimension parameters The complete definition includes:

[0201] Range of values ,in This represents the total number of diffusion steps.

[0202] Sampling distribution It is a uniform distribution;

[0203] Time Embedding Dimension .

[0204] Expected value Indicates time step Initial state and noise Joint distribution integral:

[0205]

[0206] in For the input feature distribution, It follows a standard Gaussian distribution.

[0207] Weighting coefficient Time-dependent settings are adopted:

[0208]

[0209] in This ensures that the early diffusion steps focus more on contrastive learning, while the later steps focus more on noise reduction and reconstruction.

[0210] In this embodiment of the application, in order to enhance the discriminative power of different defect types, the contrast loss is calculated using a multi-scale method at different diffusion time steps. Calculate the contrastive loss at different levels of abstraction:

[0211]

[0212] in, Indicates the scale quantity. Indicates the first Weights for each scale Indicates the first Contrast loss at each scale.

[0213] Furthermore, the complete parameter definition of the multi-scale contrastive loss function is as follows:

[0214] Scale quantity Corresponding time step interval , , ;

[0215] Weighting coefficient , , This highlights the importance of comparative learning in the early diffusion stage;

[0216] The contrast loss at each scale is calculated as follows:

[0217]

[0218] in For batch size, For the first The sample at the th Feature representation at each scale For positive sample features, For temperature parameters, This is the cosine similarity function.

[0219] The aforementioned comparative diffusion model comprises the following components:

[0220] Diffusion encoder: for input features Forward diffusion occurs at time step Add Gaussian noise:

[0221]

[0222] in, , , For predefined noise scheduling parameters, ;

[0223] Furthermore, noise scheduling parameters A linear scheduling strategy is adopted, at time step From the inside linear growth to The specific calculation is as follows:

[0224]

[0225] in This represents the total number of diffusion steps.

[0226] This scheduling ensures minimal noise in the early stages to preserve feature details, while increasing noise in the later stages to achieve sufficient feature perturbation. Gaussian noise Sampling is performed independently at each time step, with a mean of 0 and a covariance matrix that is the identity matrix. .

[0227] Denoising Network It adopts the U-Net architecture, including encoder and decoder paths:

[0228] Encoder path:

[0229]

[0230] Decoder path:

[0231]

[0232] in, For time embedding, For conditional information, Represents a residual block;

[0233] Furthermore, time embedding Calculated using a positional encoding method, specifically:

[0234]

[0235] in , For the embedded dimension.

[0236] The embedding vector is then added to the feature map after undergoing two layers of MLP transformation:

[0237]

[0238] residual block The specific structure is as follows:

[0239] First-level normalization (Number of groups is 32), second layer Convolution, third layer nonlinear activation Fourth layer time embedding injection, fifth layer The convolution is performed, and finally a residual connection is made with the input.

[0240] Condition Information Defect characteristics after purification ,pass The convolution is projected onto the same number of channels as the noise features, and then the features are concatenated.

[0241] Contrastive learning head: Extracting features at different diffusion steps and performing comparative learning.

[0242]

[0243] in, Features of the intermediate layer of U-Net It is a multilayer perceptron.

[0244] The aforementioned contrastive diffusion model employs a denoised score-matching training mode, learning the data distribution by predicting added noise. The optimization strategy uses the AdamW optimizer with a learning rate of [missing information]. The weight decay coefficient is 0.01. The contrastive loss function used during training is:

[0245]

[0246] in, For positive sample features, For batch size, This refers to the temperature parameter.

[0247] During training, a feature decoder is also used to map the hidden states back to the original feature space, ensuring the interpretability of the generated features.

[0248] The aforementioned contrastive diffusion process incorporates contrastive learning into the reverse denoising stage. The specific implementation steps are as follows:

[0249] Constructing comparative sample pairs: for each defect feature Select positive samples from similar defects Selecting a negative sample set from different types of defects ;

[0250] Synchronous diffusion: Performing the forward diffusion process simultaneously on all samples to obtain the same time step. diffusion state ;

[0251] Feature Extraction and Comparison: Extracting Feature Representations from the Intermediate Layers of the Denoising Network Calculate the contrast loss:

[0252]

[0253] in, Indicates cosine similarity;

[0254] Multi-scale aggregation: at different time steps Calculate the contrast loss and obtain the final multi-scale contrast loss by weighted summation.

[0255] Step 4: Based on the enhanced feature representation, perform defect detection and output the detection results;

[0256] The enhanced features obtained in step 3 are input into the defect detection network, which outputs the defect category probability distribution and defect bounding box coordinates for each pixel location. The defect detection network employs a feature pyramid network, enabling it to detect defects of different sizes simultaneously.

[0257] It should be noted that the output of the defect detection network includes: a defect category vector.

[0258]

[0259] in , These represent the height and width of the feature map, respectively. Indicates the number of defect categories;

[0260] Bounding box regression vector:

[0261]

[0262] Predict 4 coordinate values ​​for each location.

[0263] The aforementioned defect detection network comprises the following components:

[0264] Feature Pyramid Network (FPN): Constructing multi-scale feature representations:

[0265] Bottom-up path:

[0266]

[0267]

[0268] Top-down path:

[0269]

[0270] in, For the first Enhanced features of the layer It is a lateral connection feature. Features of a pyramid;

[0271] Furthermore, upsampling operation The nearest neighbor interpolation algorithm is used, and the specific steps are as follows:

[0272] Copy each pixel of the input feature map to the corresponding pixel of the output feature map. The region, with the input feature map as follows:

[0273]

[0274] The output feature map is:

[0275]

[0276] Location of output feature map The value is obtained by inputting the feature map location. The value is determined:

[0277]

[0278] To ensure feature map size matching, adjustments are made to the target size using zero padding or cropping. Lateral connectivity features pass Convolution will enhance features The number of channels was adjusted to 256 to ensure consistency with the number of channels in the upsampling feature.

[0279] Detection Head Network: A shared detection head applied to each pyramid level.

[0280] Classification branches:

[0281]

[0282] Regression branch:

[0283]

[0284] in, Indicates 4 consecutive Convolutional layer;

[0285] Output layer: Maps the output of the detection head to the final prediction.

[0286] Category probability:

[0287]

[0288] Bounding box coordinates:

[0289]

[0290] Bounding box decoding layer: Regresses the bounding box values ​​output by the network. Decode into actual coordinates. For each position... Output The coordinates are decoded into the final bounding box coordinates using the following formula:

[0291]

[0292]

[0293]

[0294]

[0295] in The feature map is downsampled relative to the input image, and the final bounding box is:

[0296]

[0297] Furthermore, downsampling factor According to the pyramid hierarchy Calculation, specifically The downsampling factors corresponding to layers 3, 4, and 5 are 8, 16, and 32, respectively. This factor indicates the number of pixels in the original image corresponding to one pixel in the feature map. For example, the pixel position in the feature map of layer 3... Corresponding to the original image Centered Pixel region. Bounding box regression value. The range of values ​​is limited to Inside, among which , This indicates the position offset relative to the grid center. , This indicates a logarithmic scaling adjustment for width and height. The operation ensures that the predicted width and height are positive values.

[0298] The aforementioned defect detection network employs supervised learning training, using a dataset containing defect location and category annotations. The optimization strategy uses the SGD optimizer with an initial learning rate of 0.01, followed by a warmup strategy that linearly increases the learning rate over the first 1000 iterations. The training loss function is:

[0299]

[0300] The focal loss is:

[0301]

[0302] Used to handle class imbalance problems;

[0303] The bounding box regression loss is:

[0304]

[0305] in The balance coefficient is set to 1.0.

[0306] Furthermore, to reflect the temporal consistency and multi-scale constraints of the detection process, a complete set of constraint terms is added to the detection loss function:

[0307]

[0308] Among them, time consistency loss:

[0309]

[0310] Multi-scale constraint loss:

[0311]

[0312] in , This is a 2x downsampling operation.

[0313] The specific form of focus loss is:

[0314]

[0315] in For position category The predicted probability, For category weights, For focusing parameters.

[0316] Weighting coefficients are set to , .

[0317] In this embodiment of the application, in order to improve the detection accuracy of small-sized defects, the following steps are also included between step 3 and step 4:

[0318] Step 3.1: Apply a feature-image bidirectional mapping network to establish the mapping relationship between enhancement features and reconstructed images;

[0319] The enhanced features are input into the feature-to-image branch of the feature-image bidirectional mapping network to generate the corresponding reconstructed image; simultaneously, the reconstructed image is input into the image-to-feature branch to verify the invertibility of the features. The mapping relationship is optimized by minimizing the bidirectional reconstruction error.

[0320] The aforementioned feature-image bidirectional mapping network comprises the following components:

[0321] Feature to Image Branch :

[0322] Map the features to the image decoder layer:

[0323]

[0324] Upsampling layer:

[0325]

[0326]

[0327] Output layer:

[0328]

[0329] in, This represents transposed convolution. Indicates feature reshaping;

[0330] Image to feature branch :

[0331] Map the image to a feature encoder layer:

[0332] The feature mapping layer uses the same CNN architecture as the multi-level feature extraction network:

[0333]

[0334] in, For encoder output, Indicates global pooling. Indicates a fully connected layer;

[0335] Consistency constraint layer:

[0336] Ensure the consistency and cycle consistency of bidirectional mappings:

[0337]

[0338] Image consistency:

[0339]

[0340] The aforementioned feature-image bidirectional mapping network employs an adversarial training mode, using a generative adversarial network (GAN) framework. The optimization strategy utilizes the Adam optimizer, with a generator learning rate of [missing information]. The discriminator learning rate is .

[0341] The training loss function is:

[0342]

[0343] in, To combat the losses, and These are the weight coefficients for cycle consistency and identity mapping, respectively. The discriminator used during training is the PatchGAN architecture, which judges real and fake local regions of the image.

[0344] Furthermore, the specific structure of the PatchGAN discriminator is a 5-layer convolutional network:

[0345] Layer 1 uses Convolutional kernel, stride of 2, output 64 channels, no normalization layer, using Activation function (negative slope 0.2);

[0346] Layers 2-4 have the same structure and convolutional kernel size. The step size is 2, and the number of channels is 128, 256, and 512 respectively. Each layer contains Normalization and activation;

[0347] Layer 5 is the output layer, using The convolution kernel has a stride of 1 and outputs one channel. Activation function.

[0348] The adversarial loss function uses least squares loss:

[0349]

[0350] in For discriminator, For generator, For real images, Input noise. Weighting coefficients are set to... , .

[0351] The aforementioned bidirectional mapping process ensures the reversible transformation between features and images through cycle consistency constraints, specifically including the following steps:

[0352] Feature encoding normalization: transforming input enhanced features Standardization to Interval:

[0353]

[0354] in, and These are the minimum and maximum values ​​of the feature, respectively;

[0355] Progressive image generation: generating high-quality images through multi-stage upsampling.

[0356] Phase 1: ,generate Resolution;

[0357] Phase Two: ,generate Resolution;

[0358] Phase Three: Generate the final resolution;

[0359] in, , , For cascading generator modules;

[0360] Feature reconstruction verification: The generated image via encoder Reconstruct features and calculate reconstruction error:

[0361]

[0362] when At that time, adjust the mapping parameters and regenerate, where The preset threshold;

[0363] Furthermore, reconstruct the error threshold. The dynamic range and accuracy requirements of the input features are set, and the specific calculation is as follows:

[0364]

[0365] in The relative error tolerance is set to 0.05 (i.e., 5% relative error).

[0366] The standard deviation of the enhanced features. This threshold setting ensures that the difference between the reconstructed features and the original enhanced features is controlled within an acceptable range, while avoiding mapping convergence difficulties caused by an overly strict threshold.

[0367] Semantic consistency preservation: This ensures that the mapping process retains the semantic information of defects through additional semantic loss.

[0368]

[0369] in, The first term of the pre-trained network is represented by the second term. Layer features, These are the weighting coefficients.

[0370] Step 3.2: Based on the materials knowledge base, adjust the step size and noise level of the diffusion process;

[0371] Based on the alloy material type corresponding to the input image, the physical property parameters of the material, including coefficient of thermal expansion, thermal conductivity, and phase transition temperature, are retrieved from the materials knowledge base. The step size of the diffusion model is then dynamically adjusted based on these parameters. and noise variance .

[0372] The aforementioned material knowledge base query employs a fast retrieval method based on hash tables. The input is an alloy material type identifier (such as "Ti-6Al-4V", "Inconel 718", etc.), and the output is a vector of physical property parameters of that material.

[0373]

[0374] in The coefficient of thermal expansion is Thermal conductivity, Phase transition temperature For elastic modulus, This refers to the yield strength. Since the parameters have different physical dimensions (such as the coefficient of thermal expansion, which is measured in units of...),... The unit of thermal conductivity is The unit of phase transition temperature is (etc.), all parameters need to be preprocessed using Z-score normalization to eliminate the influence of dimensions:

[0375]

[0376] in and These represent the mean and standard deviation of each parameter in the materials knowledge base.

[0377] Based on the standardized parameters, the diffusion parameters are adjusted using the following mapping relationship:

[0378]

[0379]

[0380] in, and As the baseline parameter, , To adjust the weights, The Min-Max normalization function is defined as follows:

[0381]

[0382] in and These are the minimum and maximum values ​​of the parameter in the materials knowledge base, respectively.

[0383] Furthermore, baseline parameters and Using the default settings of the standard DDPM (Denoising Diffusion Probability Model), specifically: (The initial noise scheduling corresponding to the diffusion process). (Corresponding to the basic noise variance). Adjusting weights and The degree of influence of material physical properties is determined, among which (Weight of the influence of thermal expansion coefficient on diffusion step size). (Weight of thermal conductivity on noise level). This parameter configuration ensures that the diffusion process can be adaptively adjusted according to the physical properties of different alloy materials.

[0384] Step 3.3: Select adaptive feature enhancement parameters for different defect types;

[0385] Based on the defect type distribution in the preliminary detection results, the parameter configuration for feature enhancement is adaptively adjusted. For crack-type defects, directional features are enhanced; for porosity-type defects, roundness features are enhanced; and for inclusion-type defects, texture difference features are enhanced.

[0386] The aforementioned adaptive feature enhancement parameter selection is based on the statistical distribution of defect types, with the input being the probability distribution of defect types obtained from the initial detection:

[0387]

[0388] The output is the corresponding set of feature enhancement parameters.

[0389] The specific parameter configurations are as follows:

[0390] when At that time, set the parameters of the directional filter bank: , Enhance edge features in 8 directions;

[0391] when When setting the roundness enhancement parameters: , This corresponds to the typical radius range of pores;

[0392] when At that time, set the texture analysis window: Multi-scale texture feature extraction.

[0393] When the probabilities of multiple defect types are similar, a weighted combination parameter configuration strategy is adopted.

[0394] Furthermore, the probability threshold of 0.5 is chosen based on the optimal decision boundary in classification decision theory. When the probability of a certain type of defect exceeds 0.5, it indicates that this type of defect dominates the current image region, and feature enhancement strategies targeting this type of defect should be prioritized. This threshold setting has been verified through extensive experiments: when the threshold is below 0.3, excessive false enhancements lead to increased noise; when the threshold is above 0.7, many defect features that need enhancement are missed. The setting of 0.5 achieves the best balance between false positive and false negative rates, conforming to the minimum error rate criterion of Bayesian decision theory.

[0395] The following is an example of an application of the present invention, and the implementation process is as follows:

[0396] Multi-level feature extraction:

[0397] Table 1 Feature parameters of raw image data

[0398]

[0399] Table 2 Multi-level feature extraction results

[0400]

[0401] Multi-level features after fusion The dimension is The eigenvalues ​​have a mean of 0.05 and a standard deviation of 0.78.

[0402] Example: Physical constraint feature purification:

[0403] Table 3 Physical constraint parameter settings

[0404]

[0405] Table 4. Data on the iterative process of feature purification

[0406]

[0407] After 10 iterations, the purification feature was achieved. The signal-to-noise ratio was improved to 18.4dB, and the separation accuracy of defect features and noise features reached 92%.

[0408] Example: Feature enhancement for contrast diffusion models:

[0409] Table 5 Physical parameters of Inconel 718 material

[0410]

[0411] Table 6 Diffusion process parameter adjustment

[0412]

[0413] Table 7 Calculation results of multi-scale contrast loss

[0414]

[0415] The discriminative power of the enhanced features was improved by an average of 76.7%, and the feature distance between different defect types increased by 2.3 times.

[0416] Example: Defect detection results:

[0417] The defect detection network outputs a defect category vector. and bounding box regression vector ,in This represents the number of defect categories (cracks, pores, inclusions).

[0418] Table 8 Statistics of Detection Network Output Data

[0419]

[0420] Table 9 Final Defect Detection Results

[0421]

[0422] After bounding box decoding, the actual location accuracy of the detected defects in the original image coordinate system reaches the sub-pixel level. The focusing parameters in the focus loss function are used in the detection loss function. Time consistency weight Multi-scale constraint weights Bounding box regression equilibrium coefficient .

[0423] The test results show that there are two crack defects (approximately 0.36 mm and 0.35 mm in length), three porosity defects (approximately 0.095-0.12 mm in diameter), and one inclusion defect (approximately 0.22 mm × 0.14 mm in size) on the surface of the turbine blade. The detection confidence of all defects exceeds 85%, which meets the quality control requirements of aerospace manufacturing.

[0424] It is understood that data preprocessing methods known to those skilled in the art include data cleaning, data transformation, and data reduction. Data transformation includes type conversion and normalization and standardization. Although the dimensions and types of data were omitted in the description of the preceding embodiments, data preprocessing is a technical knowledge known to those skilled in the art and a prerequisite step in data processing. Therefore, the previously described well-known data preprocessing steps were not described independently.

[0425] The embodiments of the present invention have been described above. However, the embodiments are not limited to the specific implementation methods described above. The specific implementation methods described above are merely illustrative and not restrictive. Those skilled in the art can make more equivalent embodiments under the guidance of the present embodiments, and all of them are within the protection scope of the present embodiments.

Claims

1. A method for detecting and repairing defects in alloy heat treatment based on image recognition, characterized in that, Includes the following steps: The original image data of the high-temperature alloy heat treatment process is acquired, and feature representations at different abstract levels are extracted layer by layer through a multi-level feature extraction network to generate multi-level feature representations. The multi-level feature extraction network contains multiple feature extraction layers, each of which corresponds to a different receptive field size. Low-level detailed features are preserved through a residual connection structure. The multi-level feature representation is input into the feature purification module. By introducing material physical constraints, defect features are separated from noise interference. These physical constraints include the continuity constraints of the metallic material, the geometric constraints of the defect morphology, and the temperature field distribution constraints of the heat treatment process. The calculation of the temperature field distribution constraints includes: [details of the defect features are missing from the original text]. Using a two-dimensional Gaussian filter Smoothing is performed to simulate the thermal diffusion effect and generate smooth features. ; Calculate the temperature gradient field using the Sobel operator ; Calculation of temperature field constraints based on the physical laws of heat conduction ,in This is the maximum allowable temperature gradient threshold determined based on the thermal conductivity of the alloy material; The physical constraint loss function of the feature purification module includes time-dimensional constraints: , in, For continuity constraints, For geometric constraint terms, For temperature field constraints, For time evolution constraints, The weights are the second-order time derivatives. , , , The time derivatives are calculated using finite differences, where the weights of each constraint term are used. ; The purified defect features are input into the contrastive diffusion model. Noise is added to the features through the forward diffusion process, and then the features are reconstructed through the reverse denoising process. The contrastive learning objective is incorporated into the reverse denoising process to generate an enhanced feature representation. A feature-image bidirectional mapping network is applied to establish the mapping relationship between enhanced features and reconstructed images, including feature-to-image branch and image-to-feature branch, and the mapping relationship is optimized by minimizing the bidirectional reconstruction error; Based on a materials knowledge base, physical property parameters are queried according to the alloy material type. These physical property parameters include the coefficient of thermal expansion. Thermal conductivity Phase transition temperature Elastic modulus and yield strength The step size of the diffusion model is dynamically adjusted through the following mapping relationship. and noise variance : , , in and As the baseline parameter, , To adjust the weights, This is the Min-Max normalization function; For different defect types, the parameter configuration of feature enhancement is adaptively adjusted based on the defect type distribution in the preliminary detection results; The enhanced feature representation is input into the defect detection network for defect detection. The defect detection network adopts a feature pyramid network structure and outputs the defect category probability distribution and defect bounding box coordinates for each pixel location.

2. The method for detecting and repairing alloy heat treatment defects based on image recognition according to claim 1, characterized in that, The multi-level feature extraction network includes: The input layer is used to receive RGB images and perform data preprocessing, including pixel value normalization. Convolutional coding layers contain multiple convolutional blocks, each containing two convolutional layers, processed by batch normalization and activation functions; The residual connection layer adds the output of each convolutional block to the input through skip connections, and performs dimension matching when the feature map spatial size and the number of channels are inconsistent. The multi-scale feature output layer extracts feature maps from different levels and generates the final multi-level feature representation through feature fusion operations.

3. The method for detecting and repairing alloy heat treatment defects based on image recognition according to claim 1, characterized in that, The feature purification module includes: The feature decomposition layer decomposes the input multi-level features into defect features and noise features; The physical constraint layer applies physical constraints to the decomposed features. Continuity constraints are achieved by calculating the L1 norm of the feature gradient, geometric constraints are achieved by comparing the radius of curvature at the calculated location with a geometric threshold, and temperature field constraints are calculated based on the temperature gradient distribution characteristics during the heat treatment process. The feature reconstruction layer reconstructs and cleans features through a fully connected layer.

4. The method for detecting and repairing alloy heat treatment defects based on image recognition according to claim 3, characterized in that, The feature purification process achieves feature separation through iterative optimization, including: Initialize defect and noise characteristics; In each iteration, the features are updated by gradient descent, minimizing the joint loss function of the degree of physical constraint violation and feature reconstruction error; The updated features are projected onto the physical constraint space, and the constraint projection problem is solved using the Lagrange multiplier method. The iteration stops when the change in the feature is less than a preset threshold.

5. The method for detecting and repairing alloy heat treatment defects based on image recognition according to claim 1, characterized in that, The comparative diffusion model includes: The diffusion encoder forward diffuses the input features and adds Gaussian noise at each time step. The noise scheduling parameters adopt a linear scheduling strategy. The denoising network adopts the U-Net architecture, which includes encoder and decoder paths and incorporates temporal embedding and conditional information through residual block processing. The contrastive learning head extracts features at different diffusion steps for contrastive learning, and maps the intermediate layer features to the contrastive learning feature representation through a multilayer perceptron.

6. The method for detecting and repairing alloy heat treatment defects based on image recognition according to claim 5, characterized in that, The contrastive diffusion model incorporates contrastive learning in the inverse denoising stage, including: Construct comparative sample pairs. For each defect feature, select positive samples from defects of the same type and a set of negative samples from defects of different types. Perform the forward diffusion process simultaneously on all samples to obtain the diffusion state at the same time step; Feature representations are extracted from the intermediate layer of the denoising network, the contrastive loss is calculated, and the similarity between features is measured by cosine similarity. The contrast loss is calculated at different time steps, and the final multi-scale contrast loss is obtained by weighted summation.

7. The method for detecting and repairing alloy heat treatment defects based on image recognition according to claim 1, characterized in that, The defect detection network includes: The feature pyramid network constructs multi-scale feature representations, including bottom-up and top-down paths, and fuses features of different scales through lateral connections. The detection head network applies a shared detection head to each pyramid level, including classification and regression branches; The output layer maps the output of the detection head to the final prediction, outputting the class probability and bounding box coordinates. The bounding box decoding layer decodes the bounding box regression values ​​output by the network into actual coordinates.

8. The method for detecting and repairing alloy heat treatment defects based on image recognition according to claim 1, characterized in that, The feature-image bidirectional mapping network ensures the reversible transformation between features and images through cycle consistency constraints, including: Feature coding normalization normalizes enhanced features to a specified range; Progressive image generation generates images of different resolutions through multi-stage upsampling; Feature reconstruction verification involves reconstructing features from the generated image using an encoder and calculating the reconstruction error. Semantic consistency is maintained by ensuring that the semantic information of defects is preserved during the mapping process through semantic loss.

9. An image recognition-based alloy heat treatment defect detection and repair system, used to execute the image recognition-based alloy heat treatment defect detection and repair method according to any one of claims 1-8, characterized in that, include: The image acquisition module is used to acquire raw image data of the high-temperature alloy heat treatment process; The multi-level feature extraction module is used to extract feature representations at different levels of abstraction through a multi-level feature extraction network. The feature purification module is used to separate defect features from noise interference through physical constraints. The contrastive diffusion processing module is used to generate enhanced feature representations through the contrastive diffusion model; The defect detection module is used to perform defect detection based on enhanced features and output the detection results.