Part surface quality detection method, device, equipment and medium
By simulating the specific recognition and physical diffusion dynamics of the biological immune system, and combining iterative processing of image edge information, the problem of heterogeneous feature alignment and robustness in industrial defect detection is solved, and the accurate detection and high-precision segmentation of minute defects on the surface of parts are realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 湖南工商大学
- Filing Date
- 2026-01-15
- Publication Date
- 2026-04-17
AI Technical Summary
Existing image-text fusion technologies in industrial defect detection suffer from problems such as difficulty in aligning heterogeneous features, poor robustness of static attention mechanisms, and lack of physical constraints leading to blurred or broken defect masks, making it difficult to accurately detect minute defects on the surface of parts.
By simulating the specific recognition and evolutionary optimization capabilities of the biological immune system and combining a physical diffusion dynamics-based image-text fusion method, iterative processing is performed using affinity threshold activation of matching units and diffusion modulation parameters guided by image edge information to generate refined segmented images.
It improves the accuracy and flexibility of surface defect detection for parts, reduces the false alarm rate, and meets the detection accuracy requirements of high-end manufacturing.
Smart Images

Figure CN121527086B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent manufacturing technology, and in particular to methods, devices, equipment and media for inspecting the surface quality of parts. Background Technology
[0002] In automated quality inspection of high-end manufacturing, defect detection on the surfaces of components (such as semiconductor wafers, PCBs, and precision metal parts) faces significant challenges. With the development of multimodal large-scale models, incorporating text descriptions, such as "fine scratches in the upper left corner" or "oil stains on the edges," to assist visual model detection has become a cutting-edge trend. However, existing image-text fusion technologies suffer from the following bottlenecks in industrial scenarios.
[0003] First, heterogeneous feature alignment is difficult. Industrial defects are often extremely small and irregular in shape, such as hairline cracks, while text descriptions are high-level semantics. Existing simple splicing or independent dual-tower encoding cannot achieve accurate correspondence between pixel-level features and semantic labels.
[0004] Secondly, static attention mechanisms are susceptible to background noise. The weight matrix generated by the mainstream Cross-Attention mechanism is usually statically calculated. In the absence of a large number of defective samples, it has poor robustness and is difficult to have the ability to specifically identify "non-self" anomalies like the biological immune system.
[0005] Finally, the lack of physical constraints leads to blurred or broken defect masks, and existing heatmaps lack a mechanism to utilize the physical structure (texture, edges) of the image itself to guide the spatial diffusion and shaping of semantic signals. Therefore, there is an urgent need for a new image-text fusion method that can simulate the specific recognition of the biological immune system, possess the ability to optimize the receptor population through evolution, and combine physical diffusion dynamics for fine segmentation, in order to achieve accurate detection of minute defects on the surface of parts. Summary of the Invention
[0006] In view of this, the purpose of this invention is to provide a method, apparatus, device, and medium for detecting the surface quality of components, which can simulate the specific recognition of a biological immune system, possess the ability to optimize the receptor population through evolution, and combine physical diffusion dynamics for fine segmentation via image-text fusion, thereby achieving accurate detection of minute defects on the surface of components. The specific solution is as follows:
[0007] In a first aspect, this application discloses a method for inspecting the surface quality of components, including:
[0008] Acquire a component image containing surface information of the component to be inspected, and select defect description text based on the inspection requirements of the component to be inspected to construct a defect inspection task instruction;
[0009] The component image and the defect detection task instruction are input into a preset quality inspection model, so that the first affinity of the component image and the second affinity of the defect detection task instruction are calculated by each matching unit respectively;
[0010] Based on the first affinity and the second affinity, a target matching unit is selected from each matching unit; the first affinity and the second affinity corresponding to the target matching unit both satisfy a preset affinity threshold condition;
[0011] The target matching unit is activated to generate an initial image-text matching graph;
[0012] The image edge information of the component image is read by the preset quality inspection model to obtain diffusion modulation parameters. The initial image-text matching image is iteratively processed based on the diffusion modulation parameters, and then a binarized segmented image containing defect prediction results is output.
[0013] Optionally, after inputting the component image and the defect detection task instruction into the preset quality inspection model, the method further includes:
[0014] The image encoder and text encoder in the preset quality inspection model are used to encode the component image and the defect detection task instruction respectively, so as to extract image features and text semantic features respectively;
[0015] Accordingly, the step of calculating the first affinity of the component image and the second affinity of the defect detection task instruction through each matching unit includes:
[0016] Calculate the visual affinity between the image features and the image feature template of the matching unit to obtain the first affinity;
[0017] Calculate the text affinity between the text semantic features and the text feature template of the matching unit to obtain the second affinity.
[0018] Optionally, the matching unit is a dual parameter in a preset quality detection model; wherein each dual parameter includes an image feature module for characterizing local visual texture features, a covariance matrix associated with the image feature template for defining the tolerance to image texture feature deformation, and a text feature template for characterizing defect semantic features.
[0019] Optionally, selecting a target matching unit from the matching units based on the first affinity and the second affinity includes:
[0020] Select a matching unit from the matching units in which both the first affinity and the second affinity are greater than the corresponding preset affinity threshold to obtain the target matching unit;
[0021] Accordingly, activating the target matching unit to generate an initial image-text matching graph includes:
[0022] The activation response values of the target matching units in each local region of the component image are aggregated to generate an initial image-text matching map; wherein the activation response values are calculated based on the first affinity and the second affinity output by the target matching unit.
[0023] Optionally, the step of reading the image edge information of the component image through the preset quality detection model to obtain diffusion modulation parameters includes:
[0024] The gradient magnitude of the component image is calculated using the preset quality detection model to obtain image edge information that characterizes the physical edges of the image;
[0025] Configure the mapping relationship between image edge information and diffusion modulation parameters; wherein the mapping relationship is used to control the diffusion behavior of semantic information;
[0026] Based on the image edge information and according to the mapping relationship, diffusion modulation parameters are generated.
[0027] Optionally, the iterative processing of the initial image-text matching map based on the diffusion modulation parameters, and then outputting a binarized segmented image containing the defect prediction results, includes:
[0028] The initial image-text matching graph is used as the starting point for the semantic concentration distribution;
[0029] Starting from the starting point, the diffusion modulation parameters are used to control the diffusion rate of semantic concentration in the image space to perform multiple rounds of iterative update processing until the semantic concentration distribution meets the preset stable state conditions, so as to obtain the target semantic concentration map.
[0030] The target semantic concentration map is thresholded to generate a binarized segmentation image that includes the defect prediction results.
[0031] Optionally, after iteratively processing the initial image-text matching map based on the diffusion modulation parameters, the method further includes:
[0032] Modulation weights are determined based on the target semantic density map, and the image features extracted from the component images are weighted using the modulation weights to obtain a fused feature representation that encodes visual appearance and semantic alignment information.
[0033] Secondly, this application discloses a component surface quality inspection device, comprising:
[0034] The information acquisition module is used to acquire part images containing surface information of the parts to be inspected, and select defect description text based on the inspection requirements of the parts to be inspected in order to construct defect detection task instructions.
[0035] The affinity calculation module is used to input the component image and the defect detection task instruction into a preset quality inspection model, so as to calculate the first affinity of the component image and the second affinity of the defect detection task instruction through each matching unit.
[0036] The unit selection module is used to select a target matching unit from the matching units based on the first affinity and the second affinity; the first affinity and the second affinity corresponding to the target matching unit both satisfy a preset affinity threshold condition;
[0037] An initial image generation module is used to activate the target matching unit to generate an initial image-text matching image;
[0038] The result prediction module is used to read the image edge information of the component image through the preset quality inspection model to obtain diffusion modulation parameters, and to perform iterative processing on the initial image-text matching image based on the diffusion modulation parameters, and then output a binarized segmented image containing the defect prediction results.
[0039] Thirdly, this application discloses an electronic device, including:
[0040] Memory, used to store computer programs;
[0041] A processor is used to execute the computer program to implement the steps of the aforementioned disclosed method for inspecting the surface quality of components.
[0042] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the aforementioned disclosed method for detecting the surface quality of components.
[0043] As can be seen, this application discloses a method for acquiring a component image containing surface information of the component to be inspected, and selecting defect description text based on the inspection requirements of the component to be inspected to construct a defect detection task instruction; inputting the component image and the defect detection task instruction into a preset quality inspection model, and calculating the first affinity of the component image and the second affinity of the defect detection task instruction through each matching unit, and selecting a target matching unit from the matching units based on the first affinity and the second affinity; the first affinity and the second affinity corresponding to the target matching unit both satisfy a preset affinity threshold condition; activating the target matching unit to generate an initial image-text matching map; reading the image edge information of the component image through the preset quality inspection model to obtain diffusion modulation parameters, and iteratively processing the initial image-text matching map based on the diffusion modulation parameters, and then outputting a binarized segmented image containing defect prediction results. Therefore, since the activation of the matching unit must simultaneously satisfy the affinity thresholds on both the image and text sides, spurious associations caused by single-cause matching are suppressed, greatly reducing the false alarm rate on complex backgrounds. Furthermore, the matching unit is not fixed, allowing the model to extract stable cross-modal defect matching units from a limited sample pool, eliminating noise-sensitive units. The detection target is input into the model via defect description text. By changing the task instructions, the same model can adapt to the search and localization of different defect types without any structural changes or retraining, significantly improving the flexibility of the detection system and reducing deployment and maintenance costs. By introducing image edge information and reaction-diffusion iteration, the propagation of semantic signals is controlled to follow the physical structure of the image itself. The resulting defect mask has clear and continuous edges, closely matching the actual physical contours of the parts, directly improving the accuracy of defect quantification and meeting the stringent requirements of high-end manufacturing for detection precision. Attached Figure Description
[0044] To more clearly illustrate the technical solutions in the embodiments of the present invention 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 embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0045] Figure 1 This is a flowchart of a method for inspecting the surface quality of components disclosed in this application;
[0046] Figure 2 This is a schematic diagram of the structure of a component surface quality inspection device disclosed in this application;
[0047] Figure 3 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0048] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0049] In automated quality inspection of high-end manufacturing, defect detection on the surfaces of components (e.g., semiconductor wafers, PCB circuit boards, precision metal parts) faces significant challenges. With the development of multimodal large-scale models, incorporating text descriptions, such as "fine scratches in the upper left corner" or "oil stains on the edges," to assist visual model detection has become a cutting-edge trend. However, existing image-text fusion technologies suffer from the following bottlenecks in industrial scenarios.
[0050] First, heterogeneous feature alignment is difficult. Industrial defects are often extremely small and irregular in shape, such as hairline cracks, while text descriptions are high-level semantics. Existing simple splicing or independent dual-tower encoding cannot achieve accurate correspondence between pixel-level features and semantic labels.
[0051] Secondly, static attention mechanisms are susceptible to background noise. The weight matrix generated by the mainstream Cross-Attention mechanism is usually statically calculated. In the absence of a large number of defective samples, it has poor robustness and is difficult to have the ability to specifically identify "non-self" anomalies like the biological immune system.
[0052] Finally, the lack of physical constraints leads to blurred or broken defect masks, and existing heatmaps lack a mechanism to utilize the physical structure (texture, edges) of the image itself to guide the spatial diffusion and shaping of semantic signals. Therefore, there is an urgent need for a new image-text fusion method that can simulate the specific recognition of the biological immune system, possess the ability to optimize the receptor population through evolution, and combine physical diffusion dynamics for fine segmentation, in order to achieve accurate detection of minute defects on the surface of parts.
[0053] To this end, the present invention provides a component surface quality inspection scheme that can simulate the specific recognition of the biological immune system, has the ability to optimize the evolution of the receptor population, and combines a new image-text fusion method with physical diffusion dynamics for fine segmentation, so as to achieve accurate detection of minute defects on the surface of components.
[0054] like Figure 1 As shown, the present invention provides a method for inspecting the surface quality of components, comprising:
[0055] Step S11: Obtain a component image containing surface information of the component to be inspected, and select defect description text based on the inspection requirements of the component to be inspected to construct a defect inspection task instruction.
[0056] In this embodiment, the surface image of the component to be inspected is first obtained, and based on the specific requirements of this inspection, such as the inspection requirement being to randomly inspect for cracks or to inspect for contamination, the corresponding defect description text is selected from the preset defect knowledge base, thereby forming an image-text pair input, which is to obtain the defect inspection task instruction.
[0057] Specifically, digital images of the component surface are captured by image acquisition equipment (high-resolution area array CCD (Computational Cameras and Displays) cameras, line scan cameras, or microscopic vision systems combined with preset angles and light sources) deployed on industrial production lines. To ensure the inspection effect, the original images can be preprocessed, including but not limited to: size normalization, grayscale conversion, illumination unevenness correction, and noise filtering. The preprocessed component images need to clearly characterize the texture, contour, and potential defect areas of the component surface.
[0058] Furthermore, a structured defect knowledge base is pre-built for different types of components (semiconductor wafers, PCBs, gears). This knowledge base contains all possible defect types for each type of component and their standardized language descriptions, such as elongated and curved microcracks, circular dark corrosion spots, and irregularly edged oil contamination. Based on the current inspection plan, one or more descriptive texts are selected from this knowledge base and combined to form task instructions.
[0059] In addition, the defects that need to be detected can be described in natural language through the human-computer interaction interface. For example, please check whether there are scratches and dirt on the surface. Specifically, the description can be converted into a standardized sequence of keywords or phrases through a lightweight text parsing module.
[0060] The defect detection task instructions generated in the above manner, together with the component images, constitute the input pair of the model, resulting in the defect detection task instructions, thus realizing the semantic and flexible definition of the detection task.
[0061] Step S12: Input the component image and the defect detection task instruction into the preset quality inspection model, so as to calculate the first affinity of the component image and the second affinity of the defect detection task instruction through each matching unit.
[0062] In this embodiment, the image encoder and text encoder in the preset quality inspection model are used to encode the component image and the defect detection task instruction, respectively, to extract image features and text semantic features. It can be understood that the component image to be detected and the corresponding defect detection task instruction are grouped together and input into the preset quality inspection model. Then, the trained image encoder and trained text encoder encode them. Specifically, the image encoder extracts multi-scale feature maps of the component image to obtain image features, and the text encoder extracts the semantic feature vector sequence of the text defect description in the defect detection task instruction to obtain text semantic features.
[0063] In this embodiment, the visual affinity between the image features and the image feature template of the matching unit is calculated to obtain a first affinity; the textual affinity between the textual semantic features and the textual feature template of the matching unit is calculated to obtain a second affinity. The matching unit is a dual parameter in a preset quality detection model; each dual parameter includes an image feature module characterizing local visual texture features, a covariance matrix associated with the image feature template defining the tolerance to image texture feature deformation, and a textual feature template characterizing defective semantic features. Understandably, an image-text immune receptor pool is pre-constructed before model training. Each receptor (matching unit) is defined as a dual parameter containing an image pattern vector (image feature template) and a text pattern vector (text feature template), used to calculate the two-sided affinity between the receptor and the image patch (image feature) and the text token (text semantic feature). After construction, during inference, the Mahalanobis distance between the image feature and the matching unit, and the cosine similarity between the text semantic feature and the matching unit are calculated for all matching templates in the image-text immune receptor pool, respectively, thus obtaining the first affinity and the second affinity. This forces the model to perform cross-modal validation later, avoiding false associations that generate responses based solely on visual similarity or text keywords.
[0064] Step S13: Based on the first affinity and the second affinity, select a target matching unit from each matching unit; the first affinity and the second affinity corresponding to the target matching unit both satisfy the preset affinity threshold condition.
[0065] In this embodiment, a target matching unit is obtained by selecting a matching unit from each matching unit whose first affinity and second affinity are both greater than the corresponding preset affinity threshold. It can be understood that the same matching unit whose visual affinity and text affinity both exceed the corresponding affinity threshold is selected as the target matching unit for subsequent activation. The initial image-text matching map generated after the target matching unit is activated simulates the clonal selection mechanism of the immune system.
[0066] Step S14: Activate the target matching unit to generate an initial image-text matching graph.
[0067] In this embodiment, the activation response values of the target matching units in various local regions of the component image are aggregated to generate an initial image-text matching map. The activation response values are calculated based on the first affinity and second affinity output by the target matching units. It can be understood that, firstly, clonal selection is performed on the target matching units, i.e., high-response matching units are exponentially enhanced to simulate the rapid proliferation of B cells under antigen stimulation, allowing the target matching units to dominate in subsequent calculations. Then, a loss penalty is applied to matching units that respond in normal background regions, forcing them to remain silent in non-defect regions. This directly endows the model with few-sample anomaly detection capabilities. The response values of all activated target matching units are aggregated to generate an initial image-text matching response map, serving as a preliminary heatmap of defect probability.
[0068] Step S15: Read the image edge information of the component image through the preset quality inspection model to obtain diffusion modulation parameters, and perform iterative processing on the initial image-text matching map based on the diffusion modulation parameters, and then output a binarized segmented image containing defect prediction results.
[0069] In this embodiment, the gradient magnitude of the component image is calculated using the preset quality detection model to obtain image edge information representing the physical edges of the image; a mapping relationship between the image edge information and diffusion modulation parameters is configured; wherein, the mapping relationship is used to control the diffusion behavior of semantic information; and diffusion modulation parameters are generated based on the image edge information and according to the mapping relationship. It can be understood that the anisotropic diffusion coefficient of the component image, i.e., the image edge information, is calculated using the preset quality detection model. The anisotropic diffusion coefficient is a function of the image gradient magnitude. Furthermore, the image edge information is mapped to the diffusion modulation coefficient. Specifically, in flat regions (small gradient magnitude), the diffusion modulation coefficient is large, allowing semantic concentration to diffuse freely and fill the interior of defects; at edges (large gradient magnitude), the diffusion modulation coefficient approaches zero, and semantic flow is blocked, which allows the edges of the defect mask to strictly conform to the physical texture edges of the image.
[0070] In this embodiment, the initial image-text matching map is used as the starting point of the semantic concentration distribution. Starting from the starting point, the diffusion modulation parameters are used to control the diffusion rate of semantic concentration in the image space for multiple rounds of iterative update processing until the semantic concentration distribution meets the preset stable state conditions to obtain the target semantic concentration map. The target semantic concentration map is then thresholded to generate a binary segmentation image containing defect prediction results. It can be understood that the initial image-text matching map is mapped to the initial semantic concentration field in the image space, i.e., the starting point of the semantic concentration distribution. The reaction term is based on the Logistic growth model and diffusion modulation parameters. In areas with high image-text semantic matching degree, the concentration will self-increase and strengthen to prevent signal attenuation during diffusion. Then, a numerical method (explicit Euler numerical discretization scheme) is used to iteratively solve the reaction-diffusion equation, and stability conditions (CFL (Courant-Friedrichs-Lewy) conditions) and convergence criteria are set. After the evolution stabilizes, the final target semantic concentration map is thresholded to obtain a binary defect mask, i.e., a binary segmentation image.
[0071] In this embodiment, modulation weights are determined based on the target semantic density map. These modulation weights are then used to weight the image features extracted from the component images to obtain a fused feature representation that encodes visual appearance and semantic alignment information. It can be understood that the evolved target semantic density map is used to modulate and enhance the original image features (multi-scale feature maps of the component images extracted by the image encoder) to generate physically enhanced image-text fusion features, i.e., a fused feature representation.
[0072] As can be seen, this application discloses a method for acquiring a component image containing surface information of the component to be inspected, and selecting defect description text based on the inspection requirements of the component to be inspected to construct a defect detection task instruction; inputting the component image and the defect detection task instruction into a preset quality inspection model, and calculating the first affinity of the component image and the second affinity of the defect detection task instruction through each matching unit, and selecting a target matching unit from the matching units based on the first affinity and the second affinity; the first affinity and the second affinity corresponding to the target matching unit both satisfy a preset affinity threshold condition; activating the target matching unit to generate an initial image-text matching map; reading the image edge information of the component image through the preset quality inspection model to obtain diffusion modulation parameters, and iteratively processing the initial image-text matching map based on the diffusion modulation parameters, and then outputting a binarized segmented image containing defect prediction results. Therefore, since the activation of the matching unit must simultaneously satisfy the affinity thresholds on both the image and text sides, spurious associations caused by single-cause matching are suppressed, greatly reducing the false alarm rate on complex backgrounds. Furthermore, the matching unit is not fixed, allowing the model to extract stable cross-modal defect matching units from a limited sample pool, eliminating noise-sensitive units. The detection target is input into the model via defect description text. By changing the task instructions, the same model can adapt to the search and localization of different defect types without any structural changes or retraining, significantly improving the flexibility of the detection system and reducing deployment and maintenance costs. By introducing image edge information and reaction-diffusion iteration, the propagation of semantic signals is controlled to follow the physical structure of the image itself. The resulting defect mask has clear and continuous edges, closely matching the actual physical contours of the parts, directly improving the accuracy of defect quantification and meeting the stringent requirements of high-end manufacturing for detection precision.
[0073] Before inspecting the surface quality of components, a multimodal inspection model is constructed and trained to obtain a preset quality inspection model. The specific process is as follows:
[0074] Step 1: Obtain images containing surface defects of different industrial products to obtain an industrial defect detection image dataset.
[0075] Step 2: Label the defect type and location of each image in the industrial defect detection image dataset, and set a language text containing location and shape description for defects of the same type.
[0076] Step 3: Each image containing defects and its corresponding text are grouped together and input into the image encoder and text encoder of the multimodal detection model to be trained.
[0077] Step 4: Extract multi-scale feature maps of the image using an image encoder, and extract semantic feature vector sequences of the text using a text encoder.
[0078] Step 5: Construct an image-text immune receptor pool, defining each receptor as a dual parameter containing image pattern vectors and text pattern vectors, and calculating the bilateral affinity between the receptor and the image patch and text token.
[0079] Step 6: The receptor is activated only when it detects a suspected defect texture on the image side and matches the corresponding defect description on the text side, generating an initial image-text matching response map to simulate the clonal selection mechanism of the immune system.
[0080] Specifically, in steps 5 and 6, for constructing the image-text immune receptor pool, each receptor is defined as a dual parameter containing image pattern vectors and text pattern vectors. The bilateral affinity between the receptor and the image patch and text token is calculated. The receptor is activated only when it detects a suspected defect texture on the image side and matches a corresponding defect description on the text side, generating an initial image-text matching response map.
[0081] During training and inference, the input image's multi-scale local feature set and the text's semantic feature sequence are combined to output an initial image-text matching response map. A bilaterally constrained image-text immune matching mechanism is designed. To address the extreme imbalance between positive and negative samples in industrial defect detection, an immune receptor pool containing K learnable receptors is constructed, with each receptor modeled as a cross-modal dual structure.
[0082] First, the dual structure and initialization state of the immune receptor pool are defined. Unlike the independent query-key matching in traditional multimodal models, each receptor (matching unit) in this invention... It was designed as an independent pattern recognition unit.
[0083] Calculation formula: .
[0084] in, This represents the k-th immune receptor; This represents the pattern center vector of the receptor in visual space, used to capture specific local texture features such as "crack lines" and "oil stains"; This represents the covariance matrix of the receptor in visual space, used to define the receptor's tolerance to visual feature deformation; This represents the embedding vector of the receptor in the text semantic space, used to correspond to the semantic features of defect descriptive words such as "thin" and "dark"; K is the size of the receptor pool.
[0085] Secondly, the bilateral affinity between the receptor and the local features of the current input image and the semantic features of the text is calculated. The matching degree between the features and the receptor is calculated in both the visual and text projection subspaces.
[0086] The first affinity and the second affinity are determined by calculation formulas.
[0087] .
[0088] in, Represents the first input image Each local patch feature vector (i.e., the visual antigen to be identified); The Mahalanobis distance represents affinity on the visual side; This indicates the first in the input text description. Each token feature vector; Cosine similarity affinity represents the text-to-text similarity. To prevent the use of tiny constants with a denominator of zero, this calculation formula yields an independent response value for each receptor to the current local image region and text description fragment.
[0089] Then, in order to achieve specific activation, a bilateral joint activation energy function is defined, which triggers the response only when the visual feature and the semantic description both point to the same concept.
[0090] Calculation formula:
[0091] ;
[0092] in, Indicates the first The receptor for the first The first image patch and the first The combined activation energy of individual text tokens; Use the Sigmoid activation function; and These are the modal equilibrium coefficients; This is the learnable adaptive activation threshold for the receptor; This is an indicator function; it is only applied when both visual affinity and text affinity exceed a preset baseline threshold. and The value is 1 if the condition is met, and 0 otherwise. This strategy helps the model strongly suppress spurious associations caused by image-text mismatches in the early stages of feature fusion, thereby improving its robustness against interference in complex industrial environments.
[0093] Next, to simulate the dynamic evolution of the immune system after exposure to antigens, a clonal selection mechanism is introduced to immediately enhance highly responsive receptors. This is achieved through the calculation formula:
[0094] ;
[0095] in, The clonal proliferation coefficient of receptor k is represented by α, which is the clonal rate constant. Represents the set of all local regions of an image; This represents the strongest textual semantic energy matched by the receptor in the current region i. This step assigns an exponentially increasing weight to high-energy receptors, simulating the rapid proliferation of B cells under antigen stimulation.
[0096] Meanwhile, for a large number of normal samples in industrial scenarios, a negative selection inhibition mechanism is introduced to punish receptors that respond to the background region.
[0097] Calculation formula:
[0098] ;
[0099] in, The negative selection loss term is added to the total loss function for end-to-end optimization. This represents a set of image regions that belong to a normal background (without defect annotations). This is the safety tolerance threshold. This mechanism forces the receptor to remain silent in non-defective regions, thereby endowing the model with extremely strong few-sample anomaly detection capabilities.
[0100] Finally, the responses of all activated receptors are aggregated to generate an initial text-to-image matching response map, which serves as the input for subsequent reaction-diffusion fields.
[0101] Calculation formula:
[0102] ;
[0103] in, This represents the initial defect response intensity at image location i, directly reflecting the confidence level that a specific defect exists in that region and matches the textual description. This strategy helps the model transform discrete receptor activation signals into spatially continuous thermograms, thereby providing accurate initial concentration inputs for the subsequent physical evolution of the reaction-diffusion field.
[0104] Step 7: Perform evolutionary updates based on replicon dynamics for the receptor population. According to the fitness of the receptor in the defect localization task, dynamically adjust the receptor activity weight using the replicon dynamics equation to achieve the survival of the fittest in the receptor population.
[0105] Specifically, regarding the aforementioned evolutionary update of the receptor population based on replicon dynamics, the receptor activity weights are dynamically adjusted using the replicon dynamics equation based on the receptor's fitness in the defect localization task, thereby achieving the survival of the fittest among the receptor population. Specifically:
[0106] During training, the initial receptor activation state generated in step 6 and the current batch of image and text data are input, and the receptor activity weight vector after evolutionary screening is output. Replicator Dynamics, based on evolutionary game theory, is used to iteratively optimize the image-text immune receptor pool. The core purpose of this step is to simulate the survival competition of biological populations in a limited resource environment, treating receptors as competing individuals and receptor activity weights as population density. By constructing a closed-loop evolutionary system that includes fitness assessment, dynamic evolution, mutation operations, and diversity maintenance, "elite receptors" capable of accurately identifying minute industrial defects proliferate, while "inferior receptors" responding to background noise or generating spurious associations are eliminated.
[0107] First, we define the comprehensive fitness function of the receptor in the current training batch. Fitness is the core indicator that determines the receptor's right to survive, and it needs to comprehensively consider the receptor's ability to capture defective targets, the rationality of its spatial distribution, and the consistency of its cross-modal semantics. To address the challenge of scarce labeled data and extremely complex backgrounds in industrial scenarios, we design a fitness function with multi-objective constraints.
[0108] Calculation formula:
[0109] ;
[0110] in, Indicates the first The overall fitness value of each receptor; This is the set of samples in the current batch that contain actual defect annotations; For the visual affinity of the receptor to the defective region (as defined by the second formula in step 6), this term encourages the receptor to respond strongly to the real defect; Spatial consistency score, used to measure whether receptor activation regions have a continuous physical structure (rather than discrete noise), is specifically calculated from the Laplacian smoothness of local features; This is the average semantic vector of all defect text descriptions in the current batch; This is a text consistency term that ensures the semantic pattern of the receptor is always aligned with the core semantics of the defect description. This is an L1 sparse regularization term used to suppress redundant receptors; These are the weighting coefficients for each sub-item. This calculation formula yields a survival competitiveness score for each receptor. This fitness assessment mechanism not only focuses on "whether defects are identified," but also on "whether the identified regions are continuous" and "whether the semantics are accurate," thereby guiding receptors to evolve towards a direction that is both "form and spirit complete."
[0111] Secondly, a continuous form of the replicon dynamics equation is introduced to describe the evolution of receptor activity weights over training time. This is the core equation of evolutionary game theory, which mathematically guarantees that the population converges to the evolutionarily stable strategy (ESS).
[0112] Calculation formula:
[0113] ;
[0114] in, Indicates the first The activity weight (i.e., population proportion) of each receptor satisfies ; The rate of change of receptor weights; This represents the average fitness of the entire receptor pool. The equation shows that only when the receptor... fitness Higher than the group average Its weight only increases when the condition is met; otherwise, it decreases. This mechanism allows the model to automatically select the most discriminative feature patterns during training.
[0115] Then, in order to perform numerical computation within a deep learning framework, the continuous equation is discretized to obtain an iterative update formula for the receptor weights.
[0116] Calculation formula:
[0117] ;
[0118] in, and They represent the first Wheel and First +Receptor weights during +1 round of training; The evolutionary step size (learning rate) is typically set to a small value (e.g., 0.01) to ensure evolutionary stability. This calculation formula yields the specific adjustment amount of the receptor weights after each round of training. Through this dynamic adjustment, the model can gradually "forget" those receptors that produce false positives in industrial contexts, while "strengthening" receptors that are sensitive to minor defects, thereby significantly improving the model's robustness and generalization ability in scenarios with few industrial defects.
[0119] Next, to prevent the population from getting trapped in local optima (i.e., all receptors converge to the same simple defect pattern, ignoring other complex defects), a Gaussian mutation operation is introduced. This step simulates biological gene mutation, giving the receptor pool the ability to explore unknown defect patterns.
[0120] Calculation formula:
[0121] ;
[0122] in, and These are the visual center vectors of the receptors before and after the mutation (defined in the first formula of step 6), respectively. This is a Gaussian noise disturbance. The variance intensity of the current training round decays exponentially as the training progresses; The initial mutation strength; The decay factor is 0.95. This strategy helps the model maintain a high level of exploration ability in the early stages of training, capturing potential diverse defect features, while gradually converging in the later stages of training for fine-tuning.
[0123] At the same time, in order to preserve the optimal receptors that emerged during the historical evolutionary process and prevent the loss of superior genes due to random mutations, an elite preservation strategy is implemented.
[0124] Calculation formula:
[0125] ;
[0126] in, The set of elite receptors retained in round t+1; This is the size of the historical backtracking window. This formula ensures that in the past... The receptor with the highest cumulative fitness in each training round does not participate in mutation operations and is directly replicated to the next generation. This mechanism effectively prevents premature convergence and catastrophic forgetting, ensuring that model performance monotonically increases with each training round.
[0127] Furthermore, a population diversity maintenance term is introduced to prevent receptor homogenization. In industrial scenarios, different types of defects (such as scratches, dents, and discoloration) vary greatly, requiring the receptor pool to maintain a high degree of diversity.
[0128] Calculation formula:
[0129] ;
[0130] in, This serves as a diversity penalty term, added as a negative term to the total fitness or loss function; For diverse bandwidth parameters; This serves as the visual center for different receptors. This factor penalizes receptor pairs that are too similar to each other and have a high weight, forcing the receptor pool to differentiate into different "niches" to cover different defect types.
[0131] Finally, the updated receptor activity is normalized, and the final receptor weight vector is output as the input parameter for the subsequent reaction-diffusion field.
[0132] Calculation formula:
[0133] ;
[0134] in, For the first The receptors are ultimately used as normalized weights in subsequent calculations; the ReLU function is used to truncate all negative weights (i.e., eliminated receptors) to ensure the non-negativity of the weights; This is a numerical stability constant. The calculation formula yields the final distribution of elite receptors. These weights will directly determine which receptors' matched responses will proceed to the next stage of physical field evolution.
[0135] Ultimately, through continuous evolution driven by replicon dynamics, the receptor pool retains only the elite receptor group that is most specific and robust to industrial micro-defects. This provides a high signal-to-noise ratio initial response map for the accurate evolution of the subsequent reaction-diffusion semantic field, thereby significantly improving the edge fit and positioning accuracy of the final defect mask.
[0136] Step 8: Map the matching response map generated by the receptor after evolutionary screening in step 7 to a semantic concentration field in the image space, and construct an anisotropic response-diffusion partial differential equation guided by the image gradient.
[0137] Step 9: Perform numerical evolution of the semantic concentration field over several time steps to allow the semantic signal to spread rapidly in the flat region and stop at the physical edge, thereby obtaining an evolution-stable semantic alignment defect mask with physical consistency and image-text fusion features based on the reaction-diffusion field evolution, and finally obtain a pre-trained multimodal industrial defect detection model.
[0138] It is understandable that, regarding the mapping of the matching response map generated by the receptor after evolutionary screening in step 7 to a semantic concentration field in the image space, an anisotropic response-diffusion partial differential equation guided by the image gradient is constructed; and the semantic concentration field is numerically evolved over several time steps to make the semantic signal spread rapidly in flat regions and stop at physical edges, resulting in an evolutionarily stable semantic alignment defect mask with physical consistency and image-text fusion features based on the evolution of the response-diffusion field, specifically:
[0139] After obtaining the elite receptor population purified by replicon dynamics and its corresponding weighted response map, in order to completely solve the problems of blurred edges, discontinuous shapes, and lack of physical constraints in attention maps generated by traditional deep learning methods, this invention introduces a "reaction-diffusion semantic field evolution mechanism" that is strictly constrained by the physical structure of the image. This mechanism treats abstract semantic probabilities as a kind of virtual "chemical substance," allowing it to propagate in the image pixel space according to the physical diffusion law, and uses the texture gradient of the image itself as a "diffusion barrier" to achieve the physical consistency of semantic signals.
[0140] First, initialize the semantic concentration field in the image space. Map the receptor-weighted response map output from step 7 to the substance concentration distribution at the initial time step.
[0141] Calculation formula:
[0142] ;
[0143] in, Represents image coordinates The initial semantic concentration at the location has a value range of [0,1]. The output of step 7 Normalized weights of elite receptors; The initial response map corresponding to this receptor (generated by step 6); The space normalization function (such as Min-Max normalization) ensures the energy conservation of the initial field. This calculation formula yields the initial state of evolution, providing a high signal-to-noise ratio "seed region" for subsequent physical processes.
[0144] Secondly, in order to achieve "anisotropic" diffusion, that is, to allow semantic flow to flow smoothly in flat areas (such as inside oil stains) and be blocked at physical boundaries (such as the edge of a crack), it is necessary to calculate the physical gradient magnitude of the image.
[0145] Calculation formula:
[0146] ;
[0147] in, Original industrial image (after grayscale conversion); These are the Sobel edge operators for the horizontal and vertical directions, respectively; Indicates the convolution operation; Represents pixels The gradient intensity at a given location; the larger the value, the more likely that location is to be a physical edge (such as a scratch boundary or part outline). It is a numerically stable term.
[0148] Then, an anisotropic diffusion coefficient function is constructed based on the image gradient. This is the core controller for achieving "physical consistency".
[0149] Calculation formula:
[0150] ;
[0151] in, Represents pixels Local diffusion conductivity at the location; The maximum diffusion coefficient controls the maximum speed of semantic flow; This is the edge sensitivity constant, which determines the minimum gradient threshold required to block diffusion; The smoothing exponent (usually taken as 2) is used to calculate the diffusion capability of each pixel in the gradient. flat areas This allows for rapid semantic filling; however, at edges where the gradient is large, This forms an "insulating wall." This mechanism allows semantic signals to penetrate strictly according to the physical texture of the image, thereby achieving true 'pixel-level physical consistency' image-text alignment.
[0152] Next, we define a response source term controlled by textual semantics. Simple diffusion leads to signal attenuation, so a "response term" is needed to simulate the self-proliferation of semantics (i.e., strengthening the signal after confirming that the region does indeed conform to the textual description).
[0153] Calculation formula:
[0154] ;
[0155] in, The reaction proliferation rate; This is the intrinsic reaction rate constant; This is the saturation concentration (usually set to 1) to prevent numerical explosion; For local image features Text features The semantic similarity is calculated. This is based on the Logistic growth model, which ensures that semantic concentration only continues to increase in regions where image texture and text description are highly consistent; otherwise, it will dissipate due to diffusion.
[0156] Subsequently, the diffusion and reaction terms are combined to construct the complete anisotropic reaction-diffusion partial differential equation (PDE). This is the master equation governing the entire evolution process.
[0157] Calculation formula:
[0158] ;
[0159] in, This represents the rate of evolution of semantic concentration over time. This is the divergence operator. This equation describes the dynamic equilibrium process of the semantic field under physical constraints.
[0160] To solve the PDE on a discrete digital image, an explicit Euler numerical discretization scheme is used for iteration.
[0161] Calculation formula:
[0162] ;
[0163] in, and At the (n+1)th and nth time steps, respectively, at the pixel Concentration at that location; For time step; is the interpolation diffusion coefficient at the midpoint of the grid. This discrete scheme transforms continuous physical processes into computer-executable matrix operations.
[0164] Meanwhile, in order to ensure the stability of numerical evolution, the CFL stability condition must be satisfied.
[0165] Calculation formula:
[0166] ;
[0167] in, The pixel grid spacing is typically 1. This condition strictly limits the upper limit of the time step, preventing numerical oscillations or divergences in the semantic field due to excessively large iteration steps. This strategy ensures the numerical robustness of the model during inference, guaranteeing that each evolution converges to a physically reasonable solution.
[0168] In addition, evolutionary boundary conditions are defined. To prevent semantic signals from flowing out of the image boundary, Neumann boundary conditions (insulating boundaries) are used.
[0169] Calculation formula:
[0170] ;
[0171] in, Show image boundaries; The boundary normal vector; Let be the width and height of the image. This condition forces the concentration gradient at the boundary to be zero, ensuring that semantic energy is conserved within the image.
[0172] Furthermore, an evolution termination criterion is established. Iteration stops when the semantic field morphology tends to stabilize. This is calculated using the following formula:
[0173] ;
[0174] in, It is the Frobenius norm; The convergence threshold (e.g., 10) -4 ); This represents the maximum number of iterations. This dynamic stopping mechanism allows the model to adaptively adjust the evolution time based on the complexity of the defect morphology.
[0175] Finally, the final semantic alignment defect mask and fusion features are generated.
[0176] Calculation formula:
[0177] ;
[0178] in, For binary defect segmentation mask; The segmentation threshold; This represents the steady-state semantic field at the termination of evolution. This is the enhancement feature for the final input to the downstream classification head; This indicates element-wise multiplication; This represents the fusion strength coefficient.
[0179] Ultimately, through reaction-diffusion evolution strictly constrained by the physical structure of the image, the semantic signal fully penetrates and fills the flat area inside the defect, and is precisely truncated at the physical edge, forming a semantically aligned defect mask that highly matches the morphology of the real defect. This mask not only has extremely high edge fit and morphological fidelity, but also endows the model with strong interpretability, clearly showing the complete physical process of "how semantics crawls along the crack and how it diffuses inside the oil stain," thus completely solving the "fuzzy cloud" problem generated by traditional attention mechanisms and achieving a leapfrog breakthrough from "statistical matching" to "physical intelligence" in the field of industrial defect detection.
[0180] like Figure 2 As shown, the present invention also discloses a component surface quality inspection device, comprising:
[0181] The information acquisition module 11 is used to acquire a part image containing surface information of the part to be inspected, and select defect description text based on the inspection requirements of the part to be inspected in order to construct a defect detection task instruction.
[0182] The affinity calculation module 12 is used to input the component image and the defect detection task instruction into a preset quality inspection model, so as to calculate the first affinity of the component image and the second affinity of the defect detection task instruction through each matching unit.
[0183] The unit selection module 13 is used to select a target matching unit from the matching units based on the first affinity and the second affinity; the first affinity and the second affinity corresponding to the target matching unit both satisfy a preset affinity threshold condition.
[0184] The initial image generation module 14 is used to activate the target matching unit to generate an initial image-text matching image.
[0185] The result prediction module 15 is used to read the image edge information of the component image through the preset quality inspection model to obtain diffusion modulation parameters, and to perform iterative processing on the initial image-text matching image based on the diffusion modulation parameters, and then output a binarized segmented image containing the defect prediction results.
[0186] Therefore, by constructing an evolutionary matching unit as a bridge for text-image interaction, combining replicon dynamics to achieve the survival of the fittest in the recipient population, and introducing anisotropic response-diffusion equations to achieve the physical consistency spatial shaping of semantic signals, this method is mainly applicable to tasks such as micro-defect detection, fine-grained text-image matching, and cross-modal anomaly localization in high-end manufacturing scenarios such as semiconductor wafers, PCB circuit boards, and precision metal parts.
[0187] Furthermore, embodiments of this application also disclose an electronic device, Figure 3 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0188] Figure 3 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the component surface quality inspection method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0189] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0190] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0191] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0192] The operating system 221 manages and controls the various hardware devices and computer programs 222 on the electronic device 20 to enable the processor 21 to perform calculations and processing on the massive amounts of data 223 in the memory 22. It can be Windows Server, Netware, Unix, Linux, etc. The computer program 222, in addition to including a computer program capable of performing the component surface quality inspection method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, may further include computer programs capable of performing other specific tasks. The data 223 may include data received by the electronic device from external devices, as well as data collected by its own input / output interface 25.
[0193] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned method for inspecting the surface quality of components. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0194] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0195] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application. The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly in hardware, software modules executed by a processor, or a combination of both. The software module may be located in random access memory (RAM), memory, read-only memory (ROM), electrically programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, removable disks, CD-ROMs (Compact Disc-Read Only Memory), or any other form of storage medium known in the art.
[0196] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0197] The solution provided by the present invention has been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method of detecting surface quality of a component part, characterized by, include: Acquire a component image containing surface information of the component to be inspected, and select defect description text based on the inspection requirements of the component to be inspected to construct a defect inspection task instruction; The component image and the defect detection task instruction are input into a preset quality inspection model, so that the first affinity of the component image and the second affinity of the defect detection task instruction are calculated by each matching unit respectively; Based on the first affinity and the second affinity, a target matching unit is selected from each matching unit; the first affinity and the second affinity corresponding to the target matching unit both satisfy a preset affinity threshold condition; The target matching unit is activated to generate an initial image-text matching graph; The image edge information of the component image is read through the preset quality inspection model to obtain diffusion modulation parameters. The initial image-text matching image is iteratively processed based on the diffusion modulation parameters, and then a binarized segmented image containing defect prediction results is output. Activating the target matching unit to generate an initial image-text matching graph includes: The activation response values of the target matching units in each local region of the component image are aggregated to generate an initial image-text matching map; wherein, the activation response values are calculated based on the first affinity and the second affinity output by the target matching unit; The step of reading the image edge information of the component image through the preset quality detection model to obtain diffusion modulation parameters includes: The gradient magnitude of the component image is calculated using the preset quality detection model to obtain image edge information that characterizes the physical edges of the image; Configure the mapping relationship between image edge information and diffusion modulation parameters; wherein the mapping relationship is used to control the diffusion behavior of semantic information; Based on the image edge information and according to the mapping relationship, diffusion modulation parameters are generated; The iterative processing of the initial image-text matching map based on the diffusion modulation parameters, followed by outputting a binarized segmented image containing defect prediction results, includes: The initial image-text matching graph is used as the starting point for the semantic concentration distribution; Starting from the starting point, the diffusion modulation parameters are used to control the diffusion rate of semantic concentration in the image space to perform multiple rounds of iterative update processing until the semantic concentration distribution meets the preset stable state conditions, so as to obtain the target semantic concentration map. The target semantic concentration map is thresholded to generate a binarized segmentation image that includes the defect prediction results.
2. The method of claim 1, wherein After inputting the component image and the defect detection task instruction into the preset quality inspection model, the method further includes: The image encoder and text encoder in the preset quality inspection model are used to encode the component image and the defect detection task instruction respectively, so as to extract image features and text semantic features respectively; Accordingly, the step of calculating the first affinity of the component image and the second affinity of the defect detection task instruction through each matching unit includes: Calculate the visual affinity between the image features and the image feature template of the matching unit to obtain the first affinity; Calculate the text affinity between the text semantic features and the text feature template of the matching unit to obtain the second affinity.
3. The method of claim 2, wherein The matching unit is the dual parameter in the preset quality detection model; wherein, each of the dual parameters includes an image feature template for characterizing local visual texture features, a covariance matrix associated with the image feature template for defining the tolerance to image texture feature deformation, and a text feature template for characterizing defect semantic features.
4. The method for inspecting the surface quality of components according to claim 2, characterized in that, The step of selecting a target matching unit from the matching units based on the first affinity and the second affinity includes: Select a matching unit from the matching units in which both the first affinity and the second affinity are greater than the corresponding preset affinity threshold to obtain a target matching unit.
5. The method of inspecting the surface quality of a part according to any one of claims 1 to 4, characterized in that, After iteratively processing the initial image-text matching map based on the diffusion modulation parameters, the process further includes: Modulation weights are determined based on the target semantic density map, and the image features extracted from the component images are weighted using the modulation weights to obtain a fused feature representation that encodes visual appearance and semantic alignment information.
6. A device for detecting surface quality of a part, characterized by comprising: include: The information acquisition module is used to acquire part images containing surface information of the parts to be inspected, and select defect description text based on the inspection requirements of the parts to be inspected in order to construct defect detection task instructions. The affinity calculation module is used to input the component image and the defect detection task instruction into a preset quality inspection model, so as to calculate the first affinity of the component image and the second affinity of the defect detection task instruction through each matching unit. The unit selection module is used to select a target matching unit from the matching units based on the first affinity and the second affinity; the first affinity and the second affinity corresponding to the target matching unit both satisfy a preset affinity threshold condition; An initial image generation module is used to activate the target matching unit to generate an initial image-text matching image; The result prediction module is used to read the image edge information of the component image through the preset quality inspection model to obtain diffusion modulation parameters, and to perform iterative processing on the initial image-text matching image based on the diffusion modulation parameters, and then output a binarized segmented image containing the defect prediction result. The initial image generation module is specifically used to aggregate the activation response values of the target matching units in each local region of the component image to generate an initial image-text matching image; wherein, the activation response values are calculated based on the first affinity and the second affinity output by the target matching unit; The result prediction module is specifically used to calculate the gradient magnitude of the component image through the preset quality detection model to obtain image edge information representing the physical edge of the image; configure the mapping relationship between the image edge information and the diffusion modulation parameters; wherein, the mapping relationship is used to control the diffusion behavior of semantic information; generate diffusion modulation parameters based on the image edge information and according to the mapping relationship; take the initial image-text matching map as the starting point of the semantic concentration distribution; start from the starting point and use the diffusion modulation parameters to control the diffusion rate of semantic concentration in the image space to perform multiple rounds of iterative update processing until the semantic concentration distribution meets the preset stable state conditions to obtain the target semantic concentration map; and perform thresholding processing on the target semantic concentration map to generate a binary segmentation image containing the defect prediction results.
7. An electronic device, comprising: include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the component surface quality inspection method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, Used to store a computer program; wherein, when the computer program is executed by a processor, it implements the steps of the component surface quality inspection method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Machine tool precision casting surface defect automatic detection system
CN120805069A
Special equipment nondestructive testing image defect automatic identification method and system
CN121033513A