Aluminum foil heat-sealing infrared thermal image defect graph generation method based on generative adversarial network

By using a generative adversarial network-based approach, image pairs are formed by combining defect-free and defective images. Spatial attention is generated by combining textual conditions and defect foreground. This solves the problems of sample scarcity, difficulty in generating small-scale defects, and structural differences in the generation of infrared thermal images of aluminum foil heat sealing defects. High-quality defect image generation is achieved, supporting the detection of defects in aluminum foil heat sealing.

CN121121352APending Publication Date: 2025-12-12GUANGDONG POLYTECHNIC NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511322445.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-16
Publication Date
2025-12-12

AI Technical Summary

Technical Problem

Existing technologies for generating infrared thermographic defect images of aluminum foil heat sealing suffer from problems such as scarce defect samples, difficulty in generating small-scale defects, limitations in generating defect locations and areas, and significant differences in the structure of non-defect areas between defect images and non-defect images, making it difficult to meet the requirements for high-precision defect detection.

Method used

By constructing a generative adversarial network-based method, image pairs are formed using a large number of defect-free images and a small number of defective images. Textual conditions are used to control the type, area, and location of defects. Furthermore, spatial attention is used to guide the image decoder to reconstruct defective images using defect foreground generation, thus solving the problem of small-scale defects being ignored.

Benefits of technology

It effectively solves the problem of scarce infrared thermographic defect samples for aluminum foil heat sealing, realizes the accurate generation of small-scale defects, improves the diversity and realism of generated defect images, adapts to the defect distribution requirements of aluminum foil heat sealing process, and provides high-quality data support for subsequent defect detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121121352A_ABST
    Figure CN121121352A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image generation, and discloses an aluminum foil heat-sealing infrared thermal image defect graph generation method based on a generative adversarial network, and the method comprises the following steps: constructing a training data set of the aluminum foil heat-sealing infrared thermal image defect graph generation method; constructing an aluminum foil heat-sealing infrared thermal image defect graph generation method model; training and optimizing an aluminum foil heat-sealing infrared thermal image defect image generation model; and generating a defect graph based on the trained aluminum foil heat-sealing infrared thermal image defect graph generation model. According to the method, a defect attention module is introduced in a decoder reconstruction stage, a defect foreground and a part of feature layers of the decoder are fused to generate a space attention weight, and the decoder is guided to pay attention to a defect area so as to solve the problem of small-scale defect generation; and in combination with the output characteristics of the text encoder, the defect position and size generation are guided by manually specifying the labeled text, so that the defect area is controllable, and the authenticity and diversity of the aluminum foil heat-sealing infrared thermal image defect graph can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of image generation technology, specifically relating to a method for generating infrared thermal images of defects in aluminum foil heat sealing based on generative adversarial networks. Background Technology

[0002] Deep learning-based defect detection technology is one of the key technologies for improving product quality assurance in industrial production. Its detection performance mainly depends on the quality of the defect sample dataset and the performance of the deep learning model. However, in actual industrial production scenarios, the number of defect samples collected is usually very limited, resulting in a scarcity problem in the defect dataset. This problem directly restricts the training effect and generalization ability of the deep learning model, making it difficult to meet the high-precision defect detection requirements in industrial scenarios such as aluminum foil heat sealing.

[0003] To address the issue of insufficient defect samples, existing technologies primarily employ defect sample generation to expand the dataset. Mainstream methods can be categorized into two types: defect sample generation based on adversarial generative models (PGMs) and defect sample generation based on diffusion models. While diffusion-based defect sample generation methods are suitable for high-resolution image generation, they suffer from high computational costs. Furthermore, the resolution of infrared thermal imaging defect images of aluminum foil heat sealing is inherently low, making this method inefficient and limiting its practicality in this scenario. PGM-based defect sample generation methods excel at fitting the global structure and large-scale features of images but cannot effectively learn and generate small-scale defects, making them unsuitable for generating the small-scale defects commonly found in infrared thermal imaging of aluminum foil heat sealing.

[0004] To address the shortcomings of adversarial generative models in generating small-scale defects, existing technologies have further proposed a defect sample generation method combining adversarial generative models with mask-guided methods. The core logic of this method is to leverage the high similarity between the non-defective regions of defective samples and the defect-free image, using mask guidance to directionally generate defective regions within the defect-free image, thereby expanding the defect sample pool. However, this method has strict scene adaptation limitations, only applicable when the non-defective regions of defective samples have high similarity to the defect-free image.

[0005] In the scenario of generating infrared thermal images of defects in aluminum foil heat sealing, such defect images have significant scene specificity: on the one hand, the defects themselves are small in scale, and the location and area of ​​the defects are strictly limited by the aluminum foil heat sealing process, making it difficult for conventional methods to accurately generate defects that conform to the actual process characteristics; on the other hand, due to the thermal diffusion effect during the aluminum foil heat sealing process, the non-defect areas of the defect images differ significantly from the non-defect images in terms of temperature field distribution and texture structure, making it impossible to apply the adversarial generative model combined with mask guidance method.

[0006] In summary, existing defect sample generation methods struggle to simultaneously address issues such as the scarcity of defect samples, the difficulty in generating small-scale defects, the poor controllability of defect location and area, and the significant structural differences between defect and non-defect regions in defect and non-defect images when generating infrared thermal images of aluminum foil heat sealing. Therefore, there is an urgent need to propose a novel defect image generation method adapted to this specific scenario. This would improve the quality and diversity of generated infrared thermal images of aluminum foil heat sealing, providing sufficient and high-quality samples for subsequent defect detection model training, thereby enhancing the performance of deep learning-based aluminum foil heat sealing defect detection. Summary of the Invention

[0007] The purpose of this invention is to address the technical problems in the prior art regarding the generation of infrared thermal images of aluminum foil heat-sealing defects, including scarce defect samples, small defect scale, limited generation of defect location and area, and significant structural differences between non-defect areas and defect-free areas in the defect images. To solve these problems, this invention provides a method for generating infrared thermal images of aluminum foil heat-sealing defects based on generative adversarial networks (GANs). This method utilizes image pairs composed of a large number of defect-free images and a small number of defective images to fully leverage scarce defect data. It combines textual conditions to control defect type, area, and location to ensure the diversity of generated defect images. Simultaneously, it employs spatial attention to generate defect foregrounds to guide the image decoder in reconstructing the defect images, thereby addressing the problem of small-scale defects being ignored. Ultimately, this improves the quality and diversity of generated infrared thermal images of aluminum foil heat-sealing defects, providing reliable data support for defect detection and related intelligent analysis.

[0008] To achieve the above objectives, the present invention provides the following technical solution:

[0009] A method for generating defect images from infrared thermal images of aluminum foil heat sealing based on generative adversarial networks (GANs) utilizes a large number of defect-free images and a small number of defective images to fully leverage scarce defect data. It combines textual conditions to control defect type, area, and location to ensure the diversity of generated defect images. Simultaneously, it employs spatial attention to guide the image decoder in reconstructing the defect images, addressing the problem of small-scale defects being ignored. The method includes the following steps:

[0010] Step 1: Construct a training dataset for the method of generating infrared thermal images of defects in aluminum foil heat sealing;

[0011] Step 2: Construct a model for generating infrared thermographic defect images of aluminum foil heat sealing;

[0012] Step 3: Train and optimize the infrared thermal imaging defect image generation model for aluminum foil heat sealing;

[0013] Step 4: Generate a defect map based on the trained infrared thermal imaging defect map generation model for aluminum foil heat sealing.

[0014] Preferably, in step 1, the training dataset contains a large number of defect-free samples and a small number of defective samples. The defective samples need to be labeled with the category, location and area of ​​the defect. During training, defect-free images and defective images are used as input image pairs, and each defective image can be paired with multiple defect-free images to form multiple sets of image pairs.

[0015] Preferably, in step 2, the generative model is based on a generative adversarial network architecture, including two generators G1 and G2, and three discriminators D1, D2, and D3. G1 processes the input defect-free graph x... n Reconstructed into a pseudo-defect-free image x gn G2 uses the annotation text t and defect image x of the defect image. d And defect-free graph x n As input, generate a pseudo-defect map x. gd D1 is used to determine the pseudo-defect-free map x generated by G1. gn Whether it is real or not, D2 is used to determine the defect map x generated by G2. gd Whether it is real or not, D3 is used to determine the foreground of the false defect x. gdf Is it true?

[0016] Preferably, G1 includes an image encoder E img The input to Decoder1 and G1 is a defect-free graph x. n It is through E img Extract the features of the defect-free map img Decoder1 is based on Gaussian noise z1 and feature img Reconstruct the defect-free image x gn x gn The formula for calculation is:

[0017] x gn =G1(z1,x n (1).

[0018] Preferably, G2 includes a text encoder E text Image encoder E img The defect attention module DAB and the second decoder Decoder2, G1 and G2 use the same image encoder E. img The inputs to G2 are Gaussian noise z1, defect icon annotation text t, and defect image x. d And defect-free graph x n The output is a defect image x. gd ,t by E text Extract text features text x n By E img Extract the features of the defect-free map img, Decoder2 uses z2, feature text and feature img Reconstructing the defect map x gd x gd The formula for calculation is:

[0019] x gd =G2(z2,t,x) n ,x d (2).

[0020] Preferably, during the Decoder2 defect map reconstruction process, the Defect Attention Module (DAB) uses x d and x n Defect foreground map x obtained by difference df DAB guides Decoder2 to reconstruct the defect map by analyzing the defect foreground map x. df The DAB employs a multi-scale feature extraction and attention mechanism to generate spatial attention weights, guiding Decoder2 to focus on defect regions when reconstructing defect images. The input to DAB is x. n x d and the l-th layer features F of Decoder2 (l) The output is F (l) Weighted by defect space attention (defect_attention) The calculation process for DAB is as follows:

[0021] x df =x d -x n (3)

[0022] multi_scale_feature=concate(conv k×k (x df (4) | k∈{3,5,7})

[0023] defect_attention=LeakyReLU(conv 1×1 (concate(F(l),multi_scale_reature))) (5)

[0024]

[0025] In formulas (3)-(6), F (l) This represents the features extracted by the l-th convolutional layer of Decoder2, concate represents channel concatenation, conv represents convolution, LeakyReLU represents the activation function, and ⊙ represents element-wise multiplication.

[0026] Preferably, in step 3, the optimization objective of G1 is to make E img Extract x n A key feature of G1 is its loss function. The calculation formula is:

[0027]

[0028] Preferably, in step 3, the optimization objective of G2 is to make x gd Full image and defect foreground x df More realistic, x gd The defect location and defect area conform to the given t, and the loss function of G2. Depend on and It consists of 4 items, among which, Pay attention to the generation quality of the defect foreground in the defect map. Pay attention to the overall quality of the generated defect map. Pay attention to the location where the defect is generated. Focus on the area where defects are generated;

[0029] in, The formula for calculation is:

[0030] x gdf =x gd -x gn (8)

[0031]

[0032] in, The formula for calculation is:

[0033]

[0034] in, The formula for calculation is:

[0035]

[0036] In formula (11), r represents the actual radius of the aluminum foil, and f pos It is the ratio of the distance from the defect to the center of the aluminum foil to the radius of the aluminum foil;

[0037] in, The formula for calculation is:

[0038]

[0039] In formula (12) f area It is the ratio of the defect area to the aluminum foil area;

[0040] Therefore, the The formula for calculation is:

[0041]

[0042] In formula (13), λ1 to λ4 are used for adjustment The weight of each loss item.

[0043] Preferably, the optimization objective of D1 is to enable D1 to distinguish the defect-free image x generated by G1. gn Whether it is true or not, the discriminant loss of D1 The calculation formula:

[0044]

[0045] The optimization goal of D2 is to enable D2 to distinguish the defect map x generated by G2. gd Whether it is true or not, the discriminant loss of D2 The plan

[0046] Equation:

[0047]

[0048] The optimization objective of D3 is to enable D3 to distinguish the defect foreground x of the defect map generated by G2. gdf Whether it is real or not, the discriminant loss of D3 The calculation formula:

[0049]

[0050] The overall loss function for the method of generating infrared thermographic defect images of aluminum foil heat sealing is:

[0051]

[0052] In step 4, a defect map x is generated based on the trained aluminum foil heat-sealing infrared thermal imaging defect map generation model G2. gd At this point, the defect space attention `defect_attention` is fixed to the result obtained in the last round of training, and it no longer needs to be processed by the defect attention module DAB based on the defect foreground `x`. df The generation process is as follows: No defect image needs to be input before generating the defect map; the text 't' is specified manually, controlling the type, location, and area of ​​defects in the generated map. gd The calculation formula is:

[0053] x gd =G2(z2,t,x) n (18).

[0054] Compared with the prior art, the technical effects and advantages of the present invention are:

[0055] This invention effectively solves the problem of scarce infrared thermal imaging defect samples for aluminum foil heat sealing. Existing technologies are difficult to support deep learning model training due to the high difficulty and limited quantity of defect sample collection. However, this invention fully explores and utilizes the value of scarce defect data by forming multiple image pairs with a large number of defect-free images and a small number of defective images. Model training can be achieved without relying on a large number of defective samples, which greatly reduces the demand for the number of original defective samples and provides an efficient solution for expanding the defect dataset.

[0056] This invention successfully overcomes the technical bottleneck of generating small-scale defects. Existing methods based on adversarial generative models tend to overlook small-scale defects, while methods based on diffusion models are too costly. This invention innovatively introduces a defect attention module in the decoder reconstruction stage. By fusing the defect foreground with some feature layers of the decoder, spatial attention weights are generated to guide the decoder to focus on the defect region, effectively enhancing the generation effect of small-scale defects and ensuring that the generated defect map can accurately reproduce the small-scale defect features commonly found in aluminum foil heat sealing scenarios.

[0057] This invention enables controllable generation of defect location and area, solving the problem of limited defect generation parameters in existing technologies. Existing methods lack precise control over defect location and area, making it difficult to adapt to the actual requirements of defect distribution in aluminum foil heat sealing processes. In contrast, this invention combines text encoder output features, allowing control over the type, location, and area of ​​generated defects by manually specifying annotation text. This makes the generated defect map more closely resemble the real defect distribution patterns in industrial production, improving the scene adaptability of defect samples.

[0058] This invention overcomes the technical adaptation challenge caused by the structural differences between the non-defect regions of defect images and non-defect images. Existing adversarial generative models combined with mask guidance methods cannot be applied to aluminum foil heat-sealing scenarios due to their reliance on the premise of "high similarity of non-defect regions." However, this invention, through the collaborative work of dual generators and a defect attention guidance mechanism, can generate defect images that conform to the structural characteristics of infrared thermographic images of aluminum foil heat-sealing without relying on the similarity of non-defect regions. This ensures that the temperature field and texture structure of the non-defect regions in the defect image are consistent with those of the real aluminum foil heat-sealing thermographic image, significantly improving the realism and reliability of the generated defect images and providing high-quality data support for subsequent defect detection and intelligent analysis. Attached Figure Description

[0059] Figure 1 This is a basic flowchart of the present invention;

[0060] Figure 2 This is an overall framework diagram of the present invention;

[0061] Figure 3 This is a network structure diagram of the defect attention module of the present invention. Detailed Implementation

[0062] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0063] The following combination Figures 1 to 3 This application will be described in further detail;

[0064] This embodiment provides a method for generating infrared thermal image defect maps of aluminum foil heat sealing based on generative adversarial networks. Specifically, the method generates infrared thermal image defect maps of aluminum foil heat sealing through the following steps, ensuring that the generated defect maps are both realistic and diverse, and can effectively support tasks related to aluminum foil heat sealing defect detection.

[0065] The method of this invention consists of four core steps, the process of which is as follows: Figure 1 As shown, the specific steps include the following:

[0066] Step 1: Construct a training dataset for the method of generating infrared thermal images of defects in aluminum foil heat sealing;

[0067] Step 2: Construct a model for generating infrared thermographic defect images of aluminum foil heat sealing;

[0068] Step 3: Train and optimize the infrared thermal imaging defect image generation model for aluminum foil heat sealing;

[0069] Step 4: Generate a defect map based on the trained infrared thermal imaging defect map generation model for aluminum foil heat sealing.

[0070] In step 1, the training dataset for the aluminum foil heat-sealing infrared thermal imaging defect image generation method contains a large number of defect-free samples and a small number of defective samples. The defective samples need to be labeled, with the labeling information including the defect category, location, and area. The method uses a pair of images (one defect-free image and one defective image) as input for training, where each defective image can be paired with multiple defect-free images to form multiple image pairs. The acquisition process for each sample includes: thermal image capture, thermal image cropping, and thermal image annotation.

[0071] Thermal image capture: The temperature field of aluminum foil heat sealing was captured using a thermal imager, resulting in a 16-bit high dynamic range thermal image of the aluminum foil heat sealing. 16bit Use Max-min normalization to normalize I 16bit Compressed to 8-bit grayscale image I 8bit .

[0072] Thermal image cropping: for I 8bit Perform binarization processing, extract the maximum bounding rectangle of the binarized image, and crop I based on the maximum bounding rectangle.8bit Defect image x is obtained d Or defect-free diagram x n .

[0073] Thermal image annotations: The annotation information includes the defect category, location (pos), and area (area). Defect category is represented by an integer. The defect location (pos) is the ratio of the distance from the defect center to the center of the aluminum foil to the radius of the aluminum foil; the value of the defect location (pos) is a floating-point number from 0 (defect at the center) to 1 (defect at the edge of the aluminum foil). The defect area (area) is the ratio of the number of defect pixels to the number of aluminum foil pixels; the value of the defect area is a floating-point number from 0 (no defect) to 1 (defect covers the entire aluminum foil).

[0074] The calculation process for the defect location pos is as follows: Defect diagram x d And defect-free graph x n The defect foreground image x is obtained using image difference technology. df Then, for the defect foreground image x df Perform binarization and find its maximum bounding rectangle, the distance from the center of the maximum bounding rectangle to x. d The ratio of the center distance to the foil radius *r* is pos. The foil radius *r* is automatically measured by the algorithm, and its unit is pixels. The formula for calculating pos is:

[0075] pos = f pos (x n ,x d ,r) (19)

[0076] The calculation process for the defect area (area) is as follows: Defect map x d And defect-free graph x n Defect foreground image x is generated by image difference. df For the defect foreground image x df Binarization is performed. The white area in the binarized image represents the region where defect pixels are located. The ratio of the number of defect pixels to the number of aluminum foil pixels is the area. The number of aluminum foil pixels is obtained by calculating the area of ​​the circle from the aluminum foil radius r. The formula for calculating the area is:

[0077] area = f area (x n ,x d ,r) (20)

[0078] like Figure 2 As shown, in step 2, the infrared thermal image defect map generation model for aluminum foil heat sealing is based on a generative adversarial network architecture, including two generators G1 and G2, and three discriminators D1, D2, and D3. G1 generates the input defect-free image x... n Reconstructed into a pseudo-defect-free image x gn G2 uses the annotation text t and defect image x of the defect image.d And defect-free graph x n As input, generate a pseudo-defect map x. gd D1 is used to determine the pseudo-defect-free image x generated by G1. gn Is it real? D2 is used to determine the authenticity of the defect map x generated by G2. gd Is it real? D3 is used to determine if there are false defects in the foreground image x. gdf Is it true?

[0079] G1 includes an image encoder E img And the first decoder, Decoder1, E img The specific implementation is CLIP's visual transformer, and Decoder1 is implemented as the DCGAN generator. The input to G1 is a 128×128 resolution, 1-channel defect-free image. It is through E img Extract features from the defect-free map Decoder1 is based on Gaussian noise. and Reconstruct a defect-free image The calculation formula is denoted as:

[0080] x gn =G1(z1,x n (1)

[0081] The G2 includes a text encoder E text Image encoder E img Defect Attention Module (DAB) and the second decoder (Decoder2, E) text The specific implementation is a CLIP transformer, with G1 and G2 using the same E. img Decoder2 is specifically implemented as a DCGAN generator that incorporates DAB, with DAB embedded after each convolutional layer of the DCGAN generator. The input to G2 is Gaussian noise. Defect annotation text t, defect diagram Defect-free diagram The output is a defect diagram. The content of the defect annotation text t is "a photo of {DefectClass}{Defectpos}{Defectarea}object". During model training, {DefectClass} is the class labeled when the dataset was built, {Defectpos} is the defect location pos labeled when the dataset was built, and {Defectarea} is the defect area area labeled when the dataset was built. During model inference, the content of the defect annotation text t is specified manually.

[0082] Furthermore, in G2, t is determined by E. text Extracted text features By E img Extract the features of the defect-free map Decoder2 uses and Reconstruct the defect map In addition, during the Decoder2 defect map reconstruction process, DAB utilizes and To guide Decoder2 in reconstructing the defect map The formula for calculation is:

[0083] x gd =G2(z2,t,x) n ,x d (2)

[0084] The process is as follows Figure 3 As shown, during the Decoder2 defect map reconstruction process, DAB uses... and Defect foreground map obtained by difference This guides Decoder2 to reconstruct the defect map. DAB uses the defect foreground... A multi-scale feature extraction and attention mechanism is used to generate spatial attention weights to guide the decoder Decoder2 to focus on defect regions when reconstructing defect images. The input of DAB is... and the l-th layer features F of Decoder2 (l) The output is F (l) Weighted by defect space attention (defect_attention) The calculation process for DAB is as follows:

[0085] x df =x d -x n (3)

[0086] multi_scale_feature=concate(conv k×k (x df (4) | k∈{3,5,7})

[0087] defect_attention=LeakyreLU(conv 1×1 (concate(F(l),multi_scale_feature))) (5)

[0088]

[0089] In formulas (3)-(6), concate represents channel concatenation, conv represents convolution, LeakyReLU represents activation function, and ⊙ represents element-wise multiplication.

[0090] D1 is used to determine the defect-free map generated by G1. To verify this, the backbone network of D1 is ResNet18. The input to D1 is... and The output of D1 is the probability from 0 (predicting the input image is a generated image) to 1 (predicting the input image is a real image).

[0091] D2 is used to determine the defect map generated by G2. To verify this, D2's backbone network is ResNet18. The input to D2 is... and The output of D2 is the probability from 0 (predicting the input image is a generated image) to 1 (predicting the input image is a real image).

[0092] D3 is used to determine the defect foreground image of the generated defect map. To verify this, the backbone network of D3 is ResNet18. The input to D3 is... and The output of D3 is the probability from 0 (predicting the input image is a generated image) to 1 (predicting the input image is a real image).

[0093] In step 3, the optimization objective of G1 is to make E img Extract The key feature, therefore, is the loss function of G1. The formula for calculation is:

[0094]

[0095] The optimization objective of G2 is to make and More realistic, and more The defect location and defect area conform to the set t. Therefore, the G2 loss function... It consists of 4 items, namely and in, Pay attention to the quality of the generated defect foreground map in the defect map. Pay attention to the overall quality of the generated defect map. Pay attention to the location where the defect is generated. Pay attention to the area where defects are generated.

[0096] in, The formula for calculation is:

[0097] xgdf =x gd -x gn (8)

[0098]

[0099] in, The formula for calculation is:

[0100]

[0101] in, The formula for calculation is:

[0102]

[0103] in, The formula for calculation is:

[0104]

[0105] Among them, the The formula for calculation is:

[0106]

[0107] In formula (13), λ1 to λ4 are used for adjustment The weight of each loss item.

[0108] The optimization objective of D1 is to enable D1 to distinguish the defect-free map generated by G1. Whether it is true or not, the discriminant loss of D1 The calculation formula:

[0109]

[0110] The optimization objective of D2 is to enable D2 to distinguish the defect maps generated by G2. Whether it is true or not, the discriminant loss of D2 The calculation formula:

[0111]

[0112] The optimization objective of D3 is to enable D3 to distinguish the defect foreground image from the defect image generated by G2. Whether it is real or not, the discriminant loss of D3 The calculation formula:

[0113]

[0114] The total loss function of the aluminum foil heat-sealing infrared thermal image defect map generation method based on generative adversarial networks is:

[0115]

[0116] In step 4, a defect map is generated based on the trained aluminum foil heat-sealing infrared thermal imaging defect map generation model G2. At this point, the defect space attention `defect_attention` is fixed to the result obtained in the last round of training, and it no longer needs to be processed by the defect attention module DAB based on the defect foreground. Therefore, in step 4, the generation of the infrared thermal image defect image for aluminum foil heat sealing does not require an input defect map. Meanwhile, the text 't' is manually specified to control the type, location, and area of ​​the defect in the generated defect map. At this point... The calculation formula is:

[0117] x gd =G2(z2,t,x) n (18)

[0118] This invention proposes a method for generating infrared thermal images of aluminum foil heat-sealing defects based on generative adversarial networks (GANs). This method utilizes image pairs composed of a large number of defect-free images and a small number of defective images, making full use of scarce defect data. It also incorporates textual conditions to control the defect type, area, and location, ensuring the diversity of generated defective images. Simultaneously, it employs spatial attention generated from defect foreground images to guide the image decoder in reconstructing the defective images, thereby addressing the problem of small-scale defects being easily overlooked. This invention solves the problem of generating infrared thermal images of aluminum foil heat-sealing defects in scenarios where defect samples are scarce, defect scale is small, the generated defect location and area are limited, and there are significant structural differences between the non-defective regions of the defective images and the defect-free images. This reduces the acquisition and annotation costs of these defects.

[0119] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for generating infrared thermal image defect maps of aluminum foil heat sealing based on generative adversarial networks, characterized in that, Includes the following steps: Step 1: Construct a training dataset for the method of generating infrared thermal images of defects in aluminum foil heat sealing; Step 2: Construct a model for generating infrared thermographic defect images of aluminum foil heat sealing; Step 3: Train and optimize the infrared thermal imaging defect image generation model for aluminum foil heat sealing; Step 4: Generate a defect map based on the trained infrared thermal imaging defect map generation model for aluminum foil heat sealing.

2. The method for generating infrared thermal image defect maps of aluminum foil heat sealing based on generative adversarial networks according to claim 1, characterized in that: In step 1, the training dataset contains a large number of defect-free samples and a small number of defective samples. The defective samples need to be labeled with the category, location and area of ​​the defect. During training, defect-free images and defective images are used as input image pairs, and each defective image can be paired with multiple defect-free images to form multiple sets of image pairs.

3. The method for generating infrared thermal image defect maps of aluminum foil heat sealing based on generative adversarial networks according to claim 1, characterized in that: In step 2, the generative model is based on a generative adversarial network architecture, including two generators G1 and G2, and three discriminators D1, D2, and D3. G1 processes the input defect-free graph x... n Reconstructed into a pseudo-defect-free image x gn G2 uses the annotation text t and defect image x of the defect image. d And defect-free graph x n As input, generate a pseudo-defect map x. gd D1 is used to determine the pseudo-defect-free map x generated by G1. gn Whether it is real or not, D2 is used to determine the defect map x generated by G2. gd Whether it is real or not, D3 is used to determine the foreground of the false defect x. gdf Is it true? 4. The method for generating infrared thermal image defect maps of aluminum foil heat sealing based on generative adversarial networks according to claim 3, characterized in that: G1 includes image encoder E img The input to Decoder1 and G1 is a defect-free graph x. n It is through E img Extract the features of the defect-free map img Decoder1 is based on Gaussian noise z1 and feature img Reconstruct the defect-free image x gn x gn The formula for calculation is: x gn =G1(z1,x n ) (1)。 5. The method for generating infrared thermal image defect maps of aluminum foil heat sealing based on generative adversarial networks according to claim 3, characterized in that: G2 includes a text encoder E text Image encoder E img The defect attention module DAB and the second decoder Decoder2, G1 and G2 use the same image encoder E. img The inputs to G2 are Gaussian noise z1, defect icon annotation text t, and defect image x. d And defect-free graph x n The output is a defect image x. gd ,t by E text Extract text features text x n By E img Extract the features of the defect-free map img , Decoder2 uses z2, feature text and feature img Reconstructing the defect map x gd x gd The formula for calculation is: x gd =G2(z2,t,x n ,x d ) (2)。 6. The method for generating infrared thermal image defect maps of aluminum foil heat sealing based on generative adversarial networks according to claim 5, characterized in that: During the defect map reconstruction process in Decoder2, the Defect Attention Module (DAB) uses x d and x n Defect foreground map x obtained by difference df DAB guides Decoder2 to reconstruct the defect map by analyzing the defect foreground map x. df The DAB employs a multi-scale feature extraction and attention mechanism to generate spatial attention weights, guiding the decoder (Decoder2) to focus on defect regions when reconstructing defect images. The input to the DAB is x. n x d and the l-th layer features F of Decoder2 (l) The output is F (l) Weighted by defect space attention (defect_attention) The calculation process for DAB is as follows: x df =x d -x n (3) multi_scale_feature=concate(conv k×k (x df )|k∈{3,5,7}) (4) defect_attention=LeakyReLU(conv 1×1 (concate(F (l) ,multi_scale_feature)))(5) In formulas (3)-(6), F (l) This represents the features extracted by the l-th convolutional layer of Decoder2, concate represents channel concatenation, conv represents convolution, LeakyReLU represents the activation function, and ⊙ represents element-wise multiplication.

7. The method for generating infrared thermal image defect maps of aluminum foil heat sealing based on generative adversarial networks according to claim 3, characterized in that: In step 3, the optimization objective of G1 is to make E img Extract x n A key feature of G1 is its loss function. The calculation formula is:

8. The method for generating infrared thermal image defect maps of aluminum foil heat sealing based on generative adversarial networks according to claim 3, characterized in that: In step 3, the optimization objective of G2 is to make x gd Full image and defect foreground x df More realistic, x gd The defect location and defect area conform to the given t, and the loss function of G2. Depend on and It consists of 4 items, among which, Pay attention to the generation quality of the defect foreground in the defect map. Pay attention to the overall quality of the generated defect map. Pay attention to the location where the defect is generated. Focus on the area where defects are generated; in, The formula for calculation is: x gdf =x gd -x gn (8) in, The formula for calculation is: in, The formula for calculation is: In formula (11), r represents the actual radius of the aluminum foil, and f pos It is the ratio of the distance from the defect to the center of the aluminum foil to the radius of the aluminum foil; in, The formula for calculation is: In formula (12) f area It is the ratio of the defect area to the aluminum foil area; Therefore, the The formula for calculation is: In formula (13), λ1 to λ4 are used for adjustment The weight of each loss item.

9. The method for generating infrared thermal image defect maps of aluminum foil heat sealing based on generative adversarial networks according to claim 8, characterized in that: The optimization goal of D1 is to enable D1 to distinguish the defect-free image x generated by G1. gn Whether it is true or not, the discriminant loss of D1 The calculation formula: The optimization goal of D2 is to enable D2 to distinguish the defect map x generated by G2. gd Whether it is true or not, the discriminant loss of D2 The calculation formula: The optimization objective of D3 is to enable D3 to distinguish the defect foreground x of the defect map generated by G2. gdf Whether it is real or not, the discriminant loss of D3 The calculation formula: The overall loss function for the method of generating infrared thermographic defect images of aluminum foil heat sealing is:

10. The method for generating infrared thermal image defect maps of aluminum foil heat sealing based on generative adversarial networks according to claim 1, characterized in that: In step 4, a defect map x is generated based on the trained aluminum foil heat-sealing infrared thermal imaging defect map generation model G2. gd At this point, the defect space attention `defect_attention` is fixed to the result obtained in the last round of training, and it no longer needs to be processed by the defect attention module DAB based on the defect foreground `x`. df The generation process is as follows: No defect image needs to be input before generating the defect map; the text 't' is specified manually, controlling the type, location, and area of ​​defects in the generated map. gd The calculation formula is: x gd =G2(z2,t,x n ) (18)。