Programmed generation and automatic labeling method of surface defect texture of industrial equipment
By collecting textures under multiple working conditions and extracting joint texture features from the surface of chemical equipment, and combining improved generative adversarial networks for generation and automatic annotation, the problem of existing technologies being unable to realistically reflect the textures of coexisting rust and scale defects has been solved. This has enabled high-quality defect texture generation and annotation, which is suitable for deep learning model training.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NANJING JINYU INFORMATION TECH CO LTD
- Filing Date
- 2026-03-30
- Publication Date
- 2026-06-26
AI Technical Summary
Existing technologies cannot accurately reflect the complex mixed structure when generating defect textures of rust and scale coexisting in chemical equipment. This results in significant differences between the generated textures and the actual equipment surface, especially in scenarios such as the inner walls of chemical reactors and storage tanks, where the appearance characteristics of rusted areas and deposits coexisting cannot be reflected.
By performing multi-condition texture acquisition and standardization on the surface of defect-free equipment, the joint texture features of rusted areas and deposited crystallization areas are extracted, a set of structural descriptions of mixed corrosion and deposition textures is constructed, and a mixed defect texture image is generated on the texture base library using an improved generative adversarial network. Automatic annotation is achieved by combining pixel-level masking.
The generated defect textures can realistically reflect the complex structure when rust and sediment coexist, reducing the visual difference between the generated textures and real industrial scenes, and providing high-quality defect samples for deep learning model training.
Smart Images

Figure CN121937553B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial visual inspection technology, and in particular to a programmed generation and automatic annotation of surface defect textures for industrial equipment. Background Technology
[0002] In chemical production processes, after long-term operation, the inner surfaces of 304 stainless steel equipment such as reactors and storage tanks often exhibit a combination of localized corrosion and scaling. This mixed defect poses a potential threat to the safe operation of the equipment. Automated visual inspection of this equipment requires a large number of image samples with defect annotations to train deep learning models. However, obtaining sufficient and diverse defect samples in real-world industrial scenarios is costly; therefore, generating defect textures programmatically has become an important alternative.
[0003] Existing technologies typically represent rust defects based on a single corrosion texture feature, such as simulating uniform rust spots or pitting morphology on a metal surface. However, in actual chemical equipment, rusted areas are often accompanied by scale or salt deposits, forming a complex mixed structure. Rust spots are partially covered by crystalline particles, resulting in a fragmented distribution at their boundaries. This visual structure, resulting from the superposition of corrosion and deposits, is difficult to effectively simulate using single-texture generation methods. This leads to significant differences between the generated defect textures and the actual equipment surface, especially in typical scenarios such as the inner walls of chemical reactors and storage tanks, where the generated textures fail to reflect the true appearance of rusted areas coexisting with deposits.
[0004] Therefore, there is an urgent need for a method to generate and automatically annotate defect textures that can realistically reflect the coexistence of rust and scaling in chemical equipment, in order to solve the problem that existing technologies generate textures that are monotonous and cannot simulate complex mixed structures. Summary of the Invention
[0005] In view of this, in order to solve the problems caused by the prior art, this application provides a method for programmatic generation and automatic annotation of surface defect textures of industrial equipment.
[0006] In a first aspect, the present invention provides a method for programmatically generating and automatically annotating surface defect textures of industrial equipment, the method comprising:
[0007] S1: Perform multi-condition texture acquisition and standardization processing on the surface of defect-free equipment to establish a texture base library for the equipment surface;
[0008] S2: Joint texture feature extraction is performed on the rusted area and the deposition crystallization area to construct a structural description set of mixed texture of corrosion and deposition crystallization.
[0009] S3: Based on an improved generative adversarial network, and constrained by the set of structure descriptions, a hybrid defect texture image in which corrosion and deposition crystallization coexist is generated on the base texture of the texture base library;
[0010] S4: Pixel-level masks are generated synchronously based on pixel position records during the generation process to achieve automatic labeling of defect areas;
[0011] S5: Organize the generated defect images and annotation information into a standardized sample set, divide it proportionally, and output a dataset adapted to mainstream training frameworks.
[0012] Optionally, S1 includes:
[0013] Original texture images of the surface of defect-free equipment were acquired under operating conditions in the temperature range of 20℃ to 30℃ and in the temperature range of 60℃ to 120℃.
[0014] The original texture image is subjected to noise suppression processing using Gaussian filtering;
[0015] The denoised texture image is subjected to brightness normalization processing to unify the grayscale distribution characteristics of the image;
[0016] By screening qualified areas using texture stability indicators, a standardized, defect-free equipment surface texture base library is constructed.
[0017] Optionally, S2 includes:
[0018] Extract the grayscale deviation intensity and edge roughness of the rusted area to quantify the basic characteristics of the corrosion texture;
[0019] Extract the cover density and particle dispersion of the sedimentary crystallization region to quantify the distribution characteristics of the sediment;
[0020] Establish the spatial coverage relationship between corrosion boundaries and deposited particles, and calculate the boundary fragmentation index to quantify the degree of damage to corrosion boundaries;
[0021] The extracted grayscale deviation intensity, edge roughness, coverage density, particle dispersion, and boundary fragmentation index of the rusted area are encapsulated into a structured control unit to form a hybrid texture structure description set.
[0022] Optionally, S3 includes:
[0023] A generation control unit is constructed, and the generation adaptation strength is calculated. The generation adaptation strength is used to evaluate the degree of matching between the base texture and the target defect features.
[0024] The feature parameters in the structure description set are mapped to feature map channel weights in the decoding stage of the generator network by hierarchical conditional injection. The feature parameters include corrosion grayscale deviation intensity, edge roughness, deposition coverage density, particle dispersion and boundary fragmentation index.
[0025] A continuous base rust region is generated on the base texture of the texture base library;
[0026] On the basic rusted area, based on the deposition coverage density, particle dispersion and boundary fragmentation index, a depositional crystal structure is superimposed on the rust boundary of the basic rusted area and its adjacent area to obtain an initial mixed defect texture image;
[0027] The discriminator is used to correct the overall realism and boundary realism of the initial mixed defect texture image, and the mixed texture consistency evaluation value is calculated.
[0028] In response to the mixed texture consistency evaluation value not reaching the preset threshold, the initial mixed defect texture image is sent back to the generator to optimize its local boundary and particle coverage structure until the mixed texture consistency evaluation value reaches the preset threshold, and a qualified mixed defect texture image is output.
[0029] Optionally, the hierarchical conditional injection includes:
[0030] The corrosion grayscale deviation intensity, edge roughness, deposition coverage density, particle dispersion, and boundary fragmentation index in the structure description set are mapped to feature map channel weights for different decoding stages in the generator network, respectively.
[0031] Among them, the modulation module corresponding to the boundary fracture index is assigned to the last two upsampling layers of the generator to control the degree of local fracture at the corrosion boundary;
[0032] Modulation modules corresponding to sediment cover density and particle dispersion are assigned to the intermediate layer to control the distribution density and scale variation of particles.
[0033] Optionally, S4 includes:
[0034] The initial category mask is generated by calling the location records during the generation process, and then refined by combining the boundary fragmentation index and sediment cover density;
[0035] Connected component separation and contour extraction are performed on the mask, and contour continuity is calculated to evaluate boundary reliability;
[0036] Boundary box annotations are generated based on the minimum bounding rectangle calculated from the contour, and multi-class masks are retained as semantic segmentation labels;
[0037] Extract key points from various regions and evaluate their reliability; perform label consistency checks to ensure label accuracy.
[0038] Optionally, the fine-tuning includes:
[0039] For pixels marked as overlapping areas of rust and deposition, the weight of neighborhood consistency correction is adjusted according to the boundary fragmentation index of their location; when the boundary fragmentation index is higher than a preset threshold, the correction intensity is reduced to preserve the true fragmentation boundary.
[0040] For sedimentary crystallization areas, the screening of isolated particles is guided by the sediment cover density. When the sediment cover density is high, the rejection threshold for isolated particles is lowered to retain densely distributed small particles.
[0041] Optionally, S5 includes:
[0042] Organize sample units and establish associated numbers, calculate sample association completeness to ensure that the labels are complete;
[0043] The training set, validation set, and test set are divided according to a preset ratio, and the division results are optimized by the deviation of the category distribution.
[0044] Generates bounding boxes, multi-class masks, and keypoint annotation files with normalized coordinates, adapting to mainstream training framework formats;
[0045] Organize the sample set according to the standard directory structure, calculate the packaging efficiency, and verify the output integrity.
[0046] In a second aspect, the present invention provides an electronic device comprising a memory and at least one processor, the memory storing a computer program, and the processor executing the computer program to implement the method of the first aspect described above.
[0047] Thirdly, the present invention provides a computer storage medium storing a computer program, which, when executed, implements the method described in the first aspect.
[0048] The beneficial effects of this invention are that, compared with the prior art, this disclosure has the following advantages:
[0049] 1) Addressing the limitation of existing technologies that can only represent corrosion texture features based on a single feature and cannot simulate the complex mixed structure when rust and deposits coexist, this invention constructs a joint texture feature of the corrosion region and the deposited crystallization structure. It not only extracts the grayscale deviation intensity and edge roughness of the corrosion region, and the coverage density and particle dispersion of the deposited crystallization region, but also establishes the spatial coverage relationship between the corrosion boundary and the deposited particles. The degree of occlusion and interruption of the corrosion boundary by the deposited particles is quantified into a boundary fragmentation index, and five core parameters are encapsulated into a structured control unit. Through this processing, the complex visual structure of rust and scale coexisting is transformed into a quantifiable and controllable mathematical description, overcoming the limitation of existing technologies that can only simulate a single texture feature. This allows the generated defect texture to realistically reflect the complex structure when the two coexist.
[0050] 2) To address the problem that existing technologies generate defect textures that differ significantly from real equipment surfaces and fail to accurately reflect the appearance characteristics of rust and deposits coexisting, this invention achieves realistic generation of hybrid defect textures through an improved generative adversarial network and a hierarchical conditional injection mechanism. The five extracted core parameters are mapped to feature map channel weights at different decoding stages in the generator network to achieve hierarchical conditional injection. The modulation module corresponding to the boundary fragmentation index is used to control the degree of local fracture at the rust boundary, while the modulation modules corresponding to the deposition coverage density and particle dispersion are used to control the density and scale variation of the particles. Through this hierarchical control mechanism, the generated rust boundary exhibits a realistic local fracture and fragmentation distribution under the deposition particle coverage. Simultaneously, the distribution density and scale variation of the deposition particles conform to the real scaling state, effectively reducing the visual difference between the generated texture and the actual industrial scene. Attached Figure Description
[0051] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0052] Figure 1 A flowchart of the method for procedural generation and automatic annotation of surface defect textures of industrial equipment provided in an embodiment of the present invention is shown;
[0053] Figure 2 A flowchart illustrating the construction process of a defect-free texture base library provided in an embodiment of the present invention is shown.
[0054] Figure 3 A flowchart illustrating the hybrid defect generation process based on an improved generative adversarial network provided in an embodiment of the present invention is shown.
[0055] The accompanying drawings have illustrated specific embodiments of the invention, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the invention in any way, but rather to illustrate the concept of the invention to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0056] The present invention will be further described below with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and should not be used to limit the scope of protection of the present invention.
[0057] The components of the embodiments of the invention described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0058] In the following, the terms “comprising,” “having,” and their cognates, which may be used in various embodiments of the invention, are intended only to indicate a particular feature, number, step, operation, element, component, or combination thereof, and should not be construed as excluding, firstly, the presence of one or more other features, numbers, steps, operations, elements, components, or combinations thereof, or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations thereof.
[0059] Unless otherwise specified, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which the various embodiments of the invention pertain. Terms (such as those defined in commonly used dictionaries) shall be interpreted as having the same meaning as in their contextual meaning in the relevant technical field and shall not be interpreted as having an idealized or overly formal meaning, unless clearly defined in the various embodiments of the invention.
[0060] Figure 1 The flowchart of the method for programmatic generation and automatic annotation of surface defect textures of industrial equipment provided in the embodiments of the present invention is as follows: Figure 1 As shown, the process may include the following steps:
[0061] S1: Perform multi-condition texture acquisition and standardization processing on the surface of defect-free equipment to establish a texture base library for the equipment surface.
[0062] This step aims to prepare a clean background image for subsequent defect generation. By acquiring images of the defect-free 304 stainless steel chemical equipment surface under multiple working conditions, and performing preprocessing such as noise suppression and brightness standardization on the original images, qualified texture areas are finally selected to construct a standardized equipment surface texture base library. Figure 2 The flowchart illustrating the construction process of the defect-free texture base library provided in this embodiment of the invention is shown, as follows: Figure 2 As shown, this is achieved through the following sub-steps.
[0063] S1.1: Acquire the original texture images of the surface of defect-free equipment under normal and high temperature conditions.
[0064] First, multi-condition image acquisition was performed on the surface areas of the 304 stainless steel chemical equipment that had been confirmed to be free of defects. During the acquisition process, images were taken under both normal and high-temperature conditions, and the ambient lighting system was controlled to output stable and uniform illumination, for example, using a ring-shaped shadowless light source to eliminate specular reflection interference. Normal temperature conditions refer to a temperature range of 20℃ to 30℃, and high-temperature conditions refer to a temperature range of 60℃ to 120℃. The pixel grayscale distribution and positional correspondence of each image were recorded. After acquisition, a raw texture image set was obtained. During this process, the grayscale mean of each image needed to be statistically analyzed, and its original brightness level recorded for use as a brightness benchmark in subsequent brightness unification processing. The calculation method for the image grayscale mean is as follows:
[0065] ;
[0066] in, This represents the average gray level of the image. Indicates the number of pixels along the width of the image. This represents the number of pixels in the height direction of the image. This represents the grayscale value at the i-th row and j-th column of the image, ranging from 0 to 255. This formula is used to calculate the average brightness level of the original image. This value can be used in subsequent analysis to understand the original brightness distribution of the image, but the subsequent brightness normalization process will recalculate the grayscale mean based on the denoised image.
[0067] S1.2: Gaussian filtering is used to suppress noise in the original texture image.
[0068] Spatial domain filtering is performed on the acquired raw texture image set to remove random noise introduced by sensor noise or environmental disturbances during the acquisition process. Specifically, Gaussian filtering is used to smooth the images. Gaussian filtering is a linear smoothing filter that can effectively suppress noise that follows a normal distribution while preserving the overall texture structure of the image to the greatest extent. The new value of each pixel in the Gaussian-filtered image is obtained by weighted averaging of itself and its neighboring pixels. The weights are determined by a Gaussian function, with pixels closer to the center having a larger weight. The pixel values after Gaussian filtering are calculated as follows:
[0069] ;
[0070] in, Indicates the location after filtering pixel values, Indicates the original image with Centered on, offset by The grayscale values of neighboring pixels, and This represents the neighborhood offset, and its value range is determined by the radius of the filter window. Decide, This represents the standard deviation of the Gaussian distribution and controls the decay rate of the weights. Its value ranges from 0.8 to 1.5, which can effectively filter out noise while preserving texture edges. This represents the radius of the filtering window, typically ranging from 1 to 3, corresponding to window sizes of 3×3 to 7×7. This formula smooths random noise in the image by weighted averaging of neighboring pixels, thus preserving the continuity of the texture structure. Noise suppression prevents subsequent texture analysis from misidentifying random noise as real texture structure, thereby ensuring the authenticity and reliability of the base texture.
[0071] S1.3: Perform brightness normalization processing on the denoised texture image to unify the grayscale distribution characteristics of the image.
[0072] Because images acquired under different operating conditions exhibit varying light intensities—for example, the surface reflectivity of equipment may change between normal and high temperatures—resulting in inconsistent image brightness, it is necessary to perform brightness normalization processing on the denoised texture image. First, the grayscale mean of the denoised image is recalculated, still denoted as... Then adjust the overall brightness of the image to a uniform target standard value. This ensures that the brightness levels of all images are basically consistent, facilitating subsequent texture analysis and generation. The brightness adjustment calculation is as follows:
[0073] ;
[0074] in, This represents the pixel value after brightness adjustment. This represents the filtered pixel value obtained in step S1.2. This represents the target grayscale mean, with a value range of 120 to 140. This range corresponds to a medium brightness level, which can make image details clear and avoid overexposure or underexposure. This represents the mean grayscale value of the current image (after denoising). This represents the brightness adjustment coefficient, with a value ranging from 0.6 to 1.2. It is used to control the non-linearity of brightness adjustment. When the value is less than 1, the dynamic range of the adjusted image will be compressed; conversely, it will be expanded. This formula achieves overall brightness balance through exponential scaling, adapting to images with different original brightness distributions and ensuring they ultimately have consistent brightness characteristics. This provides a unified lighting basis for subsequent texture region selection and generation.
[0075] S1.4: Select qualified regions through texture stability index and construct a standardized defect-free texture base library.
[0076] A texture region filtering operation is performed on the brightness-unified image to identify and remove regions containing contamination, crystal deposits, or specular reflections, as these regions can interfere with the realism of subsequent defect generation. During the filtering process, the texture stability index of each image patch or the entire image needs to be calculated. This index reflects the severity of grayscale changes within the image; when abnormal reflections or contamination are present, local grayscale changes will increase significantly, leading to a higher stability index. First, the mean grayscale value of the brightness-unified image is calculated, denoted as... This serves as the benchmark for subsequent calculations of the texture stability index. The texture stability index is calculated as follows:
[0077] ;
[0078] in, This represents a texture stability index. This represents the pixel value after brightness is uniform. This represents the average grayscale value of the image after brightness is uniform. and These represent the image width and height, respectively. This metric is essentially a variation of the image grayscale variance, used to quantify the overall dispersion of grayscale levels in an image. When If the image exceeds a preset threshold, it indicates abnormal reflection or contamination in the image area, and this area will be removed. The threshold can be set based on the statistical results of a large number of normal, defect-free texture samples; for example, normal samples can be used. The mean of the values plus three standard deviations is used as the rejection threshold. The remaining areas, once confirmed, are uniformly stored as a device surface texture base library, i.e., a standardized defect-free texture base library. Each image in this base library represents a pure, uniform stainless steel surface texture, which can be directly used in subsequent defect generation processes to ensure the background of generated defects is realistic and reliable.
[0079] In the technical solution of this invention, a standardized equipment surface texture base library is constructed by performing multi-condition data acquisition, noise suppression, brightness standardization, and texture region screening on the surface of defect-free equipment. Each image in this base library represents a pure and uniform stainless steel surface texture, providing a realistic and reliable background input for subsequent defect generation. This ensures that the generated defect texture is highly consistent with the real equipment surface in the background, avoiding a decrease in the overall credibility of the generated image due to background distortion.
[0080] S2: Perform joint texture feature extraction on the rusted area and the deposited crystallization area to construct a structural description set of mixed corrosion and deposition textures.
[0081] The core of this step is to analyze the complex visual structure of the coexistence of rust and scale on the surface of chemical equipment. By extracting features from the actual rusted area and the deposited crystallization area, rust texture parameters and deposited particle parameters are obtained respectively, and the spatial coverage relationship between the two is established. Finally, a set of hybrid texture structure descriptions containing five core parameters is formed, providing a precise constraint basis for the subsequent generation process. This is specifically achieved through the following sub-steps.
[0082] S2.1: Extract the grayscale deviation intensity and edge roughness of the rusted area to quantify the basic characteristics of the corrosion texture.
[0083] Typical corrosion spot areas were extracted from the actual collected images of the rusted areas and aligned with the defect-free texture base obtained in step S1 at the same scale. To ensure that the extraction results accurately reflect the corrosion propagation state in chemical equipment, the liquid level fluctuation area on the inner wall of the reactor, the weld seam adjacent area on the inner wall of the storage tank, and the long-term condensate contact area were preferentially selected as the source of rust samples, because the corrosion edges in these areas are more likely to exhibit non-uniform diffusion characteristics. For each rusted area, the local grayscale deviation intensity, edge undulation degree, and spot diffusion intensity were calculated to obtain the basic texture parameters of the rusted area.
[0084] The formula for calculating the deviation of corrosion grayscale from intensity is as follows:
[0085] ;
[0086] in, This indicates the intensity of the corrosion grayscale deviation, used to quantify the overall degree of grayscale deviation of the corroded area relative to the defect-free substrate. This represents the total number of pixels involved in the calculation within the eroded area; Indicates the first The grayscale value of each eroded pixel ranges from 0 to 255; The average gray value of the base texture corresponding to the eroded area is obtained by statistical analysis of the same location or type of area in the texture base library in step S1. This represents the deviation enhancement factor, ranging from 2 to 4, typically set to 3, used to enhance the response of locally deep corrosion areas. This formula highlights the degree of grayscale shift of the corroded area relative to a defect-free substrate through high-order deviation averaging, thereby distinguishing slight color differences from substantial corrosion.
[0087] The formula for calculating the roughness of the corrosion edge is as follows:
[0088] ;
[0089] in, It represents the roughness of the corrosion edge, used to quantify the geometric tortuosity and grayscale variability of the corrosion profile; Indicates the total number of sampling points for the corrosion profile; Indicates the first The local curvature of each contour sampling point can be calculated by the directional change of adjacent contour points; This represents the average curvature of all contour sampling points; Indicates the first The gray-level fluctuation coefficient in the neighborhood of a contour sampling point reflects the degree of gray-level change near that point. Specifically, it can be calculated as the ratio of the standard deviation of the pixel gray-level value in the neighborhood of that point, such as a 3×3 or 5×5 window, to the local average gray-level value. This represents the curvature enhancement index, ranging from 1.2 to 2.0, used to amplify the contribution of curvature to roughness. The grayscale fluctuation weight index, ranging from 0.5 to 1.5, is used to adjust the weight of grayscale fluctuation in roughness. This formula incorporates the degree of bending of the geometric profile with grayscale fluctuation into the evaluation, enabling the stable quantification of the fragmentation, jaggedness, and diffusion characteristics of rusted edges.
[0090] This sub-step transforms the visual representation of corrosion into a mathematical description composed of controllable texture parameters, so that the visual effect of the boundary being interrupted and obscured can be realistically simulated when deposited particles cover the area. Through the above calculations, the corrosion grayscale deviation intensity and edge roughness of the corrosion area are obtained. These two parameters together constitute the basic parameters describing the geometry and grayscale distribution of the corrosion boundary, denoted as the corrosion boundary parameters.
[0091] S2.2: Extract the cover density and particle dispersion of the sedimentary crystallization area to quantify the distribution characteristics of the sediment.
[0092] Based on the obtained corrosion boundary parameters, images of the scale-coexisting areas are further read, and granular analysis is performed on the scale, salt deposits, and localized crystal clusters. During processing, deposits are no longer treated as independent defects, but rather as covering structures that locally obstruct and cut off the boundaries of the corrosion area. Specifically, connected component separation and particle boundary fitting can be used to obtain particle size, particle spacing, and coverage density. A statistical window of 7 to 21 pixels is recommended for the particle size, and a minimum connected component area threshold of 9 to 25 pixels is recommended to avoid misidentifying weak noise as deposited particles.
[0093] The formula for calculating sediment cover density is as follows:
[0094] ;
[0095] in, This indicates the density of sediment cover, used to quantify the overall coverage of the rusted area by sediment particles. This represents the total area of the currently analyzed region, expressed in pixels. Indicates the total number of sediment particles; Indicates the first The projected area of each sedimentary particle; Indicates the first The distance from the center of each sedimentary grain to the nearest corrosion boundary; This represents the average distance from all particles to the rust boundary; The distance decay index ranges from 1.0 to 2.5. The core idea of this formula is that the closer the deposited particles are to the corrosion boundary, the greater their contribution to the boundary fragmentation effect. Therefore, when calculating the cover density, not only the particle area should be considered, but also the spatial coupling relationship between the particles and the corrosion boundary.
[0096] The formula for calculating the dispersion of sediment particles is as follows:
[0097] ;
[0098] in, It represents the dispersion of sedimentary particles and is used to measure the non-uniformity of sedimentary particles at different scales. Indicates the first The equivalent height of a particle, that is, the projected length of the particle in the vertical direction, can be obtained by the minimum bounding rectangle height of the particle's connected domain. Indicates the first The equivalent width of a particle, that is, the projected length of the particle in the horizontal direction, can be obtained by the width of the minimum bounding rectangle. This represents the average value of the equivalent height of all particles; This represents the average value of the equivalent width of all particles; This represents the total number of particles. The formula quantifies the degree of dispersion by calculating the variance of particle size. The more discrete the scale, the more irregular the subsequent shielding boundaries, which is closer to the actual scaling state in chemical equipment.
[0099] Through the above calculations, the sedimentary cover density and particle dispersion of the sedimentary crystallization region are obtained. These two parameters together constitute the basic parameters describing the distribution and scale variation of sedimentary crystallization particles, and are denoted as sedimentary crystallization characteristics.
[0100] S2.3: Establish the spatial coverage relationship between the corrosion boundary and the deposited particles, and calculate the boundary fragmentation index to quantify the degree of damage to the corrosion boundary.
[0101] After obtaining the deposition and crystallization characteristics, the spatial distribution of the deposited particles is correlated with the corrosion boundary parameters obtained in step 2.1. Using the corrosion profile as a baseline, coverage detection zones are established for its expanding and contracting neighborhoods, respectively. Then, the coverage ratio, cutting ratio, and boundary fragmentation contribution of the deposited particles to the profile are statistically analyzed. The key here is not simply determining whether particles are pressing on the rust, but rather determining the extent to which the particles disrupt the continuity of the corrosion boundary. When the coverage ratio is high and the particle dispersion is also high, the corrosion boundary often exhibits a fractured, irregular, or serrated appearance.
[0102] The formula for calculating the boundary fragility index is as follows:
[0103] ;
[0104] in, The boundary fragmentation index is used to comprehensively quantify the degree of damage to the corrosion boundary caused by deposited particles. Indicates the total number of sampling points for the corrosion profile; Indicates the first The number of times each contour sampling point is obscured by deposited particles within the coverage detection zone; Indicates the first The length of contour break within the neighborhood of each contour sampling point, i.e. the continuous length of the missing contour after being occluded by particles. This represents the average break length of all contour sampling points; This represents the sediment cover density obtained in step 2.2; The fracture enhancement index, ranging from 1.0 to 2.0, is used to enhance the contribution of fracture length to the fracture index. The coverage amplification index, ranging from 0.5 to 1.5, is used to adjust the influence weight of coverage density. This formula couples local occlusion, contour breakage, and overall coverage density, using a unified index to describe the reasons for the fragmented appearance of the boundary, thus providing direct constraints for subsequent generation stages.
[0105] S2.4: The extracted five types of core parameters are encapsulated into a structured control unit to form a set of hybrid texture structure descriptions.
[0106] The corrosion boundary parameters obtained in step 2.1, the deposition crystallization features obtained in step 2.2, and the coverage relationships constructed in step 2.3 are uniformly encoded to form a hybrid texture structure description set for subsequent generation stages. This set includes at least five core parameters: corrosion grayscale deviation intensity, edge roughness, deposition coverage density, particle dispersion, and boundary fragmentation index. It also records the corresponding typical operating condition categories, such as high-temperature condensation zones, liquid level fluctuation zones, or weld-adjacent zones. To facilitate subsequent steps, a one-to-one correspondence should be established between each set of description results and its source texture block, and the location information of areas with preferential particle coverage and high incidence of boundary fracture should be preserved.
[0107] When forming the structural description set, parameter filtering rules can be set to ensure that the description results conform to the actual working condition distribution: the corrosion grayscale deviation intensity should be between 18 and 75, the edge roughness should be between 0.12 and 0.85, the deposition coverage density should be between 0.08 and 0.60, and the boundary fragmentation index should be between 0.15 and 1.20. These ranges are not fixed values but are dynamically adjusted based on sample statistical results; if a certain indicator deviates from the actual working condition distribution for a long period, the corresponding sample block should be removed to prevent it from entering subsequent steps. Through the above processing, a structural description set of mixed corrosion and deposition textures that can directly describe the rusted area being partially covered by deposition particles and forming a fragmented boundary is finally obtained.
[0108] After obtaining the above five core parameters, this embodiment further encapsulates the parameters to form a structured control unit suitable for generating network input. Specifically, the encapsulation method is as follows: the corrosion grayscale deviation intensity and edge roughness are combined into a corrosion intrinsic control group to constrain the basic morphology and grayscale distribution of the corrosion region in the generated network; the deposition coverage density and particle dispersion are combined into a deposition coverage control group to constrain the distribution density and scale variation of deposition particles; and the boundary fragmentation index is used as a separate spatial coupling control group to constrain the overlay relationship between the corrosion boundary and deposition particles. These three control units are transmitted independently when inputting into the generated network and act on different decoding stages of the generator in the layered modulation module of step S3.1. Through this joint encapsulation method, the mixed texture features extracted in step S2 are transformed from dispersed parameter forms into structured control instructions, providing a more direct constraint basis for the subsequent generation process.
[0109] In the technical solution of this invention, by extracting the texture structure of the actual rusted area and the deposited crystallization area, a joint texture feature description set consisting of five core parameters—corrosion grayscale deviation intensity, edge roughness, deposition coverage density, particle dispersion, and boundary fragmentation index—is established. This step not only quantifies the individual characteristics of the rusted area and the deposited particles, but more importantly, it constructs the spatial coverage relationship between the corrosion boundary and the deposited particles. It transforms the complex visual structures such as boundary fragmentation and local occlusion when the two coexist into a quantifiable mathematical expression, providing a precise structural constraint basis for the subsequent generation process.
[0110] S3: Based on an improved generative adversarial network, and constrained by the set of structure descriptions, a hybrid defect texture image in which corrosion and deposition crystallization coexist is generated on the base texture of the texture base library.
[0111] This step uses a standardized, defect-free texture as a background and the structural description set output from step S2 as a constraint. An improved generative adversarial network is used to generate defect textures. During generation, a basic rust region is first formed, and then a depositional crystalline structure is superimposed to create realistic local fractures and grain occlusion effects at the rust boundaries. The final output is a hybrid defect texture image that closely resembles a real industrial scene. Figure 3 The following is a flowchart illustrating the hybrid defect generation process based on an improved generative adversarial network provided in an embodiment of the present invention, such as... Figure 3 As shown, this is achieved through the following sub-steps.
[0112] S3.1: Construct the generator control unit and calculate the adaptation strength, and map the feature parameters to the modulation signal of the generator network through hierarchical conditional injection.
[0113] Select a base texture block corresponding to the current working condition from a standardized, defect-free texture base library. Examples include base texture blocks corresponding to the condensation zone, liquid level fluctuation zone, and weld seam proximity zone under high-temperature conditions (60℃ to 120℃). Bind the corrosion grayscale deviation intensity, edge roughness, deposition coverage density, particle dispersion, and boundary fragmentation index output in step 2 to the same texture block number to form groups of generation control units. Each generation control unit simultaneously contains four types of information: base texture features, corrosion extension degree, deposition particle coverage location, and final boundary fragmentation degree. In the improved generative adversarial network, the generator does not directly generate random images but performs constrained generation after receiving conditional control input. To ensure that the corrosion texture and deposition texture do not deviate from the base texture, the adaptation strength between the current base and the target mixed texture must first be calculated. The formula for calculating the adaptation strength is as follows:
[0114] ;
[0115] in, This indicates the generation adaptation strength of the current texture block, used to measure the degree of matching between the current base texture and the target blending defect features; This indicates that the corrosion grayscale obtained in step 2 deviates from the intensity. This represents the roughness of the etched edge obtained in step 2; This represents the deposition cover density obtained in step 2; This represents the texture stability index of the corresponding base texture block in step 1; This represents the boundary fragility index obtained in step 2; This indicates the corrosion deviation amplification factor, with a value ranging from 0.8 to 1.6; This represents the edge roughness magnification factor, with a value ranging from 0.6 to 1.4; This represents the sediment cover weighting coefficient, with a value ranging from 0.5 to 1.2; This represents the basement stability inhibition coefficient, with a value ranging from 0.5 to 1.0; This represents the boundary breakage correction factor, with a value ranging from 0.7 to 1.5.
[0116] The core idea of this formula is that when the corrosion deviation is strong, the edge roughness is high, and the deposition coverage is obvious, the generation adaptation strength should be higher; while when the substrate itself is too smooth or the target boundary is extremely broken, the generation amplitude should be limited to prevent the generator from directly blurring or distorting the texture excessively.
[0117] At the model execution level, the generator employs an encoder-decoder structure. The encoder extracts the local surface undulations and brightness distribution of the base texture, while the decoder writes eroded and deposited textures step-by-step according to conditions. The discriminator uses a dual-branch structure: one branch focuses on overall visual realism, and the other on the realism of boundary fragmentation. In the initial training phase, the learning rate should be between 0.0001 and 0.0003, the batch size between 4 and 12, and the texture block size between 256×256 and 512×512. If the device surface is highly reflective, the batch size should be smaller to avoid excessive perturbation of the update direction by the reflective base during a single training iteration.
[0118] In terms of feature condition injection, this embodiment further maps corrosion grayscale deviation intensity, edge roughness, deposition coverage density, particle dispersion, and boundary fragmentation index to feature map channel weights at different decoding stages in the generator network. Specifically, in the upsampling stage of the generator, five parallel feature modulation modules are set up, each receiving the normalized values of the above five structural parameters and generating scaling and offset coefficients of corresponding scales through affine transformation, which are then applied to the decoded feature map. Here, the scaling and offset coefficients generated by the affine transformation of the structural parameters constitute the modulation signals used to finely control the generation process. Among them, the modulation module corresponding to the boundary fragmentation index is assigned to the last two upsampling layers of the generator to focus on controlling the local fracture degree of the corrosion boundary; the modulation modules corresponding to deposition coverage density and particle dispersion are assigned to the middle layer to control the density and scale variation of the particles. Through the above-mentioned layered condition injection mechanism, the hybrid texture structure description set output in step S2 can directly participate in the layer-by-layer feature reconstruction process of the generator, rather than just serving as a global condition input for the generation start.
[0119] S3.2: Prioritize the generation of continuous basic corrosion zones to provide a complete corrosion boundary for subsequent deposition of particles.
[0120] The generator prioritizes processing corrosion textures, without immediately introducing deposited particles. This is to first obtain a complete and continuous rust boundary, which is then locally covered and cut off by deposited particles in subsequent steps. Otherwise, if both types of structures are generated simultaneously from the beginning, a chaotic state can easily occur where the corrosion area itself is incomplete, and crystalline particles cover it, resulting in an unclear rust substrate structure. The basic rust generation process is as follows: First, the local brightness gradient area, surface texture direction, and substrate roughness level in the defect-free texture substrate are extracted using the encoding end; then, based on the corrosion grayscale deviation intensity and edge roughness, the corrosion diffusion texture is written layer by layer at the decoding end. Corrosion diffusion does not grow uniformly outward, but preferentially extends along the fine texture grooves in the substrate where liquid film retention is more likely to occur. To control the relationship between the corrosion area area and grayscale depth, a corrosion diffusion intensity function is used for adjustment.
[0121] ;
[0122] in, This indicates the intensity of corrosion propagation and is used to control the generation intensity of corrosion regions in the current iteration. This represents the generated adaptation strength obtained in step 3.1; This indicates that the corrosion grayscale deviates from the intensity. Indicates the roughness of the corrosion edge; This represents the area of the eroded region generated in the current iteration. The target corrosion area is obtained from the statistical analysis of similar samples in step 2. This represents the corrosion enhancement index, with a value ranging from 1.1 to 2.0. This represents the edge suppression index, with a value ranging from 0.4 to 1.2. This represents the area convergence index, with a value ranging from 0.8 to 1.8.
[0123] The core idea of this formula is that corrosion intensity is not solely determined by grayscale, but is also constrained by both the target area and the edge condition. When the generated area approaches the target area, the expansion rate should naturally slow down to prevent the corrosion zone from expanding outwards uncontrollably. After the basic rust formation is complete, a continuous rust area and a complete rust boundary can be obtained. At this point, the image does not yet show the characteristics of scale coexistence, but it already possesses a true boundary foundation interrupted by deposited particles.
[0124] S3.3: Deposited crystalline structures are superimposed on the basic rusted area, so that the rust boundary presents a fragmented effect of local fracture and particle obscuring.
[0125] Deposited crystalline structures are superimposed on the base corrosion area. This superposition is not a simple layer overlay, but rather, based on the deposition coverage density, grain dispersion, and boundary fragmentation index determined in step 2, several priority coverage areas are selected within the corrosion boundary and its adjacent zone. Deposited grains of different sizes are then pressed onto these areas, creating visual effects such as local gaps, grain occlusion, boundary fractures, and non-uniform outward expansion at the corrosion boundary. In practice, the priority coverage ratio is first determined based on the boundary fragmentation index. If the boundary fragmentation index is low, more deposited grains are distributed on the surface of the corrosion area, forming slight occlusion; if the boundary fragmentation index is high, more deposited grains are pressed onto the boundary line, forming obvious fractures and broken boundaries. The brightness of the deposited grains should not be completely detached from the substrate and corrosion grayscale; it should be coupled with the grayscale of the local area. Otherwise, the crystalline grains may appear unrealistically like stickers. Therefore, the formula for the local visual overlay intensity after deposition is defined as follows:
[0126] ;
[0127] in, It represents the local visual overlay intensity after sedimentation, and is used to measure the degree of visual integration between the superimposed sedimentary particles and the surrounding environment; Indicates sediment cover density; Indicates the dispersion of sedimentary particles; Indicates the boundary fragmentation index; This represents the average gray value of the sedimentary particle region; This represents the average gray value of the covered corrosion boundary region; This represents the average grayscale value of the corresponding base texture block; This represents the coverage density enhancement index, with a value ranging from 0.8 to 1.6; This represents the particle dispersion enhancement index, with a value ranging from 0.5 to 1.4; This represents the boundary fragmentation enhancement index, with a value ranging from 1.0 to 2.0; This represents the grayscale mismatch suppression index, with a value ranging from 0.6 to 1.5.
[0128] The core idea of this formula is that for deposited particles to create a realistic overlay effect, they need sufficient coverage density and boundary fragmentation contribution, but they also cannot be severely mismatched with the local grayscale relationship. If the particle grayscale differs too much from the surrounding area, even if the coverage position is correct, it will still appear obviously artificial. After the deposited particles are superimposed, the resulting image already shows an initial mixed defect texture where the rust boundary is partially covered by particles and the boundary appears fragmented, but its overall realism still needs to be further corrected by a discriminator. For ease of subsequent description, the generated image that has not yet been corrected by the discriminator at this point is defined as the initial mixed defect texture image.
[0129] S3.4: The generated image is corrected for overall realism and boundary realism by a discriminator, and a mixed defect texture image that meets the requirements is output.
[0130] The initial mixed defect texture image generated in step 3.3 is input into the discriminator and compared with images of rust and scaling in real chemical equipment. The discriminator consists of two parts: the first part judges the overall realism, focusing on whether the generated image maintains the consistency of the stainless steel substrate texture, grayscale transition of the corrosion area, and spatial distribution of deposited particles; the second part judges the boundary realism, focusing on whether the rust boundary presents a realistic local fracture, particle overlay, and discontinuous expansion structure. During training, the generator and discriminator are updated alternately. Typically, the first 20 rounds focus on teaching the generator to have continuous rust boundaries; the middle 20 rounds focus on learning particle overlay and boundary fracture; and the subsequent 20 rounds focus on optimizing local brightness contrast and overall visual consistency. The total number of training rounds should be 50 to 100 rounds; if the condensation area accounts for a large proportion of the samples under high-temperature conditions (60℃ to 120℃), 10 to 20 rounds can be added appropriately so that the model can fully learn the scaling particle overlay effect under weak reflective background.
[0131] To measure whether the final output image closely resembles a real industrial scene, a hybrid texture consistency evaluation value can be defined:
[0132] ;
[0133] in, This represents the consistency evaluation value of the mixed texture, used to quantify the overall similarity between the generated image and the real image; This represents the particle distribution similarity score, output by the particle branch of the discriminator; This represents the boundary structure similarity score, output by the discriminator's boundary branch; This represents the local contrast similarity score, output by the overall realism branch of the discriminator. The visual incongruity score is obtained from manual rule verification or statistical analysis of abnormal branches of the discriminator. This represents the particle distribution weighting index, with a value ranging from 0.8 to 1.4. This represents the boundary structure weight index, with a value ranging from 1.0 to 1.8; This represents the contrast weighting index, with a value ranging from 0.6 to 1.2. This represents the disharmony suppression index, with a value ranging from 1.0 to 2.0.
[0134] The core idea of this formula is that a realistic mixed defect texture must simultaneously meet three conditions: reasonable particle distribution, reasonable boundary fragmentation, and reasonable local visual contrast. If any one of these conditions is significantly distorted, the overall consistency will decrease.
[0135] When the consistency evaluation value of the mixed texture reaches the set threshold, the corresponding image can be output as a qualified texture image of mixed corrosion and deposition defects. This threshold should preferably be between 2.5 and 6.0, specifically set according to the statistical results of surface reflectivity and scale thickness distribution of different equipment. If the evaluation value does not reach the threshold, the image is sent back to the generator to further optimize its local boundaries and particle coverage structure.
[0136] This sub-step completes the final quality sealing, ensuring that the output is not just a viewable image, but a set of highly realistic mixed defect texture images that can be used for subsequent automatic annotation and model training, thus providing reliable input for the pixel-level mask synchronous annotation in step 4.
[0137] In the technical solution of this invention, based on an improved generative adversarial network, using a standardized defect-free texture as the background and the joint texture features output from step S2 as the conditional constraint, a layered conditional injection mechanism is used to achieve the collaborative generation of corrosion regions and deposited crystalline structures. During the generation process, a complete rust boundary is first formed, and then deposited particles are superimposed at specific locations based on the boundary fragmentation index and deposition coverage density. This allows the generated mixed defect texture to realistically reproduce the complex appearance of rust and scale coexisting in chemical equipment in terms of particle distribution, edge structure, and visual contrast, solving the problem that existing technologies cannot simulate the superposition effect of these two processes.
[0138] S4: Based on the pixel position records during the generation process, pixel-level masks are generated synchronously to achieve automatic annotation of defect areas.
[0139] This step involves organizing the generated defect images and their corresponding annotations to construct structured sample units. These units are then divided into training, validation, and test sets according to a preset ratio. A standardized annotation file compatible with mainstream training frameworks is generated, ultimately outputting a complete sample set that can be directly used for training industrial vision inspection models. This is achieved through the following sub-steps.
[0140] S4.1: The initial category mask is generated by calling the location record during the generation process, and then refined by combining the boundary fragmentation index and sediment cover density.
[0141] During defect texture generation in step S3, the generator has already recorded the writing position of the basic rust region, the coverage position of the deposited particles, and the overlap position after the boundary is pressed. The position recording results from step S3 are directly called, and each pixel in the image is assigned a corresponding mask category value according to its structure category. Specifically, background pixels can be assigned a value of 0, rust regions a value of 1, deposited crystallization regions a value of 2, and overlapping rust and deposit regions a value of 3. The resulting mask image is completely consistent with the defect texture image in resolution and coordinates. To reduce the interference of edge jaggedness and isolated noise on subsequent contour extraction, neighborhood consistency correction needs to be performed on the original mask. The proportion of pixels of the same category can be counted within a 3×3 or 5×5 window neighborhood, and the current pixel is reassigned according to the proportion result. This correction process can be evaluated using the following mask stability formula:
[0142] ;
[0143] in, This indicates mask stability and is used to evaluate the reliability of the category label for each pixel in the mask image; This represents the total number of pixels included in the statistics in the mask image; Indicates the first The number of pixels in a neighborhood that are of the same class as the pixel itself; This represents the total number of pixels in the neighborhood. It is 9 when using a 3×3 neighborhood and 25 when using a 5×5 neighborhood. Indicates the first The grayscale value of each pixel in the corresponding defect texture map; This represents the average grayscale value of the region containing the pixel's category; This represents the category consistency enhancement index, with a value ranging from 1.0 to 2.0. This represents the grayscale deviation suppression index, with a value ranging from 0.5 to 1.5.
[0144] The core idea of this formula is that if a pixel maintains high continuity with surrounding pixels of the same type in space, and its gray level differs little from the average gray level of its category region, then the category label of that pixel is more reliable. This metric can be used to filter out isolated mislabeled points and boundary spikes.
[0145] In the mask generation process described above, this embodiment further introduces the boundary fragmentation index and deposition coverage density extracted in step S2 as auxiliary constraints for mask refinement. Specifically, for pixels marked as overlapping areas of corrosion and deposition (category value 3), the boundary fragmentation index of their location is used as the basis for further refinement. Adjusting the weights of neighborhood consistency correction: when When the value exceeds a preset threshold (e.g., 0.6), it indicates that the region belongs to a high-incidence area of boundary fracture. The correction strength should be appropriately reduced in the neighborhood consistency correction to avoid excessive smoothing that could erase the true fracture boundary. When the intensity is below a preset threshold, smoothing is applied using the normal intensity. Meanwhile, for sedimentary crystallization regions (category 2), smoothing is applied based on the sediment cover density. Guiding the screening of isolated particles: when When the threshold is high, appropriately lower the removal threshold for isolated particles to retain densely distributed small particles; when When the threshold is low, the rejection threshold is increased to remove sporadic noise points. Through the above-mentioned masking refinement process based on feature parameters, the generated annotation information is made more consistent with the boundary characteristics of the corrosion and deposition coexisting region under real working conditions.
[0146] S4.2: Perform connected component separation and contour extraction on the mask, and calculate contour continuity to evaluate boundary reliability.
[0147] Connectivity separation and contour tracking are performed on each category of regions in the multi-category original mask set. During processing, rusted regions, deposited crystallization regions, and overlapping regions are first independently binarized according to their category values. Then, an eight-neighbor connected component search is performed on each category region to remove invalid fragments with excessively small areas. The area threshold can be dynamically set according to the image size; for example, for a 256×256 texture block, the minimum connected component area should be 8 to 20 pixels; for a 512×512 texture block, the minimum connected component area should be 20 to 60 pixels. Within each valid connected component, a sequence of contour points is extracted according to the outer boundary priority principle, and contour continuity is calculated. Higher contour continuity indicates a more reliable mask boundary. The contour continuity evaluation formula is as follows:
[0148] ;
[0149] in, This represents the contour continuity evaluation value, used to measure the smoothness and stability of the contour of a connected region; This represents the total number of sampling points on the contour of a certain connected component; Indicates the first The distance between a contour point and its adjacent contour points; This represents the average distance between all adjacent contour points in the connected region; Indicates the first The local curvature of a contour point can be calculated by the rate of change of the angle between the point and the vector formed by the vectors of the points before and after it, for example, by using the three-point curvature estimation method. This represents the average curvature of all contour points in the connected region; This represents the distance consistency enhancement index, with a value ranging from 0.8 to 1.5; This represents the curvature fluctuation suppression index, with a value ranging from 0.5 to 1.2.
[0150] The core idea of this formula is that the true region contour should have relatively uniform distances between points, and the curvature changes should not exhibit excessive, meaningless jitter. This evaluation value can be used to determine whether a certain contour needs further smoothing. In algorithm execution, boundary tracking can be used first, followed by light smoothing combined with local curvature constraints. The smoothing intensity should not be too high, otherwise it will mistakenly correct the true rust and fracture boundaries as overly smooth boundaries, destroying the authenticity of mixed defects. Typically, the number of smoothing iterations should be between 1 and 3.
[0151] S4.3: Generate bounding box annotations based on the minimum bounding rectangle calculated from the contour, and retain multi-class masks as semantic segmentation labels.
[0152] After obtaining the contours for each category, the minimum bounding rectangle is calculated for each valid contour to generate the bounding box annotation information required for target detection. For rusted areas, individual bounding boxes can be output; for deposited crystallization areas, single-particle bounding boxes or aggregated bounding boxes can be selected based on particle density; for overlapping areas, independent bounding boxes are preferred to highlight the mixed areas obscured by deposited particles. The compactness of the bounding boxes directly affects the training effect of the subsequent detection model, therefore, the bounding box envelope efficiency needs to be calculated. The formula for envelope efficiency is as follows:
[0153] ;
[0154] in, This represents the bounding box envelope efficiency, used to evaluate how tightly the bounding box wraps around the target region; Indicates the actual area covered by the outline; This represents the area of the corresponding outer bounding box; Indicates the perimeter of the bounding box; This represents the perimeter penalty coefficient, with a value ranging from 0.02 to 0.15.
[0155] The core idea of this formula is that if the bounding box area is too large and the actual target area is too small, the envelope efficiency will decrease; if the bounding box is too long and thin or too sparse, the ratio of its perimeter to its area will increase, which will also be penalized. This can avoid outputting detection boxes with severely empty envelopes.
[0156] For semantic segmentation annotation, the modified multi-class mask from step 4.1 can be directly retained as a pixel-level label map. This type of annotation data used for semantic segmentation tasks is collectively referred to as semantic segmentation labels. To adapt to different training needs, semantic segmentation labels in both single-channel class maps and multi-channel independent mask maps can be output simultaneously. Single-channel class maps are suitable for conventional semantic segmentation tasks, while multi-channel mask maps are more suitable for instance segmentation or mixed region separation tasks. This sub-step not only satisfies the semantic segmentation task but also transforms the same mask into bounding box information that can be directly used for object detection, improving the versatility of the annotation results.
[0157] S4.4: Extract key points for various regions and evaluate their reliability; perform annotation consistency checks to ensure accurate annotation.
[0158] Based on existing bounding boxes and semantic segmentation results, key point information for various regions is further extracted. For rusted regions, key points can be defined as the starting point, ending point, and the point corresponding to the maximum width along the main expansion direction; for sedimentary crystallization regions, key points can be defined as the centroid of the grains; for overlapping regions, key points can be defined as the point of strongest boundary fracture and the center point of local coverage. Key point extraction cannot rely solely on the geometric center; regional grayscale and contour morphology must also be considered, otherwise significantly eccentric sedimentary grains may be mistakenly labeled as intermediate points. The reliability of key points can be calculated using the following formula:
[0159] ;
[0160] in, Indicates the credibility of key points, used to evaluate the representativeness of the extracted key points; Indicates the height scale of the local area where the key point is located; Indicates the width of the local area where the key point is located; This represents the average height of all candidate keypoint regions for the current object. This represents the average width of all candidate keypoint regions for the current object. This represents the contour continuity evaluation value obtained in sub-step 4.2; This represents the normalized offset distance from the keypoint to the centroid of the region; This represents the height enhancement index, with a value ranging from 0.5 to 1.2; This represents the width enhancement index, with a value ranging from 0.5 to 1.2. This represents the contour continuity enhancement index, with a value ranging from 0.8 to 1.5; This represents the offset penalty index, with a value ranging from 0.6 to 1.4.
[0161] The core idea of this formula is that reliable keypoints should be located in regions with stable shapes, continuous contours, and no abnormal offsets. If a candidate point deviates significantly from the overall shape of the region, its reliability will decrease. After keypoint extraction, a consistency check needs to be performed. The check includes: whether the bounding box completely encloses the corresponding mask region; whether the keypoint falls within the corresponding category region; and whether the overlapping region maintains spatial contact with both the rusted region and the sedimentary crystallization region. If any condition is not met, return to sub-step 4.2 to correct the contour, or return to sub-step 4.3 to recalculate the bounding box. After the consistency check, a multi-type automatic annotation result set is finally formed.
[0162] In the technical solution of this invention embodiment, while generating defect textures, a pixel-level category mask is simultaneously generated based on the pixel position information recorded during the generation process. The boundary fragmentation index and deposition coverage density extracted in step S2 are introduced as auxiliary constraints for mask refinement. Through differentiated processing of overlapping regions and depositional crystallization regions, both realistic fragmentation boundary features are preserved and isolated noise points are effectively removed. Finally, multi-type annotation information including bounding box annotations, semantic segmentation annotations, and keypoint annotations is generated, achieving integrated execution of defect generation and annotation.
[0163] S5: Organize the generated defect images and annotation information into a standardized sample set, divide it proportionally, and output a dataset adapted to mainstream training frameworks.
[0164] After generating and automatically annotating defect textures, the generated defect images and corresponding annotation information are uniformly organized and arranged according to the standard structure of machine vision training datasets. The system automatically divides the dataset into training, validation, and test sets according to a preset ratio, and generates corresponding standardized annotation files. This allows the output dataset to be directly adapted to the training framework of mainstream industrial vision inspection models, ultimately outputting a standardized sample set containing texture images of mixed corrosion and scaling defects and their corresponding annotation information. This is achieved through the following sub-steps.
[0165] S5.1: Organize sample units and establish associated numbers, calculate sample association completeness to ensure that the labels are complete.
[0166] Each defect texture image, its corresponding mask file, bounding box annotation, and keypoint annotation are organized into sample units with the same number, and a one-to-one index relationship is established. Each sample unit includes at least the image number, category number, mask path, bounding box coordinates, and keypoint coordinates. This organization process aims to ensure that images and various annotation files will not be misaligned or lost during subsequent segmentation and use. To avoid the separation of images and annotations after subsequent segmentation, the sample association completeness needs to be calculated first to evaluate whether the various annotation files maintain a complete matching relationship with the original image. The formula for calculating sample association completeness is as follows:
[0167] ;
[0168] in, It represents the completeness of sample association and is used to measure the completeness of the image and its corresponding annotation file; This represents the number of valid sample units that simultaneously exist in the image, mask, bounding box, and keypoint; This represents the total number of image files, i.e., the total number of sample units. This formula calculates the proportion of complete sample units to the total number of sample units. When the value is close to 1, it indicates that the vast majority of samples have been fully matched; if... If the values are significantly lower, the missing annotation files need to be checked and regenerated or corrected.
[0169] Through the above processing, a set of sample unit indexes with a clear structure and complete association can be obtained, laying the foundation for subsequent dataset partitioning.
[0170] S5.2: Divide the training set, validation set, and test set according to a preset ratio, and optimize the division results by class distribution deviation.
[0171] The sample unit index set is divided according to a preset ratio. The training set ratio should be set to 60% to 80%, the validation set ratio to 10% to 20%, and the test set ratio to 10% to 20%. During the division, the distribution of rusted areas, deposited crystallization areas, and overlapping areas should be kept roughly consistent across the three subsets to avoid bias in model training due to uneven class distribution. Therefore, the class distribution deviation can be calculated to monitor the closeness of the class ratio of each subset to the overall ratio. The formula for calculating the class distribution deviation is as follows:
[0172] ;
[0173] in, It represents the deviation of the category distribution and is used to evaluate the degree of difference between the proportion of each category in a subset and the proportion of the corresponding category in the whole sample. This indicates the total number of categories, which typically include three categories: rusted areas, deposited and crystallized areas, and overlapping areas. This represents the proportion of the $c$-th class of samples in a certain subset; Represents the th element in the entire sample. The proportion of samples of each class.
[0174] This formula quantifies the degree of distribution deviation by summing the relative deviations of the proportions of each category. The smaller the value, the more consistent the category distribution of the subset is with the overall distribution. During the partitioning process, multiple random partitions and selections can be performed. The smallest possible partition is selected to ensure the representativeness of each subset.
[0175] S5.3: Generates bounding boxes, multi-class masks, and keypoint annotation files with normalized coordinates, adapting to mainstream training framework formats.
[0176] For object detection, bounding box annotation files are generated; for semantic segmentation, mask label files are generated; and for keypoint detection, keypoint coordinate files are generated. To ensure the generated annotation files are compatible with various mainstream training frameworks, pixel coordinates need to be converted to a normalized coordinate form independent of image size. The calculation methods for the normalized coordinates of the bounding box center and the normalized area value are as follows:
[0177] ;
[0178] ;
[0179] ;
[0180] in, Represents the normalized coordinates of the bounding box center along the image width direction; This represents the normalized coordinates of the bounding box center along the image height direction; This represents the normalized value of the bounding box area. , This represents the pixel coordinates of the top-left corner of the bounding box in the original image; , This represents the pixel coordinates of the bottom right corner of the bounding box in the original image; and These represent the width and height of the image (in pixels). This set of formulas converts absolute pixel coordinates into ratios relative to the image size, decoupling the annotation information from the image resolution and facilitating transfer between models with different input sizes. For semantic segmentation tasks, the multi-class mask corrected in step 4.1 can be directly saved as a single-channel PNG format or indexed color image, where pixel values 0, 1, 2, and 3 represent the background, rusted area, sedimentary crystallization area, and overlapping area, respectively. For keypoint detection tasks, the normalized coordinates and confidence level of each keypoint are saved together. This step generates a standardized annotation file set compatible with mainstream dataset formats.
[0181] S5.4: Organize the sample set according to the standard directory structure, calculate the packaging efficiency, and verify the output integrity.
[0182] The training, validation, and test sets are written to their respective directories and organized according to standard formats such as image folders, label folders, and configuration folders. For example, a first-level directory such as images, labels, and config can be created, with images further divided into train, val, and test subdirectories, and labels storing various annotation files accordingly. A category description file (e.g., classes.txt) and a dataset index list (e.g., train.txt, val.txt, test.txt) are also generated, listing the filenames or relative paths of all samples in each subset for direct use by subsequent training scripts. Before outputting, the packing efficiency needs to be calculated to verify the completeness of the final output dataset. The formula for calculating the packing efficiency is as follows:
[0183] ;
[0184] in, This indicates the packaging efficiency, which measures the proportion of successfully output sample units out of the expected total number of output sample units. This indicates the number of successfully output sample units, i.e., the number of samples that simultaneously contain the image and all necessary annotation files; This represents the total number of sample units to be output, i.e., the total number of valid sample units sorted out in step 5.1. This formula reflects the completeness of the dataset packaging process by calculating the ratio of the actual output to the expected output. When... When the value is close to 1, it indicates that all expected samples have been successfully output; if... If the values are significantly lower than expected, it is necessary to check whether there were any file write failures or missing data during the output process. After completing the above organization, the final standardized defect sample set can be output for direct use by subsequent industrial vision models.
[0185] In the technical solution of this invention, the generated defect texture images and corresponding annotation information are uniformly organized according to the standard dataset structure. The dataset is divided into training, validation, and test sets according to a preset ratio, and a standardized annotation file compatible with mainstream training frameworks is generated. Through multiple verification mechanisms such as sample association completeness, category distribution deviation, and packaging efficiency, the integrity and representativeness of the output dataset are ensured, ultimately forming a standardized defect sample set that can be directly used for training industrial visual inspection models. According to an embodiment of this invention, an electronic device is also provided, which may include: a processor, a communication interface, a memory, and a communication bus, wherein the processor, communication interface, and memory communicate with each other through the communication bus. The processor can call logical instructions in the memory to execute the methods provided in the above embodiments.
[0186] Furthermore, the logical instructions in the aforementioned memory can be implemented as software functional units and sold or used as independent products, and can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0187] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the methods provided in the above embodiments.
[0188] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0189] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0190] It should be understood that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for programmatically generating and automatically annotating surface defect textures of industrial equipment, characterized in that, The method includes: S1: Perform multi-condition texture acquisition and standardization processing on the surface of defect-free equipment to establish a texture base library for the equipment surface; S2: Joint texture feature extraction is performed on the rusted area and the deposition crystallization area to construct a structural description set of mixed texture of corrosion and deposition crystallization. S3: Based on an improved generative adversarial network, and constrained by the set of structure descriptions, a hybrid defect texture image in which corrosion and deposition crystallization coexist is generated on the base texture of the texture base library; S4: Pixel-level masks are generated synchronously based on pixel position records during the generation process to achieve automatic labeling of defect areas; S5: Organize the generated defect images and annotation information into a standardized sample set, divide them proportionally, and output a dataset that is compatible with mainstream training frameworks. S2 includes: Extract the grayscale deviation intensity and edge roughness of the rusted area to quantify the basic characteristics of the corrosion texture; Extract the cover density and particle dispersion of the sedimentary crystallization region to quantify the distribution characteristics of the sediment; Establish the spatial coverage relationship between corrosion boundaries and deposited particles, and calculate the boundary fragmentation index to quantify the degree of damage to corrosion boundaries; The formula for calculating the boundary fragility index is as follows: ; in, Indicates the boundary fragmentation index; Indicates the total number of sampling points for the corrosion profile; Indicates the first The number of times each contour sampling point is obscured by deposited particles within the coverage detection zone; Indicates the first The length of the contour break within the neighborhood of each contour sampling point; This represents the average break length of all contour sampling points; Indicates sediment cover density; Indicates the fracture enhancement index; Indicates the coverage amplification index; The extracted grayscale deviation intensity, edge roughness, coverage density, particle dispersion, and boundary fragmentation index of the rusted area are encapsulated into a structured control unit to form a hybrid texture structure description set. S3 includes: A generation control unit is constructed, and the generation adaptation strength is calculated. The generation adaptation strength is used to evaluate the degree of matching between the base texture and the target defect features. The feature parameters in the structure description set are mapped to feature map channel weights in the decoding stage of the generator network by hierarchical conditional injection. The feature parameters include corrosion grayscale deviation intensity, edge roughness, deposition coverage density, particle dispersion and boundary fragmentation index. A continuous base rust region is generated on the base texture of the texture base library; On the basic rusted area, based on the deposition coverage density, particle dispersion and boundary fragmentation index, a depositional crystal structure is superimposed on the rust boundary of the basic rusted area and its adjacent area to obtain an initial mixed defect texture image; The discriminator is used to correct the overall realism and boundary realism of the initial mixed defect texture image, and the mixed texture consistency evaluation value is calculated. In response to the mixed texture consistency evaluation value not reaching the preset threshold, the initial mixed defect texture image is sent back to the generator to optimize its local boundary and particle coverage structure until the mixed texture consistency evaluation value reaches the preset threshold, and a qualified mixed defect texture image is output.
2. The method for programmatic generation and automatic annotation of surface defect textures of industrial equipment according to claim 1, characterized in that, S1 includes: Original texture images of the surface of defect-free equipment were acquired under operating conditions in the temperature range of 20℃ to 30℃ and in the temperature range of 60℃ to 120℃. The original texture image is subjected to noise suppression processing using Gaussian filtering; The denoised texture image is subjected to brightness normalization processing to unify the grayscale distribution characteristics of the image; By screening qualified areas using texture stability indicators, a standardized, defect-free equipment surface texture base library is constructed.
3. The method for programmatic generation and automatic annotation of surface defect textures of industrial equipment according to claim 1, characterized in that, The injection via hierarchical conditions includes: The corrosion grayscale deviation intensity, edge roughness, deposition coverage density, particle dispersion, and boundary fragmentation index in the structure description set are mapped to feature map channel weights for different decoding stages in the generator network, respectively. Among them, the modulation module corresponding to the boundary fracture index is assigned to the last two upsampling layers of the generator to control the degree of local fracture at the corrosion boundary; Modulation modules corresponding to sediment cover density and particle dispersion are assigned to the intermediate layer to control the distribution density and scale variation of particles.
4. The method for programmatic generation and automatic annotation of surface defect textures of industrial equipment according to claim 1, characterized in that, S4 includes: The initial category mask is generated by calling the location records during the generation process, and then refined by combining the boundary fragmentation index and sediment cover density; Connected component separation and contour extraction are performed on the mask, and contour continuity is calculated to evaluate boundary reliability; Boundary box annotations are generated based on the minimum bounding rectangle calculated from the contour, and multi-class masks are retained as semantic segmentation labels; Extract key points from various regions and evaluate their reliability; perform label consistency checks to ensure label accuracy.
5. The method for programmatic generation and automatic annotation of surface defect textures of industrial equipment according to claim 4, characterized in that, The refined corrections include: For pixels marked as overlapping areas of rust and deposition, the weight of neighborhood consistency correction is adjusted according to the boundary fragmentation index of their location; when the boundary fragmentation index is higher than a preset threshold, the correction intensity is reduced to preserve the true fragmentation boundary. For sedimentary crystallization areas, the screening of isolated particles is guided by the sediment cover density. When the sediment cover density is high, the rejection threshold for isolated particles is lowered to retain densely distributed small particles.
6. The method for programmatic generation and automatic annotation of surface defect textures of industrial equipment according to claim 1, characterized in that, S5 includes: Organize sample units and establish associated numbers, calculate sample association completeness to ensure that the labels are complete; The training set, validation set, and test set are divided according to a preset ratio, and the division results are optimized by the deviation of the category distribution. Generates bounding boxes, multi-class masks, and keypoint annotation files with normalized coordinates, adapting to mainstream training framework formats; Organize the sample set according to the standard directory structure, calculate the packaging efficiency, and verify the output integrity.
7. An electronic device, characterized in that, The electronic device includes a memory and at least one processor, the memory storing a computer program, and the processor executing the computer program to implement the programmed generation and automatic annotation method for surface defect textures of industrial equipment as described in any one of claims 1-6.
8. A computer storage medium, characterized in that, It stores a computer program, which, when executed, implements a method for the programmed generation and automatic annotation of surface defect textures of industrial equipment according to any one of claims 1-6.