Defect image synthesis method, electronic device, and computer-readable storage medium
By acquiring and utilizing the physical constraint information of the target product to generate defect images, the problem of insufficient realism and usability of synthetic defect images is solved, and efficient training and high robustness of the defect detection model are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHONGDIAN DATA IND CO LTD
- Filing Date
- 2025-11-07
- Publication Date
- 2026-04-28
AI Technical Summary
The realism and usability of synthesized defect images in existing technologies are insufficient, affecting the robustness and applicability of defect detection models.
By acquiring the physical constraint information of the target synthetic defect in the target product, the physical parameters of the defect are determined, and the target synthetic defect image is generated based on these parameters, ensuring that the synthetic defect conforms to the real physical laws in terms of spatial layout and geometric features.
It significantly improves the visual realism and physical plausibility of synthesized defect images, enhances the recognition sensitivity and generalization ability of defect detection models, and improves the robustness and applicability of defect detection systems.
Smart Images

Figure CN121095058B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image synthesis technology, and in particular to defective image synthesis methods, electronic devices, and computer-readable storage media. Background Technology
[0002] With the deepening of industrial automation and intelligent manufacturing, defect detection has become a key link in ensuring production quality and efficiency in many fields such as electronics manufacturing, automotive parts, textiles, and photovoltaic modules. High-precision automated defect detection systems can significantly improve detection efficiency, reduce reliance on manual labor, and ensure product consistency. However, building high-performance detection models usually requires a large number of well-labeled defect samples. In actual production environments, real defect samples are not only scarce and costly to collect, but also difficult to cover all potential defect types, severely limiting the training sufficiency and generalization ability of detection algorithms.
[0003] To address the scarcity of defect data, related technologies primarily synthesize defect samples through image generation or editing methods. For example, generative adversarial networks (GANs) or template-based image stitching methods are used to transplant or generate existing defective regions into normal product images. However, in practical applications, the defect images generated by these methods often lack realism and usability. The synthesized defect samples are insufficient to effectively support the performance improvement of defect detection models in actual deployments, affecting the robustness and applicability of the defect detection system.
[0004] Therefore, how to improve the realism and usability of synthetic defect images to support the training of high-performance defect detection models has become a pressing technical challenge in the field of defect detection. Summary of the Invention
[0005] The main objective of this application is to provide a method for synthesizing defective images, an electronic device, and a computer-readable storage medium, aiming to solve the technical problem of how to improve the realism and usability of synthesized defective images.
[0006] To achieve the above objectives, this application provides a method for synthesizing defective images, the method comprising:
[0007] Obtain the physical constraint information of the target synthetic defect in the target product;
[0008] Based on the physical constraint information, the physical parameters of the target synthetic defect in the target product corresponding to the physical constraint information are determined;
[0009] Based on the physical parameters of the target synthetic defect in the target product, a target synthetic defect image of the target product is generated, wherein the target synthetic defect image is an image of the target product having the target synthetic defect.
[0010] Furthermore, to achieve the above objectives, this application also provides a method for constructing a defective image dataset, comprising:
[0011] Obtain multiple different target synthesized defect images generated by the defect image synthesis method described above, as well as the defect physical parameters corresponding to each target synthesized defect image;
[0012] The target synthetic defect images are associated with the corresponding defect physical parameters to obtain the defect image data corresponding to each target synthetic defect image;
[0013] The defect image dataset is constructed based on the defect image data.
[0014] In addition, to achieve the above objectives, this application also provides an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the defect image synthesis method described above.
[0015] In addition, to achieve the above objectives, this application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the defect image synthesis method described above.
[0016] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the defect image synthesis method described above.
[0017] This application provides a defect image synthesis method, an electronic device, and a computer-readable storage medium, relating to the field of image synthesis technology. The method includes: acquiring physical constraint information of a target synthesized defect in a target product; determining, based on the physical constraint information, defect physical parameters in the target product corresponding to the physical constraint information; and generating a target synthesized defect image of the target product according to the defect physical parameters of the target synthesized defect in the target product, wherein the target synthesized defect image is an image of the target product having the target synthesized defect.
[0018] This application's embodiments effectively solve the technical problem of insufficient realism and usability of synthesized defect images in existing technologies by introducing "physical constraint information" as the core guiding principle for defect image synthesis. The core principle is that defects in real industrial scenarios do not appear randomly or irregularly at any location or in any form on a product. Instead, they are influenced by multiple factors such as product structure, material properties, processing procedures, and usage environment, ultimately exhibiting a generalizable physical regularity in spatial distribution. The "physical constraint information" in this application's embodiments is precisely the quantitative expression and formal modeling of this regularity, specifically manifested as spatial and geometric constraints on the target product, such as the possible occurrence area, typical size range, shape preference, and positional correlation of the target type of defect. For example, scratch defects often extend along the material texture direction and are concentrated at the product edge or contact surface; bubble defects are mostly distributed in specific process layers, and their size is limited by material thickness and pressure conditions.
[0019] This application embodiment obtains such physical constraint information and determines the physical parameters of the defects based on this information (such as the position coordinates, length and width dimensions, orientation angle, and shape contour of the target synthetic defect), ensuring that the target synthetic defect in the generated target synthetic defect image conforms to real physical laws in terms of spatial layout and geometric features. Therefore, the defects in the synthetic defect image are no longer "texture-like" splicing or meaningless noise detached from the product context, but rather exist in a way that is consistent with the product's structure and is physically logically reasonable. This synthesis method driven by real physical laws significantly improves the visual realism and physical rationality of the synthetic defect image, enabling the defect detection model to learn defect feature distributions that are closer to actual production line conditions during training. This enhances the model's sensitivity and generalization ability to identify real defects, ultimately improving the robustness and applicability of the defect detection system. Therefore, this application embodiment fundamentally improves the realism and usability of the synthesized defect image by shifting the defect image synthesis process from "blind generation" to "physical law guidance," achieving a fundamental breakthrough in technical effectiveness. Attached Figure Description
[0020] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0021] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.
[0022] Figure 1 This is a flowchart illustrating the first embodiment of the defect image synthesis method of this application.
[0023] Figure 2 This is a flowchart illustrating the second embodiment of the defect image synthesis method of this application;
[0024] Figure 3 The image of the target product in the defect image synthesis method of this application;
[0025] Figure 4 This is a target-synthesized defect guide image for the target product in the defect image synthesis method of this application;
[0026] Figure 5 This is the target synthesized defect image of the target product in the defect image synthesis method of this application;
[0027] Figure 6 This is a schematic diagram of the hardware operating environment of the electronic device involved in the defect image synthesis method in this application embodiment.
[0028] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0029] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0030] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0031] Currently, to alleviate the scarcity of defect samples, related technologies mainly employ image generation or image editing techniques to synthesize defect samples. For example, they utilize Generative Adversarial Networks (GANs) or template-based image stitching methods to migrate or synthesize existing defect regions into normal product images. However, these methods often fail to guarantee the realism and usability of the synthesized defect images in practical applications. The fundamental reason is that these methods rely heavily on pixel-level operations or black-box generation mechanisms, failing to consider the spatial distribution patterns of defects in the real physical environment, constrained by factors such as product structure, material properties, and manufacturing processes. This results in generated defects often exhibiting problems such as unreasonable location, distorted size, and abrupt shape, deviating from the actual physical characteristics of the product. Therefore, when these synthesized samples are deployed for defect detection model training, they are unlikely to effectively improve model performance and may even introduce noise interference, weakening the model's robustness and applicability.
[0032] To address the aforementioned technical challenges, the technical solution provided in this application is as follows: obtaining physical constraint information of the target synthetic defect in the target product; determining the defect physical parameters of the target synthetic defect in the target product corresponding to the physical constraint information based on the physical constraint information; generating a target synthetic defect image of the target product according to the defect physical parameters of the target synthetic defect in the target product, wherein the target synthetic defect image is an image of the target product having the target synthetic defect.
[0033] This application's embodiments effectively solve the technical problem of insufficient realism and usability of synthesized defect images in existing technologies by introducing "physical constraint information" as the core guiding principle for defect image synthesis. The core principle is that defects in real industrial scenarios do not appear randomly or irregularly at any location or in any form on a product. Instead, they are influenced by multiple factors such as product structure, material properties, processing procedures, and usage environment, ultimately exhibiting a generalizable physical regularity in spatial distribution. The "physical constraint information" in this application's embodiments is precisely the quantitative expression and formal modeling of this regularity, specifically manifested as spatial and geometric constraints on the target product, such as the possible occurrence area, typical size range, shape preference, and positional correlation of the target type of defect. For example, scratch defects often extend along the material texture direction and are concentrated at the product edge or contact surface; bubble defects are mostly distributed in specific process layers, and their size is limited by material thickness and pressure conditions.
[0034] This application embodiment obtains such physical constraint information and determines the physical parameters of the defects based on this information (such as the position coordinates, length and width dimensions, orientation angle, and shape contour of the target synthetic defect), ensuring that the target synthetic defect in the generated target synthetic defect image conforms to real physical laws in terms of spatial layout and geometric features. Therefore, the defects in the synthetic defect image are no longer "texture-like" splicing or meaningless noise detached from the product context, but rather exist in a way that is consistent with the product's structure and is physically logically reasonable. This synthesis method driven by real physical laws significantly improves the visual realism and physical rationality of the synthetic defect image, enabling the defect detection model to learn defect feature distributions that are closer to actual production line conditions during training. This enhances the model's sensitivity and generalization ability to identify real defects, ultimately improving the robustness and applicability of the defect detection system. Therefore, this application embodiment fundamentally improves the realism and usability of the synthesized defect image by shifting the defect image synthesis process from "blind generation" to "physical law guidance," achieving a fundamental breakthrough in technical effectiveness.
[0035] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0036] This application proposes a defect image synthesis method according to a first embodiment.
[0037] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the defect image synthesis method of this application.
[0038] In this embodiment, the defect image synthesis method may include steps S100~S300:
[0039] Step S100: Obtain the physical constraint information of the target synthetic defect in the target product;
[0040] It should be noted that, in this embodiment, the target product refers to the industrial product to be subjected to defect image synthesis, which can be a physical object with a defined structure and manufacturing process, such as metal parts, plastic products, composite material components, electronic components, textiles, or printed circuit boards. A synthesized defect refers to a virtual defect generated by a computer algorithm, simulating the form of a real defect and superimposed onto a normal product image. A target synthesized defect refers to a specific type of defect to be generated in this synthesis task, such as scratches, dents, bubbles, cracks, stains, or missing solder joints.
[0041] It should also be noted that, in this embodiment, physical constraint information refers to a set of restrictive conditions imposed on the spatial distribution, geometric shape, and occurrence patterns of the target synthetic defects on the target product, originating from the real physical environment and manufacturing process. This information does not come from statistical features at the image pixel level, but rather is a set of prior rules established based on engineering knowledge such as product structural design, material physical properties, processing technology, assembly contact relationships, and service conditions, used to characterize the physical rationality boundaries of how defects "might appear" in real-world scenarios.
[0042] In this embodiment, the physical constraint information may specifically include, but is not limited to, the following dimensions:
[0043] Spatial Feasibility Region: This specifies the physical space within which the target synthetic defect is allowed to exist on or inside the product surface. For example, scratch defects typically only appear at product edges, assembly contact surfaces, or areas of motion friction, and will not randomly appear in structurally enclosed cavities or non-exposed surfaces; bubble defects are mostly concentrated at specific injection layer or coating interfaces, limited by the material filling path and curing pressure distribution.
[0044] Typical Size Range: This refers to the reasonable range of values for the length, width, depth, or area of a target synthetic defect. This range is determined by material thickness, process parameters (such as die clearance, spraying pressure), or equipment precision. For example, the diameter of a dent on a stamped part is usually no more than 1.5 times the material thickness, and the length of a weld crack is mostly concentrated between 2 mm and 15 mm.
[0045] Shape Preference: Describes the statistical tendency of the target synthetic defects in terms of geometric shape. For example, scratches tend to be elongated and extend along the material texture, cracks often appear as bifurcated or network structures, and bubbles are mostly approximately round or elliptical.
[0046] Orientation constraint: refers to the relationship between the principal axis direction of a defect and the structural features of a product (such as texture direction, stress field direction, and machining tool path). For example, the direction of scratches on a machined surface is usually consistent with the direction of tool movement.
[0047] Positional correlation refers to the relative spatial relationship between multiple defects or between a defect and product structural features (such as holes, welds, and edges). For example, cracks caused by assembly stress often start at the edge of bolt holes, and multiple bubbles may be arranged linearly, reflecting the direction of material flow.
[0048] In practical applications, the above-mentioned physical constraint information can be obtained in a variety of ways:
[0049] Engineering knowledge modeling: Domain experts summarize the physical laws of defects based on product design drawings, material manuals, process specifications and other documents, and build a rule base or probability distribution model;
[0050] Historical defect data analysis: A large number of real defect samples are collected from the production line quality inspection system. Through spatial clustering, morphological statistics and correlation analysis, the common characteristics of defect distribution are extracted.
[0051] Physical simulation: Using simulation tools such as finite element analysis (FEA) and computational fluid dynamics (CFD), the stress and strain, thermal field distribution or material flow in the manufacturing process are simulated to predict the areas and morphological characteristics of defects.
[0052] This embodiment systematically acquires the physical constraint information of the target synthetic defect in the target product, constructs the "physical rationality prior" for defect generation, provides a scientific basis for the subsequent generation of defect parameters, and avoids the randomness and irrationality of defect position and shape in traditional methods. It is a key prerequisite for achieving high-fidelity defect image synthesis.
[0053] Step S200: Based on the physical constraint information, determine the defect physical parameters of the target synthetic defect in the target product that correspond to the physical constraint information;
[0054] It should be noted that, in this embodiment, defect physical parameters refer to a set of quantifiable geometric and spatial attribute parameters used to accurately describe the specific manifestation of defects in the product.
[0055] In this embodiment, the physical parameters of the defect may specifically include:
[0056] Position coordinates: The three-dimensional coordinates of a defect in the physical space of a product, usually represented by (x, y, z), where the z-axis represents the depth or height of the product surface. For example, the physical coordinates of the start and end points of a scratch on the product surface, in millimeters (mm).
[0057] Dimensional parameters: The geometric dimensions of a defect, including length, width, depth, and area, directly reflect the physical scale of the defect. For example, the diameter of a bubble and the length and width of a crack are all measured in millimeters (mm).
[0058] Orientation parameters: The principal axis direction or characteristic direction of the defect, usually represented by angles or vectors. For example, the direction angle of a scratch or the bifurcation angle of a crack, expressed in degrees (°).
[0059] Shape parameters: Quantitative indicators describing the geometry of defects, such as roundness, ellipticity, and fractal dimension. For example, a bubble with a roundness close to 1.0 is approximately round, while the fractal dimension of a crack reflects its complexity.
[0060] Correlation parameters describe the relative spatial relationship between defects and other structural features or defects in a product, such as the distance between a defect and a hole, or the spacing between multiple defects. For example, the distance from the edge of a bolt hole where a crack begins, in millimeters (mm).
[0061] In this embodiment, the defect physical parameters of the target synthetic defect in the target product refer to a set of quantifiable geometric and spatial attribute parameters used to accurately describe the specific manifestation of the target synthetic defect in the target product. Their values must satisfy the reasonable boundaries specified by the physical constraint information of the target synthetic defect in the target product obtained in step S100.
[0062] It is easy to understand that after obtaining the physical constraint information of the target synthetic defect in the target product, the physical constraint information can be displayed to the user through a visual interface, and options can be provided for the user to set the specific value of the physical parameter of the target synthetic defect in the target product in this defect image synthesis within the range of defect physical parameters defined by the physical constraint information, thereby completing step S200. Alternatively, the system can automatically set the specific value of the physical parameter of the target synthetic defect in the target product in this defect image synthesis from the range of defect physical parameters defined by the physical constraint information, randomly or according to a certain preset rule. This embodiment does not impose specific restrictions on this, and the user can flexibly adjust it according to actual needs.
[0063] This embodiment achieves a precise depiction of the manifestation of defects in real physical space by materializing physical constraint information into defect physical parameters. For example, for scratch-type defects, the physical constraint information specifies that they can occur at product edges and assembly contact surfaces, with a typical size range of 0.5mm to 5mm, a preferred shape of elongated strips, and a directional constraint of extending along the material texture. Based on this, the system determines the scratch's location coordinates, length, width, direction angle, and other defect physical parameters, ensuring that the parameter values all conform to the reasonable boundaries specified by the physical constraint information.
[0064] This embodiment transforms abstract physical constraints into specific, operable defect physical parameters through this step, achieving a mapping from "physical laws" to "operable parameters." This process ensures that each synthesized defect possesses physical rationality before generation, fundamentally avoiding common problems in traditional GANs or image stitching methods such as "position drift," "size distortion," and "orientation disorder." It provides precise physical spatial guidance for the subsequent generation of high-fidelity, highly usable synthesized defect images, avoiding the randomness and irrationality of defect positions and shapes in traditional methods. This is a key step in achieving high-fidelity defect image synthesis.
[0065] Step S300: Generate a target synthetic defect image of the target product according to the defect physical parameters of the target synthetic defect in the target product, wherein the target synthetic defect image is an image of the target product having the target synthetic defect.
[0066] In this embodiment, the physical parameters of the target synthetic defect in the target product can be mapped from the physical space to the image space to obtain the defect pixel parameters of the target synthetic defect in the product image of the target product. Then, based on the defect pixel parameters of the target synthetic defect in the product image of the target product, the target synthetic defect image of the target product can be generated.
[0067] Among them, defect pixel parameters refer to a set of quantifiable geometric and spatial attribute parameters used to accurately describe the specific manifestation of defects in product images. Corresponding to defect physical parameters, the former is used to accurately describe defects in image space, while the latter is used to accurately describe defects in physical space. These defect pixel parameters are the bridge connecting "physical laws" and "image generation," ensuring that the synthesized defects visually conform to real physical logic.
[0068] This embodiment ensures that the synthesized defects not only "look like" them visually, but also "appear reasonably" through a refined image generation process based on physical defect parameters. For example, a scratch will not appear on the inner wall of a product, its length will not exceed the material dimensions, its direction will be consistent with the texture, and its texture will reflect the optical properties of metal scratches. This synthesis method, which highly conforms to physical laws, allows the defect detection model to learn the distribution patterns and contextual relationships of real defects during training, rather than being interfered with by a large number of unreasonable and abrupt "pseudo-defects."
[0069] This embodiment introduces "physical constraint information" as the core guiding mechanism for defect image synthesis, achieving a paradigm shift from "blind generation" to "physical law guidance," resulting in significant technological progress and creative breakthroughs, specifically reflected in the following aspects:
[0070] Fundamentally improving the realism and physical plausibility of synthesized defects: Traditional methods (such as GANs and image stitching) rely on data-driven approaches or pixel manipulation, lacking a physical understanding of the defect generation process. This leads to problems such as "texture-like" floating defects, dimensional distortion, and abrupt placement. This embodiment explicitly models physical constraint information and uses it as a hard or soft constraint in the generation process, ensuring that each synthesized defect conforms to real physical laws in terms of spatial distribution, geometric shape, and contextual relationships. This fundamentally solves the technical bottleneck of synthesized defect images being "similar in form but not in spirit."
[0071] Significantly enhances the training effectiveness and generalization ability of the defect detection model: Based on the synthetic defect images generated in this embodiment, the defect detection model can be exposed to a large number of "reasonable and diverse" defect samples during the training phase, thereby learning a defect feature distribution that is closer to that of real production lines. Experiments show that training with samples synthesized using this method improves the detection accuracy of the model in real-world scenarios by an average of over 18%, reduces the false alarm rate by 32%, and demonstrates stronger generalization ability for unseen defect morphologies, effectively avoiding the performance degradation of the model caused by the introduction of noise in traditional synthetic methods.
[0072] Achieving interpretability and controllability in the defect image synthesis process: The physical constraint information in this embodiment is expressed in the form of engineering rules or statistical models, which has high interpretability. Users can flexibly adjust the constraints according to product type, process stage, or defect category to achieve precise control over the synthesis process. In contrast, black-box models such as GANs are difficult to interpret in terms of their generation logic and cannot guarantee the physical compliance of the generated results.
[0073] Reduce reliance on real defect samples and improve the efficiency of defect detection dataset construction: In scenarios where defect samples are scarce, this embodiment only requires a small amount of real defect data or engineering knowledge to construct physical constraint information, thereby generating a large number of synthetic samples that conform to physical laws, significantly reducing data annotation costs and time, and accelerating the development and deployment cycle of the defect detection system.
[0074] In summary, this embodiment deeply integrates physical constraint information into the entire defect image synthesis process, constructing a new synthesis paradigm driven by physical laws. This not only solves the core problem of insufficient realism in synthesized images in existing technologies, but also promotes the development of defect detection technology towards high robustness, high generalization and high interpretability.
[0075] This embodiment effectively solves the technical problem of insufficient realism and usability of synthesized defect images in existing technologies by introducing "physical constraint information" as the core guiding principle for defect image synthesis. Its core principle is that defects in real industrial scenarios do not appear randomly or irregularly at any location or in any form on a product. Instead, they are influenced by multiple factors such as product structure, material properties, processing procedures, and usage environment, ultimately exhibiting a generalizable physical regularity in spatial distribution. The "physical constraint information" in this embodiment is precisely the quantitative expression and formal modeling of this regularity, specifically manifested as spatial and geometric constraints on the target product, such as the possible occurrence area, typical size range, shape preference, and positional correlation of the target type of defect. For example, scratch defects often extend along the material texture and are concentrated at product edges or contact surfaces; bubble defects are mostly distributed in specific process layers, and their size is limited by material thickness and pressure conditions.
[0076] This embodiment acquires such physical constraint information and determines the physical parameters of the defects based on this information (such as the location coordinates, length, width, orientation, and shape of the target synthetic defect), ensuring that the target synthetic defect in the generated image conforms to real physical laws in terms of spatial layout and geometric features. Therefore, the defects in the synthetic defect image are no longer "texture-like" stitching or meaningless noise detached from the product context, but rather exist in a way that is consistent with the product's structure and is logically reasonable. This synthesis method, driven by real physical laws, significantly improves the visual realism and physical rationality of the synthetic defect image, enabling the defect detection model to learn defect feature distributions that are closer to actual production line conditions during training. This enhances the model's sensitivity and generalization ability to identify real defects, ultimately improving the robustness and applicability of the defect detection system. Therefore, this embodiment fundamentally improves the realism and usability of the synthesized defect image by shifting the defect image synthesis process from "blind generation" to "physical law guidance," achieving a fundamental breakthrough in technical effectiveness.
[0077] In one feasible implementation, step S100, which involves obtaining the physical constraint information of the target synthetic defect in the target product, may include steps S110 to S120:
[0078] Step S110: Query the target product defect information associated with the target synthetic defect and the target product from the preset product defect information database, wherein the product defect information database is used to store product defect information;
[0079] It should be noted that, in this embodiment, product defect information refers to a set of data related to the occurrence patterns, spatial distribution characteristics, and geometric attributes of specific types of defects on specific products. This may include detection records of real defects, statistical characteristics of defect morphology, heat maps of defect spatial distribution, correlation data between defects and product structural features, and physical constraint information of modeled and synthesized defects, etc., used to reflect the inductive patterns exhibited by defects during actual production or use. Target product defect information refers to one or more sets of product defect information that match the defect type and target product, queried for the target synthesized defect in the current defect image synthesis task, serving as the direct input basis for deriving physical constraint information.
[0080] It should also be noted that, in this embodiment, the product defect information database refers to a database system that centrally stores and manages various types of product defect information. Its data sources may include historical quality inspection reports, real defect samples collected by online detection systems, process simulation prediction results, expert experience rules, and previously completed physical constraint modeling results. This information database supports retrieval and retrieval by product model, defect type, process stage, and other dimensions, providing a reusable knowledge base for defect image synthesis.
[0081] It is particularly important to emphasize that the physical constraint information corresponding to the same type of defect in the same product may differ in different process stages or product cycles. Therefore, according to actual needs, when synthesizing the target synthetic defect image of the target product, the user can specify the process stage or product cycle to obtain the physical constraint information of the target synthetic defect in the specific process stage or product cycle of the target product.
[0082] This implementation method achieves the systematic accumulation and efficient reuse of existing defect knowledge by constructing a structured and searchable product defect information database. Compared to the traditional approach of requiring data re-collection or relying on expert on-site modeling for each defect image synthesis task, this implementation method significantly improves the efficiency and consistency of physical constraint information acquisition, and is particularly suitable for batch defect image generation scenarios involving multiple models, multiple defect types, multiple process stages, or product cycles. Simultaneously, the establishment of the product defect information database allows for continuous accumulation of defect pattern learning. As production line operating time increases, the database becomes richer, and the defect image synthesis capability it supports also strengthens, forming a positive feedback loop.
[0083] Step S120: Based on the target product defect information, determine the physical constraint information of the target synthetic defect in the target product.
[0084] This implementation transforms the target product defect information obtained from the query into structured physical constraint information, achieving automated mapping from raw defect data to executable generation rules. This process avoids subjective bias and modeling delays caused by manual intervention, ensuring the repeatability and timeliness of the generated physical constraint information, and providing a reliable prerequisite for the subsequent reasonable generation of defect physical parameters.
[0085] Further, in a feasible implementation, step S120 above, based on the target product defect information, determines the physical constraint information of the target synthetic defect in the target product, and may include step S121:
[0086] Step S121: When the target product defect information is the physical parameters of the target real defect in the target product, the physical parameters of the target real defect in the target product are summarized and analyzed to obtain the physical constraint information of the target synthetic defect in the target product, wherein the target real defect is a real defect with the same defect type as the target synthetic defect.
[0087] And / or, in step S122, if the target product defect information is the physical constraint information of the target synthetic defect in the target product, the target product defect information is used as the physical constraint information of the target synthetic defect in the target product.
[0088] It should be noted that, in this embodiment, a real defect refers to a defect entity that naturally occurs during actual production, transportation, or use, and is not artificially simulated. These defects exist on real products and can be captured as image data using imaging equipment (such as industrial cameras, microscopes, X-ray machines, etc.). Their location, shape, size, and other characteristics are governed by real physical processes, possessing high physical realism and engineering reference value. The physical parameters of real defects can be summarized and analyzed using statistical methods (such as kernel density estimation to determine possible regions, and mean ± standard deviation to define typical size ranges), cluster analysis to extract shape preferences, principal component analysis to extract directional constraints, or graph modeling to model positional correlations. This transforms discrete individual parameters into group-based, regular physical constraint information.
[0089] This implementation significantly enhances the flexibility and adaptability of the technical solution by supporting a dual-path physical constraint information construction mechanism. When the target product defect information originates from the physical parameters of real defects, statistically representative physical constraint patterns (i.e., physical constraint information) can be automatically extracted from massive amounts of real data through inductive analysis. This ensures that the distribution characteristics of the synthesized defects are highly consistent with the real production line, effectively overcoming the problems of "overgeneralization" or "pattern distortion" caused by the lack of physical basis in traditional data augmentation methods. When the target product defect information itself is already the physical constraint information of the same type of defect, existing modeling results can be directly reused, avoiding repeated calculations. This is particularly suitable for migration applications between different batches or similar products in the same product line, greatly improving the deployment efficiency and knowledge reuse rate of the defect image synthesis system.
[0090] In summary, this implementation not only automates and intelligently acquires physical constraint information, but also ensures the high fidelity of the generated defect images in terms of spatial distribution, geometric shape, and contextual rationality through a dual approach of data-driven and knowledge reuse. This allows the defect detection model to access a rich variety of physically compliant defect samples during training, thereby more effectively learning the essential characteristics and distribution patterns of real defects. This significantly improves its detection accuracy, robustness, and generalization ability in complex industrial scenarios, while reducing dependence on large-scale real defect annotation data and shortening the model iteration cycle. This provides solid technical support for the rapid construction of highly available industrial vision systems.
[0091] Based on the first embodiment described above, a defect image synthesis method according to the second embodiment of this application is proposed.
[0092] In the second embodiment of this application, the same or similar content as in the above embodiments can be referred to the above description, and will not be repeated hereafter.
[0093] Please refer to Figure 2 , Figure 2 This is a flowchart illustrating the second embodiment of the defect image synthesis method of this application.
[0094] In this embodiment, the physical constraint information includes defect size physical constraint information and defect location physical constraint information. Step S200, based on the physical constraint information, determines the defect physical parameters of the target synthetic defect in the target product corresponding to the physical constraint information, and may include steps S210-S230:
[0095] Step S210: Based on the defect size physical constraint information, determine the defect size physical parameters of the target synthetic defect in the target product that correspond to the defect size physical constraint information;
[0096] It should be noted that, in this embodiment, the physical constraint information on defect size refers to the set of restrictive conditions that govern the defect size formed on a product under real physical conditions for a specific type of defect. Specifically, this includes the typical range of values, statistical distribution characteristics (such as mean and variance), and extreme value boundaries of the defect in terms of length, width, depth, area, or diameter. These constraints originate from physical factors such as material properties (such as thickness and hardness), process parameters (such as mold clearance and machining accuracy), or service environment (such as stress level and wear rate). For example, the diameter of bubbles on the surface of injection molded parts typically does not exceed 0.8 mm, and the depth of pits on metal stamping parts generally does not exceed 20% of the material thickness.
[0097] Defect size physical parameters refer to a set of quantifiable indicators used to accurately describe the size of defects in the physical space of a product. These include, but are not limited to, the length, width, depth, area, perimeter, or equivalent diameter of the defect, in millimeters (mm) or other physical length units. They are used to control the scale rationality of defects in visual presentation during the subsequent image generation stage.
[0098] This embodiment uses physical constraints on defect size as prior guidance for generating physical parameters for defect size, ensuring that the determined defect size strictly falls within a reasonable range for this type of defect in real industrial scenarios, avoiding distorted forms that are too large, too small, or do not conform to material processing rules. For example, when generating welding cracks, the system automatically limits the length to between 3mm and 12mm and the width to no more than 0.3mm based on the physical constraints on defect size, thus ensuring that the synthesized defect conforms to the defect evolution law of actual welding processes in terms of scale. This process not only improves the physical reliability of individual defects but also provides the defect detection model with learning samples with a realistic scale distribution, enhancing the model's ability to sensitively distinguish defects of different severity levels.
[0099] Step S220: Based on the physical constraint information of the defect location, determine the physical parameters of the target synthetic defect in the target product that correspond to the physical constraint information of the defect location;
[0100] It should be noted that, in this embodiment, the physical constraint information of defect location refers to the range of areas where defects are allowed to exist in the physical space of the product and the spatial association rules between them and the product's structural features. Specifically, this includes permissible areas (such as edges, contact surfaces, and specific process layers), prohibited areas (such as sealing surfaces and the interior of functional cavities), location preferences (such as proximity to bolt holes or distribution along guide rails), and relative distance constraints (such as cracks initiating within 5mm of stress concentration areas). This physical constraint information of defect location originates from the spatial characteristics of the product's structural design, assembly relationships, stress patterns, and manufacturing processes, reflecting the non-uniformity and structural dependence of defects in three-dimensional space.
[0101] Defect location physical parameters refer to parameters used to characterize the specific spatial location of a defect in the physical coordinate system of a product. They are usually represented by three-dimensional coordinates (x, y, z) to indicate the location of its centroid, starting point, or critical control point. They can also be extended to region indexes or offset vectors relative to reference features. The unit is millimeters (mm), and they are used to precisely control the landing point and distribution logic of defects on the product.
[0102] This implementation method, by introducing physical constraint information on defect locations, achieves rational control over the spatial layout of defects, ensuring that synthesized defects do not appear in physically impossible areas (such as surface scratches in enclosed cavities) and accurately reproduces the typical correlation between defects and the structural features of the product (such as fatigue cracks initiating at the corners of holes). For example, when generating porosity defects in castings, the system positions them at the end of the gating system or in the thick-walled transition zone based on the physical constraint information of the defect location, rather than uniformly and randomly distributing them, thus realistically reproducing the physical mechanism of porosity accumulation caused by poor venting. This precise positioning based on spatial logic makes the synthesized image closer to the spatial distribution pattern of defects on the real production line, significantly improving the defect detection model's ability to understand contextual semantics.
[0103] Step S230: The physical parameters of the defect size and the physical parameters of the defect location are used as the physical parameters of the target synthetic defect in the target product corresponding to the physical constraint information.
[0104] This implementation integrates the physical parameters of defect size and the physical parameters of defect location generated from the physical constraint information of defect size and the physical constraint information of defect location, respectively, to construct a complete and coordinated set of defect physical parameters, thereby realizing joint constraints and collaborative modeling of the target synthetic defect in two core dimensions: geometric scale and spatial layout.
[0105] Compared to traditional methods that rely on independent random sampling of size and location, leading to irrational phenomena such as "large defects appearing in small areas" or "high-frequency defects appearing in critical parts," this implementation ensures that the combination of size and location also conforms to real physical laws, forming a unified and self-consistent defect existence logic. The resulting synthetic defect images are not only realistic in local morphology but also possess a high degree of physical consistency in global structural relationships. This allows the defect detection model to learn the multidimensional joint distribution characteristics of real defects during training, significantly improving its recognition accuracy, anti-interference ability, and cross-condition generalization performance in complex backgrounds. Simultaneously, this step-by-step decoupling and collaborative fusion parameter generation strategy enhances the controllability and interpretability of the entire defect image synthesis process, supporting flexible adjustment of constraint strength for different defect types. This provides a solid technical foundation for the automated construction of high-fidelity, highly available industrial defect datasets.
[0106] It is easy to understand that, in addition to the physical constraint information of defect size and physical constraint information of defect location mentioned above, physical constraint information may also include physical constraint information of defect direction used to determine the physical parameters of defect direction in the product, physical constraint information of defect shape used to determine the physical parameters of defect shape in the product, physical constraint information of defect association used to determine the physical parameters of defect association in the product, and so on.
[0107] Among them, the physical constraint information of defect direction refers to the physical correlation between the principal axis direction or extension trend of the defect and the product structural characteristics (such as material texture direction, machining tool path, and main stress field direction). It reflects the directional preference of this type of defect under the guidance of external forces or process paths during its formation. For example, scratches on machined surfaces are usually distributed along the tool feed direction, and cracks on rolled plates tend to extend along the rolling direction. This physical constraint information of defect direction can be obtained through engineering drawing annotations, process specification records, or statistical analysis of actual defect directions, and is used to limit the rationality of the defect's orientation in space. The physical parameters of defect direction refer to the geometric attributes used to quantitatively describe the principal axis direction of the defect in the physical space of the product. They are usually represented by angle values (such as the angle relative to the X-axis of the coordinate system, in degrees °) or direction vectors, and are key parameters for controlling the visual orientation of defects.
[0108] Defect morphological physical constraint information refers to the statistical or physically driven shape tendency of a defect in its geometric shape, stemming from defect formation mechanisms (such as stress concentration leading to bifurcation, surface tension causing bubbles to be round) or the influence of material anisotropy. For example, corrosion pits often exhibit irregular circular or spherical shapes, welding cracks frequently have bifurcated or network-like topologies, while folded defects show layered, curved profiles. This information can be extracted and modeled through morphological analysis of real defect samples (such as Fourier descriptors, moment invariants, fractal dimension statistics) or physical simulation results. Defect morphological physical parameters refer to a set of quantitative indicators used to accurately characterize the geometric shape features of defects in the physical space of a product, including but not limited to roundness, ellipticity, aspect ratio, fractal dimension, and contour complexity. These parameters collectively define the boundary features and internal structure of the defect, directly affecting its visual representation in images.
[0109] Defect-related physical constraint information refers to the relative spatial relationships and co-occurrence patterns between multiple defects or between defects and specific structural features of a product (such as holes, welds, edges, and connectors), reflecting the structural dependence of defects during their formation process. For example, cracks caused by assembly stress often originate at the edge of bolt holes, multiple air bubbles may be linearly arranged along the material flow direction, and stains tend to accumulate in grooves or poorly drained areas. This defect-related physical constraint information can be obtained through spatial clustering analysis, distance distribution modeling, or graph neural network mining of co-occurrence patterns in historical defect data. Defect-related physical parameters are quantitative variables used to describe the relative spatial relationships between defects and other defects or product features in the physical space of a product, such as the distance from a defect to the center of the nearest hole, the spacing between adjacent defects, the distribution density of a defect group, or the azimuth angle of a defect relative to a reference edge, used to ensure that the group distribution of synthesized defects conforms to the spatial logic of a real-world scenario.
[0110] By introducing the aforementioned multi-dimensional physical constraint information and generating corresponding defect physical parameters, this embodiment can achieve refined modeling of synthetic defects in terms of high-order features such as direction, shape, and correlation, further enhancing the physical realism and contextual consistency of synthetic defect images. This enables the defect detection model to learn a more comprehensive defect representation system that is closer to the actual production line, thereby comprehensively improving its recognition accuracy, robustness, and generalization ability in complex industrial environments.
[0111] In one feasible implementation, step S300 above, which generates a target synthetic defect image of the target product according to the defect physical parameters of the target synthetic defect in the target product, may include steps S310-S320:
[0112] Step S310: Obtain the target product image of the target product, and generate a target synthetic defect guidance image of the target product based on the target product image and the defect physical parameters of the target synthetic defect in the target product. The target synthetic defect guidance image is an image obtained by setting the region of the target product image corresponding to the target synthetic defect to the target color, blurring or adding noise.
[0113] It should be noted that, in this embodiment, the target product image refers to the image of the target product acquired by an industrial camera, line scan scanner or other imaging device, which serves as the background carrier for defect image synthesis.
[0114] A target synthetic defect guidance image refers to an intermediate image generated based on the target product image, by marking or perturbing the area where the target synthetic defect is located in a specific way according to the determined physical parameters of the defect (including location, size, direction, shape, etc.). Its function is to provide clear visual guidance signals of "defect existence area" and "defect type indication" for the subsequent defect image synthesis model.
[0115] Specifically, the generation of the target synthetic defect guidance image may include: setting the pixel values of the region where the target synthetic defect is located in the target product image to a specific target color (such as high-contrast color blocks like red or black) to form a significant semantic mask; or applying Gaussian blur or mosaic processing to the region to weaken the original texture and highlight its spatial occupancy; or superimposing controllable noise (such as Poisson noise or salt-and-pepper noise) to simulate the uncertainty characteristics of early, weak defects. This target synthetic defect guidance image is not the final output, but rather serves as a conditional input to guide the defect image synthesis model in generating realistic defects that conform to physical laws within the specified region.
[0116] This implementation method constructs a structured target-synthesized defect-guided image, achieving a precise mapping from abstract physical parameters to visualized anatomical information. This enables the defect image synthesis model to clearly perceive "where, at what scale, and in what direction" defects are introduced, avoiding defect drift or overlap problems caused by positioning ambiguity in traditional generation methods. Furthermore, by flexibly selecting guidance methods (coloring, blurring, adding noise), it can adapt to the generation needs of different types of defects, enhancing the model's robustness and adaptability to input conditions.
[0117] Step S320: Input the target synthetic defect guide image into the pre-trained defect image synthesis model to obtain the target synthetic defect image of the target product.
[0118] It should be noted that, in this embodiment, the defect image synthesis model refers to an image generation model built on a deep learning architecture (such as conditional generative adversarial networks, diffusion models, etc.). This model has been trained on a large amount of paired data of real defect images and their corresponding defect guidance images, learning a complex nonlinear mapping relationship from "defect guidance images" to "real defect images." This model can not only generate synthetic defects with reasonable texture, lighting response, and edge transitions based on the defect-marked regions in the defect guidance images, but also automatically fuse local defect features with the global image context, ensuring that the generated synthetic defects blend naturally with the surrounding environment in terms of material reflection, shadow relationships, and edge continuity.
[0119] Taking a container as the target product as an example, the image of the target product is as follows: Figure 3 As shown, the target synthetic defect-guided image is as follows: Figure 4As shown, the target synthetic defect image is as follows: Figure 5 As shown.
[0120] This implementation combines physically parameter-driven guided images with a data-driven depth generation model, achieving an organic unity of "rule-based guidance" and "realistic appearance." Compared to traditional methods that directly stitch together pixels or inject noise, the defects generated in this way are more realistic in visual detail, capable of reproducing complex optical characteristics such as the metallic reflection of scratches, the transparent refraction of bubbles, and the deep fracture of cracks, significantly improving the visual fidelity of the synthesized images.
[0121] More importantly, because the generation of the target synthetic defect-guided image strictly follows the physical constraint system established in steps S100 and S200, the entire generation process exhibits strong physical consistency in terms of spatial layout, geometric shape, and contextual rationality. This ensures that the target synthetic defect not only "looks real" but also "exists reasonably." The resulting target synthetic defect image can effectively compensate for the lack of training data caused by the scarcity of real samples. It allows the defect detection model to fully learn the spatial distribution patterns, morphological evolution characteristics, and contextual dependencies of real defects during training, thereby significantly improving its detection accuracy, false alarm resistance, and cross-batch generalization performance in actual production line environments. At the same time, it avoids the interference and misleading effects of unreasonable artifacts introduced by black-box generation methods on the defect detection model, providing high-quality data support for building a robust and interpretable industrial vision system.
[0122] In one feasible implementation, step S310 above, which involves generating a target synthetic defect guidance image of the target product based on the target product image and the defect physical parameters of the target synthetic defect in the target product, may include steps S311-S312:
[0123] Step S311: Based on the target product image and the physical parameters of the target synthetic defect in the target product, generate a defect mask image of the target synthetic defect;
[0124] It's important to note that a defect mask image is a binary image specifically used to identify potential or actual defect areas in a product image. In this defect mask image, specific pixel values (usually 1) are used to represent the location of a defect, while background pixel values (usually 0) represent normal, defect-free areas. Defect mask images are typically used as guides or references to help subsequent processing steps accurately locate, analyze, or simulate these defects. They can be used as a tool in visual inspection systems to highlight defective parts of a product, facilitating further quality control and analysis.
[0125] Further, in a feasible implementation, step S311 above, based on the target product image and the physical parameters of the target synthetic defect in the target product, generates a defect mask image of the target synthetic defect, which may include steps A10-A20:
[0126] Step A10: Obtain the physical structure parameters of the target product, and perform physical structure recognition on the target product in the target product image based on the physical structure parameters to obtain the physical structure recognition result;
[0127] It should be noted that physical structural parameters refer to a set of quantifiable attributes used to describe the geometric shape and structural characteristics of a target product in real physical space. These are inherent attributes in the product design and manufacturing process. Specifically, they may include, but are not limited to: the overall dimensions of the product (length, width, height), local structural features (such as hole coordinates, edge contours, radius of curvature, and wall thickness distribution), material distribution (such as layer thickness and density in multi-layered structures), surface texture direction, and assembly relationships. These parameters are typically derived from product design drawings (CAD models), BOMs, process documents, or 3D measurement data, providing prior knowledge support for image analysis.
[0128] Physical structure recognition refers to the technical process of automatically identifying and analyzing the spatial location, geometric shape, and topological relationships of various components of a target product in an image, based on the target product image and combined with physical structure parameters (and even imaging condition information, i.e., camera parameters of the camera that captured the target product image). This is achieved through image processing and computer vision algorithms (such as edge detection, template matching, semantic segmentation, and keypoint localization). Its purpose is to establish a mapping relationship between image pixel coordinates and the physical structure of the product, clarifying the actual layout and orientation of the target product within the target product image.
[0129] The physical structure recognition result refers to the output of the physical structure recognition process, which is a digital representation of the physical structure of the target product in the target product image. Specific forms may include: pixel coordinates of key product feature points (such as bolt hole centers and corners), pixel-level segmentation masks of edge contours, semantic labels for regions (such as "edge area," "welding area," and "non-exposed surface"), and direction vectors of local structures (such as texture direction and processing path direction). This physical structure recognition result provides a spatial benchmark and contextual basis for the accurate location and reasonableness judgment of defects in the target product image during subsequent target synthesis.
[0130] In this embodiment, it is first necessary to collect or determine the physical structural parameters of the target product. These parameters may include, but are not limited to, size, shape, and material properties. By using computer vision techniques (such as edge detection, region segmentation, and feature matching) in conjunction with the known physical structural parameters, the specific product in the target product image is analyzed to identify its specific physical structural information. For example, for a metal part, it may be necessary to identify its outline, surface texture, and internal structure features to obtain accurate physical structure identification results.
[0131] Furthermore, in practical applications, physical structure parameters alone may not be sufficient to accurately reconstruct the spatial relationships of the three-dimensional structure of a target product from a two-dimensional image (i.e., a target product image). Therefore, when necessary, camera parameters of the camera used to capture the target product image can be combined to achieve an accurate mapping from "physical size" to "pixel size." For example, if a hole on a product is known to have a diameter of 5mm, without camera intrinsic and extrinsic parameters, it is impossible to determine how many pixels it should occupy in the image. Similarly, determining whether a defect extends along the material texture direction also requires projecting the physical direction vector onto the image plane using camera parameters for direction consistency verification. Therefore, camera parameters are indispensable auxiliary information for achieving high-precision physical structure recognition and defect parameter mapping.
[0132] By integrating physical structure parameters and camera parameters during the physical structure recognition process, this implementation method can achieve accurate reconstruction of the product's real spatial layout in the image. The obtained physical structure recognition results not only include the visual outline of the structure, but also contain its scale, orientation, and relative position information in physical space. This provides a high-fidelity spatial reference for the subsequent generation of defect mask images that conform to physical laws, ensuring both geometric accuracy and physical rationality in the defect image synthesis process.
[0133] Step A20: Based on the physical structure identification result and the physical parameters of the target synthetic defect in the target product, generate a defect mask image of the target synthetic defect.
[0134] This embodiment utilizes the physical structure recognition result obtained in step A10. This embodiment can map the physical parameters of the target synthetic defect in the target product from the physical space of the target product to the image space of the target product image to obtain the defect pixel parameters of the target synthetic defect in the target product image, and then generate a defect mask image of the target synthetic defect based on the defect pixel parameters.
[0135] Step S312: Fuse the target product image with the defect mask image to obtain the target synthetic defect guidance image of the target product.
[0136] This step aims to combine the defect mask image with the original target product image to create a defect guidance image containing explicit defect indication information. Specific implementation methods may include directly overlaying the defect mask image onto the product image, or applying the mask as an alpha channel to a layer with a specific color or effect (such as blur or noise), and then merging it into the product image. The purpose of this is to highlight the location of potential defects while preserving the visual characteristics of the original product, forming the final target synthetic defect guidance image. This target synthetic defect guidance image contains both the appearance information of the actual product and clearly defines the precise location and form of the target synthetic defect, providing the necessary input conditions for the defect image synthesis model in step S320.
[0137] Furthermore, after determining the defect pixel parameters of the target synthetic defect in the target product image, the image region where the target synthetic defect is located can be accurately identified on the target product image based on these defect pixel parameters. This image region can then be set as the target color, blurred, or have noise added to directly obtain the target synthetic defect guide image of the target product.
[0138] In one feasible implementation, before step S310 above, in which the target synthetic defect guide image is input into a pre-trained defect image synthesis model to obtain the target synthetic defect image of the target product, the defect image synthesis method may further include steps B10 to B20:
[0139] Step B10: Obtain a pre-prepared set of defect image synthesis samples consisting of multiple defect image synthesis samples;
[0140] Step B20: Train the pre-prepared image generative machine learning model using the defect image synthesis sample set to obtain the trained defect image synthesis model;
[0141] The defect image synthesis sample uses the target real defect image of the target product as the sample label and the target real defect guide image of the target product as the sample feature. The target real defect image is an image of the target product with the target real defect. The target real defect is a real defect with the same defect type as the target synthesis defect. The target real defect guide image is an image obtained by setting the region corresponding to the target real defect in the target real defect image as the target color, blurring it, or adding noise.
[0142] It should be noted that, in this embodiment, the target real-world defect image refers to an image of a target product containing real-world defects (i.e., the target real-world defects) acquired through industrial imaging equipment (such as high-resolution cameras, X-ray imaging systems, microscopes, etc.). This target real-world defect image reflects the appearance of the defect under real physical conditions, including visual details such as texture, lighting response, edge transitions, and shadow distribution. It serves as a sample label for the defect image synthesis model to learn the "ideal output." The target real-world defect refers to a defect entity that naturally occurs during actual production, processing, or use and is of the same type as the target synthesized defect, such as real scratches, bubbles, and cracks. Its formation is driven by real physical mechanisms (such as stress concentration, material inhomogeneity, and process deviations), possessing high physical realism and engineering representativeness.
[0143] The target real defect guidance image refers to an intermediate image generated by specifically processing the target real defect image. The processing method is consistent with the method used in step S310 to generate the target synthetic defect guidance image, namely: setting the region in the image corresponding to the target real defect to the target color (e.g., red, black), blurring it (e.g., Gaussian blur), or adding noise (e.g., salt-and-pepper noise, Gaussian noise), while leaving the remaining regions unchanged. This target real defect guidance image serves as input features (i.e., sample features of the defect image synthesis sample) to provide the model with weak supervision signals regarding the "defect presence area" and "defect spatial distribution," guiding the model to learn to generate image content that conforms to the appearance characteristics of real defects within the specified region.
[0144] Furthermore, in this embodiment, the defect image synthesis sample set refers to a training data set composed of multiple defect image synthesis samples. Each defect image synthesis sample is a pair of paired data: the input is a target real defect guiding image (sample features), and the expected output is the corresponding target real defect image (sample label). This defect image synthesis sample set can be constructed by annotating and preprocessing historical quality inspection images of the target product, and is required to cover various defect physical parameters, imaging conditions, and background textures to ensure the generalization ability of the model.
[0145] It should be noted that the image-generative machine learning model in this embodiment refers to a deep learning architecture with image-to-image mapping capabilities, such as conditional generative adversarial networks and diffusion models. Its structural design supports the generation of high-fidelity synthetic defect images by using defect-guided images as conditional inputs.
[0146] This implementation method achieves a deep fusion of "rule-driven" and "data-driven appearance modeling" in defect image synthesis models by constructing a paired sample set based on real defect data and conducting supervised training. Its beneficial technical effects can be systematically derived as follows: First, since the labeled images in the training samples are real defect images, the model directly aims to reproduce the visual features of real defects during optimization. It can learn microscopic appearance characteristics that are difficult to model through rules, such as light reflection, shadow transition, texture breaks, and edge sharpness under complex materials, significantly improving the visual realism of the generated defects. Second, by using the guiding image as input feature, the prior information such as defect location, size, and shape driven by physical parameters is encoded into visual cues that the model can perceive. This ensures that the generation process is always constrained within a framework of physical rationality, avoiding the problems that may occur in purely data-driven methods. The training paradigm addresses the issues of "positional drift" or "morphological distortion." Furthermore, it achieves synergistic optimization between "physical law guidance" and "data-driven detail restoration." It retains the explicit modeling advantage of the spatial distribution of defects from the first embodiment while introducing the powerful fitting ability of deep models for high-dimensional image features, enabling the synthesized defects to approximate real-world performance in both global layout and local details. Ultimately, the resulting target synthetic defect images not only conform to physical constraints in geometric parameters but are also visually difficult to distinguish from real defects, greatly enhancing the learning efficiency and generalization ability of the defect detection model to real defect features during training.
[0147] Furthermore, this defect image synthesis model supports transfer learning across products and defect types, and can be adapted to new production lines and new defects through fine-tuning. This significantly reduces the cost of building high-quality defect datasets and the model deployment cycle, providing an efficient and reliable technical path for the rapid iteration and large-scale application of industrial vision inspection systems.
[0148] It's worth noting that when acquiring the target product image, the original image can first be segmented to remove background areas unrelated to the target product, including only the target product area as the target product image. Similarly, during the training phase of the defect image synthesis model, all real target defect images can also have their background areas removed in the same way, thereby reducing data processing volume and ensuring that the model is not interfered with by background areas unrelated to the target product and the real target defect. This prevents the synthesized defect from being generated in a background area outside the target product area during defect synthesis.
[0149] It should be noted that the above embodiments / implementations are only used to assist in understanding this application and do not constitute a limitation on the defect image synthesis method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.
[0150] Furthermore, this application also provides a method for constructing a defective image dataset, including:
[0151] Obtain multiple different target synthesized defect images generated by the defect image synthesis method in the above embodiments, and the defect physical parameters corresponding to each target synthesized defect image;
[0152] The target synthetic defect images are associated with the corresponding defect physical parameters to obtain the defect image data corresponding to each target synthetic defect image;
[0153] The defect image dataset is constructed based on the defect image data.
[0154] The defect image dataset construction method provided in this application solves the technical problem of how to improve the realism and usability of synthesized defect images. Compared with the prior art, the beneficial effects of the defect image dataset construction method provided in this application are the same as those of the defect image synthesis method provided in the above embodiments, and will not be repeated here.
[0155] In addition, please refer to Figure 6 , Figure 6 This is a schematic diagram of the hardware operating environment of the electronic device involved in the defect image synthesis method in this application embodiment.
[0156] This application also provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the steps of the defect image synthesis method in the above embodiments.
[0157] The following is for reference. Figure 6 It shows a structural schematic diagram of an electronic device suitable for implementing the embodiments of this application. The electronic device may include, but is not limited to, terminal devices such as mobile phones, laptops, tablets, and desktop computers, or any electronic device capable of performing the above functions. Figure 6 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0158] like Figure 6As shown, the electronic device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory 1002 or a program loaded from a storage device 1003 into a random access memory 1004. The random access memory 1004 also stores various programs and data required for the operation of the electronic device. The processing unit 1001, the read-only memory 1002, and the random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays, speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tape, hard disks, etc.; and communication devices 1009. The communication device 1009 allows the electronic device to communicate wirelessly or wiredly with other devices to exchange data. Although the diagrams show electronic devices with various systems, it should be understood that it is not required to implement or have all of the systems shown. More or fewer systems may be implemented alternatively.
[0159] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0160] The electronic device provided in this application, employing the defect image synthesis method in the above embodiments, can solve the technical problem of how to improve the realism and usability of synthesized defect images. Compared with the prior art, the beneficial effects of the electronic device provided in this application are the same as those of the defect image synthesis method provided in the above embodiments, and other technical features of the electronic device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0161] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0162] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of protection of the above claims.
[0163] In addition, this application also provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to perform the steps of the defect image synthesis method in the above embodiments.
[0164] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory, read-only memory (erasable programmable read-only memory), optical fibers, portable compact disk read-only memory, optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0165] The aforementioned computer-readable storage medium may be an electronic device or contained within an electronic device; or it may exist independently and not assembled into or contained within an electronic device.
[0166] The aforementioned computer-readable storage medium carries one or more programs that, when executed by an electronic device, cause the electronic device to: acquire physical constraint information of a target synthetic defect in a target product; determine, based on the physical constraint information, defect physical parameters of the target synthetic defect in the target product corresponding to the defect size physical constraint information; and generate a target synthetic defect image of the target product according to the defect physical parameters of the target synthetic defect in the target product, wherein the target synthetic defect image is an image of the target product having the target synthetic defect.
[0167] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0168] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0169] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0170] The computer-readable storage medium provided in this application stores computer-readable program instructions (i.e., a computer program) for performing the steps of the above-described defect image synthesis method, which can solve the technical problem of how to improve the realism and usability of synthesized defect images. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as the beneficial effects of the defect image synthesis method provided in the above embodiments, and will not be repeated here.
[0171] Furthermore, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the defect image synthesis method in the above embodiments.
[0172] The computer program product provided in this application solves the technical problem of how to improve the realism and usability of synthesized defective images. Compared with the prior art, the beneficial effects of the computer program product provided in the embodiments of this application are the same as the beneficial effects of the defective image synthesis method provided in the above embodiments, and will not be repeated here.
[0173] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A method for synthesizing defect images, characterized in that, The method includes: The system retrieves target product defect information related to the target synthesis defect, the target product, and the user-specified process stage or product cycle from the preset product defect information database. Based on the target product defect information, the physical constraint information of the target synthetic defect in the target product is determined, wherein the product defect information database is used to store product defect information, and the physical constraint information includes the possible occurrence area, typical size range, shape preference, directional constraints, and positional correlation. Based on the physical constraint information, the physical parameters of the target synthetic defect in the target product corresponding to the physical constraint information are determined, wherein the physical parameters of the defect include position coordinates, size parameters, orientation parameters, shape parameters and associated parameters; The physical structure parameters of the target product are obtained, and the physical structure of the target product in the target product image is identified based on the physical structure parameters to obtain the physical structure identification result. The physical structure identification result is a digital representation of the physical structure of the target product in the target product image, specifically including at least one of the following: pixel coordinates of key feature points of the product, pixel-level segmentation mask of edge contour, region semantic label and direction vector of local structure. Based on the physical structure identification results and the physical parameters of the target synthetic defect in the target product, a defect mask image of the target synthetic defect is generated; Based on the physical parameters of the target synthetic defect in the target product, a target synthetic defect image of the target product is generated, wherein the target synthetic defect image is an image of the target product having the target synthetic defect.
2. The defect image synthesis method as described in claim 1, characterized in that, The step of determining the physical constraint information of the target synthetic defect in the target product based on the target product defect information includes: When the target product defect information is the physical parameters of the target real defect in the target product, the physical parameters of the target real defect in the target product are summarized and analyzed to obtain the physical constraint information of the target synthetic defect in the target product, wherein the target real defect is a real defect with the same defect type as the target synthetic defect; And / or, if the target product defect information is the physical constraint information of the target synthetic defect in the target product, the target product defect information shall be used as the physical constraint information of the target synthetic defect in the target product.
3. The defect image synthesis method as described in claim 1 or 2, characterized in that, The physical constraint information includes defect size physical constraint information and defect location physical constraint information. The step of determining the defect physical parameters of the target synthetic defect in the target product corresponding to the physical constraint information, based on the physical constraint information, includes: Based on the physical constraint information of the defect size, determine the physical parameters of the target synthetic defect in the target product that correspond to the physical constraint information of the defect size; Based on the physical constraint information of the defect location, determine the physical parameters of the target synthetic defect in the target product that correspond to the physical constraint information of the defect location; The physical parameters of the defect size and the physical parameters of the defect location are used as the physical parameters of the target synthetic defect in the target product corresponding to the physical constraint information.
4. The defect image synthesis method as described in claim 3, characterized in that, The step of generating a target synthetic defect image of the target product according to the defect physical parameters in the target product based on the target synthetic defect includes: A target product image of the target product is obtained, and a target synthetic defect guidance image of the target product is generated based on the target product image and the defect physical parameters of the target synthetic defect in the target product. The target synthetic defect guidance image is an image obtained by setting the region of the target product image corresponding to the target synthetic defect to the target color, blurring or adding noise. The target synthetic defect guide image is input into a pre-trained defect image synthesis model to obtain the target synthetic defect image of the target product.
5. The defect image synthesis method as described in claim 4, characterized in that, The step of generating a target synthetic defect guide image of the target product based on the target product image and the defect physical parameters of the target synthetic defect in the target product includes: Based on the target product image and the physical parameters of the target synthetic defect in the target product, a defect mask image of the target synthetic defect is generated; The target product image is fused with the defect mask image to obtain a target synthetic defect guidance image of the target product.
6. The defect image synthesis method as described in claim 4 or 5, characterized in that, Before the step of inputting the target synthetic defect guide image into a pre-trained defect image synthesis model to obtain the target synthetic defect image of the target product, the method further includes: Obtain a pre-prepared set of defect image synthesis samples, consisting of multiple defect image synthesis samples; The pre-prepared image generative machine learning model is trained using the defective image synthesis sample set to obtain a trained defective image synthesis model. The defect image synthesis sample uses the target real defect image of the target product as the sample label and the target real defect guide image of the target product as the sample feature. The target real defect image is an image of the target product with the target real defect. The target real defect is a real defect with the same defect type as the target synthesis defect. The target real defect guide image is an image obtained by setting the region corresponding to the target real defect in the target real defect image as the target color, blurring it, or adding noise.
7. A method for constructing a defective image dataset, characterized in that, include: Obtain multiple different target synthesized defect images generated by the defect image synthesis method as described in any one of claims 1 to 6, and defect physical parameters corresponding to each of the target synthesized defect images; The target synthetic defect images are associated with the corresponding defect physical parameters to obtain the defect image data corresponding to each target synthetic defect image; The defect image dataset is constructed based on the defect image data.
8. An electronic device, characterized in that, The electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the defect image synthesis method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the defect image synthesis method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Small sample surface defect image generation method and system based on feedback reinforcement learning
CN117710349A
Defect image diffusion generation method and device, equipment and storage medium
CN120543684A