Resistance disc defect detection method and device, electronic equipment and storage medium

Through the method of combining image feature screening and differentiated preprocessing to generate adversarial networks and target random forest models, the problem of insufficient accuracy and reliability in resistor sheet defect detection is solved, and higher detection accuracy and reliability are achieved.

CN119850624AActive Publication Date: 2025-04-18BEIJING JINGUAN INTELLIGENT ELECTRICAL TECH CO LTD +1
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510330981.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-20
Publication Date
2025-04-18
Estimated Expiration
2045-03-20

AI Technical Summary

Technical Problem

The prior art has problems of insufficient accuracy and reliability in resistor chip defect detection, especially when real defect samples are scarce, the model generalization ability is poor, and various types of resistor chip defects cannot be accurately detected.

Method used

By initially screening suspected defect images and suspected defect-free images based on image features, and differentiated preprocessing of the two types of images, generating adversarial networks to generate multiple types of defect images, expanding the training data sets, and using the target random forest model for defect detection.

Benefits of technology

It significantly improves the accuracy and reliability of resistor chip defect detection, effectively highlights defect characteristics, reduces noise interference, and improves the generalization ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119850624A_ABST
    Figure CN119850624A_ABST
Patent Text Reader

Abstract

The invention provides a resistor disc defect detection method and device, electronic equipment and a storage medium, and belongs to the technical field of defect detection.The method comprises the steps that a suspected defect image and a suspected defect-free image are determined based on image features of a first image, and the first image is a to-be-detected resistor disc image; the suspected defect image is subjected to first preprocessing, the suspected defect-free image is subjected to second preprocessing, a target image is obtained, and the processing mode of the first preprocessing is different from the processing mode of the second preprocessing; inputting the target image into the target random forest model to obtain a defect detection result; wherein the training process of the target random forest model comprises the step of generating multiple types of defect images based on a generative adversarial network; determining a first data set based on the generation effect value of each type of defect image; and training the random forest model based on the first data set to obtain a target random forest model. According to the invention, the accuracy and reliability of resistor disc defect detection can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure belongs to the technical field of defect detection, and more specifically, relates to a resistor defect detection method and device, electronic equipment, and storage medium. Background Art

[0002] In the field of electronic equipment manufacturing, resistors are basic and key electronic components, and their quality is directly related to the performance and stability of the entire electronic equipment.

[0003] Although automated detection technology has been applied to resistor defect detection, it has limitations. Although machine learning algorithms have made some progress, because the number of normal resistors is usually far greater than that of defective resistors during the production process, in actual resistor defect detection scenarios, real defect data is relatively scarce, making it difficult to collect real defect samples, with small amounts of data and unbalanced categories, resulting in poor model generalization and inability to accurately detect various types of resistor defects.

[0004] Therefore, an accurate and reliable method for detecting resistor defects is needed. Summary of the invention

[0005] The purpose of the present disclosure is to provide a resistor defect detection method and device, electronic equipment, and storage medium to improve the accuracy and reliability of resistor defect detection.

[0006] According to a first aspect of an embodiment of the present disclosure, a resistor defect detection method is provided, comprising: Determining a suspected defective image and a suspected non-defective image based on image features of a first image, wherein the first image is an image of a resistor sheet to be detected; Performing a first preprocessing on the suspected defective image and a second preprocessing on the suspected non-defective image to obtain a target image, wherein the processing method of the first preprocessing is different from the processing method of the second preprocessing; The target image is input into the target random forest model to obtain the defect detection result; wherein, the training process of the target random forest model includes generating multiple types of defect images based on a generative adversarial network; determining a first data set based on the generation effect value of each type of defect image; and training the random forest model based on the first data set to obtain the target random forest model.

[0007] According to a second aspect of the embodiments of the present disclosure, a resistor defect detection device is provided, comprising: A pre-detection module, used to determine a suspected defective image and a suspected non-defective image based on image features of a first image, wherein the first image is an image of a resistor sheet to be detected; A preprocessing module, used for performing a first preprocessing on the suspected defective image and a second preprocessing on the suspected non-defective image to obtain a target image, wherein the processing method of the first preprocessing is different from the processing method of the second preprocessing; The defect detection module is used to input the target image into the target random forest model to obtain the defect detection result; wherein the training process of the target random forest model includes generating multiple types of defect images based on the generative adversarial network; determining the first data set based on the generation effect value of each type of defect image; and training the random forest model based on the first data set to obtain the target random forest model.

[0008] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of the above-mentioned resistor defect detection method when executing the computer program.

[0009] According to a fourth aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned resistor defect detection method are implemented.

[0010] The beneficial effects of a resistor defect detection method and device, electronic device, and storage medium provided by the embodiments of the present disclosure are: The present invention preliminarily screens suspected defective images and suspected non-defective images through image features, and then performs differentiated preprocessing on these two types of images, which can more effectively highlight defect features and reduce noise interference. It not only improves image quality, but also lays a solid foundation for subsequent model detection, thereby significantly improving the accuracy of resistor defect detection. In response to the problem of scarcity of real defect samples, the present invention uses a generative adversarial network to generate multiple types of defect images, effectively expands the training data set, and determines the data set for training the random forest model based on the generated results, so that the random forest model can better identify various defects and improve the accuracy and reliability of resistor defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0012] Figure 1 A schematic diagram of a flow chart of a resistor defect detection method provided by an embodiment of the present disclosure; Figure 2A structural block diagram of a resistor defect detection device provided by an embodiment of the present disclosure; Figure 3 A schematic block diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0013] In the following description, specific details such as specific system structures and technologies are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present disclosure. However, it should be clear to those skilled in the art that the present disclosure may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obstructing the description of the present disclosure with unnecessary details.

[0014] In order to make the purpose, technical solutions and advantages of the present disclosure more clear, specific embodiments will be described below in conjunction with the accompanying drawings.

[0015] Please refer to Figure 1 , Figure 1 A schematic diagram of a flow chart of a resistor defect detection method provided in an embodiment of the present disclosure, the method comprising: S101: Determine a suspected defective image and a suspected non-defective image based on image features of a first image, where the first image is an image of a resistor sheet to be detected.

[0016] In this embodiment, the first image refers to the image of the resistor sheet that needs to be inspected for defects, which can be obtained by a camera or a high-precision camera in the production process of the resistor sheet. The image feature can be an average grayscale value or grayscale distribution, etc. The suspected defective image is the part of the image area that is preliminarily judged to have defects after analyzing and processing the first image. It is only a preliminary judgment and does not determine that there are defects. Further testing and verification are required. The suspected non-defective image, in contrast to the suspected defective image, is the part of the image area that is preliminarily judged to have no defects after analysis.

[0017] In this embodiment, the image features include: average grayscale value; suspected defective images and suspected non-defective images can be determined in the following manner: Determining a suspected defective image and a suspected non-defective image based on the image feature of the first image includes: Determine an area image in the first image whose average gray value is within a first value interval as a suspected defect image; An area image in the first image whose average grayscale value is not within the first value interval is determined as a suspected defect-free image.

[0018] In this embodiment, the average gray value can be obtained by summing the gray values ​​of all pixels in the image and dividing by the total number of pixels. The first value interval can be determined by the average gray value of the image when a large number of resistors have defects or can be set based on experience.

[0019] This embodiment takes into account that when a resistor sheet has defects, its physical structure or surface characteristics will change, causing the optical reflection or absorption characteristics of the area to be different from those of a normal area. From the perspective of the image, this difference will be reflected in the grayscale value.

[0020] For example, when there are defects such as scratches, cracks or impurities on the surface of the resistor, these areas may absorb more light, resulting in a lower grayscale value in the image; if there are protrusions or reflective defects, the area may reflect more light, resulting in a higher grayscale value. Therefore, by determining whether the average grayscale value of the image is within the preset first value interval, it can be preliminarily determined whether certain areas may have defects.

[0021] S102: performing a first preprocessing on the suspected defective image and a second preprocessing on the suspected non-defective image to obtain a target image, wherein the processing method of the first preprocessing is different from the processing method of the second preprocessing.

[0022] In this embodiment, the first preprocessing is performed on suspected defective images, and the second preprocessing is performed on suspected non-defective images. Because suspected defective images and suspected non-defective images have different characteristics, different processing methods are required to better retain or highlight their respective characteristics. Therefore, the first preprocessing and the second preprocessing have different processing methods.

[0023] The first preprocessing may be enhancement processing, denoising and sharpening, and the second preprocessing may be normalization processing and filtering.

[0024] Specifically, the first preprocessing is to use contrast-limited adaptive histogram equalization and other methods to enhance the local contrast of the image, highlight the details of the defect, and make the defect features that may not be obvious before clearer. Secondly, use the median filter to remove salt and pepper noise, and then use a sharpening filter, such as the Laplace operator or the Sobel operator, to sharpen the image and enhance the edge information of the defect, which is helpful for the subsequent accurate identification of the shape and boundary of the defect. The second preprocessing is normalization, mapping the pixel value to a specific range, such as [0, 1] or [-1, 1] to eliminate the brightness difference between different images due to factors such as lighting, which is convenient for subsequent feature extraction and model processing. Then use a mean filter or a Gaussian filter for smoothing to reduce the noise in the image and make the image smoother, which is conducive to the subsequent extraction of features such as normal texture.

[0025] The target image is the image obtained after the first image undergoes the first preprocessing and the second preprocessing. Specifically, it can be understood that the target image is the image obtained by stitching together the suspected defective image in the first image after the first preprocessing and the suspected non-defective image in the first image after the second preprocessing.

[0026] By preprocessing the suspected defective images and the suspected non-defective images respectively, the obtained target images can better adapt to the input requirements of the model and improve the accuracy of defect detection.

[0027] S103: Input the target image into the target random forest model to obtain a defect detection result; wherein the training process of the target random forest model includes generating multiple types of defect images based on a generative adversarial network; determining a first data set based on the generation effect value of each type of defect image; and training the random forest model based on the first data set to obtain a target random forest model.

[0028] In this embodiment, the target image obtained above is input into the target random forest model to obtain a defect detection result, and the defect detection result is a defect detection result of the resistor to be detected.

[0029] The target random forest model is composed of multiple decision trees and is obtained by training the first data set. The data in the first data set includes a large number of defect-free images, various types of defect images, and defect type data corresponding to the defect images.

[0030] However, in the actual training process, it was found that the image data of defective resistors were relatively scarce. Therefore, the present disclosure adopts a generative adversarial network (GAN) to generate various types of defect images. Taking into account the influence of factors such as the characteristics of the defects themselves, training data, network structure and parameters, the effects of the generative adversarial network on the generation of various types of defect images are different. Therefore, in the process of training the random forest model, different weights should be given to the defect images generated in the data of each defect type and the real defect images. However, each decision tree in the random forest will randomly select a part of the features to find the optimal splitting point when the node splits, that is, the random forest implementation does not directly provide parameters for feature weights, so the present application considers changing the data composition in the data set (that is, the first data set) extracted by the random forest to achieve similar weight settings.

[0031] That is, the lower the generation effect value of a certain defect, the smaller the proportion of the generated defects in the defect data set of this type, the lower the probability of each decision tree in the random forest model to extract the defect image generated in this type of defect, and the more inclined to learn the real defect image in this type of defect, thus achieving a similar weight effect. The defect types of resistor sheets can include surface scratches, deformation, resistor body size deviation, pits, etc.

[0032] In this embodiment, the first data set may be determined in the following manner, wherein the first data set is determined based on the generation effect values ​​of each type of defect image, including: Determine the proportion of the generated defect images of the corresponding type in the defect image data set of the type based on the generation effect value of each type; Among them, the generated defect image is a defect image generated based on a generative adversarial network; and the first data set includes defect image data sets of various types.

[0033] In this embodiment, the generation effect value refers to a quantitative evaluation of the quality of each type of defect image generated by GAN, which can be obtained by calculating the Inception score or the Fréchet distance. The larger the Fréchet distance, the lower the generation effect value. The generation effect value can be determined according to the Fréchet distance through a simple mapping relationship, such as taking the inverse and normalizing it.

[0034] The process of determining the proportion of the corresponding type of generated defect images in the defect image data set of the type based on the generation effect value of each type can be determined by the first formula, which is: ,in Indicates the proportion of generated defect images in the defect image dataset of this type, Indicates the generation effect value of this type, Represents the scarcity coefficient, which is used to measure the scarcity of this type of real defect images. It is a preset parameter used to adjust the influence of the generated effect value on the proportion. represents the weight of the generated effect value, It is a bias term, which is used to ensure a certain proportion when the generated effect value is low.

[0035] in, , is the number of real defect images of this type, is the average number of real defect images of all types. The larger the value, the rarer the real defect images of this type are.

[0036] The logic of the first formula is It represents the comprehensive impact after considering the scarcity of real data and the generation effect value. When a certain type of real defect image is scarce and the generation effect value is high, the value of the numerator will be larger, indicating that the proportion of generated defect images should be higher to supplement the scarce real data. The denominator is normalized and is used to map the numerator to between 0 and 1.

[0037] Through the foregoing, the proportion of generated defect images and real defect images in each type of defect image data can be obtained, and the first data set can be obtained by mixing them.

[0038] From the above, it can be concluded that the present disclosure can more effectively highlight defect features and reduce noise interference by preliminarily screening suspected defect images and suspected non-defective images through image features, and then performing differentiated preprocessing on these two types of images. It not only improves the image quality, but also lays a solid foundation for subsequent model detection, thereby significantly improving the accuracy of resistor defect detection. In response to the problem of scarce real defect samples, the present disclosure uses a generative adversarial network to generate multiple types of defect images, effectively expands the training data set, and determines the data set for training the random forest model based on the generated results, so that the random forest model can better identify various defects and improve the accuracy and reliability of resistor defect detection.

[0039] In one embodiment of the present disclosure, a generative adversarial network includes a generator and a discriminator; The training process of generating adversarial networks includes: determining a generated noise of the generator based on the type of the generated defect image; Determine a first learning rate and a second learning rate based on the number of training rounds of the generative adversarial network, the first learning rate is a learning rate of the generator, and the second learning rate is a learning rate of the discriminator; The generative adversarial network is trained based on the multimodal loss function until the value of the multimodal loss function is less than the loss threshold or the number of training rounds of the generative adversarial network reaches the round threshold.

[0040] In this embodiment, the function of the generator is to generate various defect images of the resistor according to the input noise and other information, and the discriminator is responsible for judging whether the input image is real defect data or generated by the generator.

[0041] In the generative adversarial network, the parameters that should be determined are the generator's generated noise, the generator and discriminator's learning rates, the loss function, and the training termination condition.

[0042] In this embodiment, the determination process of generating noise is first discussed: Considering that there are many types of defects for resistors, and different types of defects have different characteristics and distributions, by determining the generated noise according to the defect image type, the generator can generate images that meet the requirements more specifically.

[0043] Specifically, noise is generated, including: uniformly distributed noise and normally distributed noise; The generated noise of the generator is determined based on the type of defect image generated, including: In response to the generated defect type being a regular class, determining a generated noise of the generator based on a first uniform weight and a first normal weight; In response to the generated defect type being a random class, determining a generated noise of the generator based on a second uniform weight and a second normal weight; Among them, the first uniform weight and the second uniform weight are both weights corresponding to uniformly distributed noise, the first normal weight and the second normal weight are both weights corresponding to normally distributed noise, the first uniform weight is smaller than the second uniform weight, and the first normal weight is larger than the second normal weight.

[0044] In this embodiment, regular defects include scratches and cracks, etc., and random defects include impurities and deformation, etc. A table can be preset to determine whether the defects of various resistors correspond to regular defects or random defects.

[0045] Regular defects have certain regularity, orderliness and predictability, while normal distribution noise has the characteristic of being concentrated near the mean, which can generate regular or patterned image features. Therefore, when generating regular defect images, giving normal distribution noise a larger weight (i.e., the first normal weight) can guide the generator to generate images that are more consistent with the characteristics of regular defects. The first normal weight and the first uniform weight can be set based on experience.

[0046] On the contrary, the characteristics of random defects are uncertainty and randomness. Uniformly distributed noise has uniform values ​​within a certain range, which can better reflect this randomness. Therefore, when generating random defect images, giving uniformly distributed noise a larger weight (i.e., the second uniform weight) is helpful to generate defect images with random characteristics. The second normal weight and the second uniform weight can be set based on experience.

[0047] Secondly, the learning rates of the generator and discriminator are discussed: The first learning rate and the second learning rate are determined based on the number of training rounds of the generative adversarial network, including: In response to the number of training rounds of the generative adversarial network being less than or equal to the third training round, using the first initial learning rate as the first learning rate and using the second initial learning rate as the second learning rate; In response to the number of training rounds of the generative adversarial network being greater than the third training round, the first learning rate and the second learning rate are reduced based on the number of training rounds.

[0048] In this embodiment, a fixed initial learning rate is used in the early stage of training, that is, when the number of training rounds is less than or equal to the third training round. This is because at the beginning of training, the parameters of the model are randomly initialized, and a relatively large and stable learning rate is required to allow the model to quickly adapt to the data, explore the parameter space, and initially establish the basic functions of the generator and the discriminator. Using a fixed initial learning rate can enable the model to learn at a relatively stable speed in the early stage of training, avoiding frequent changes in the learning rate that lead to unstable model training.

[0049] When the number of training rounds is greater than the third training round, the learning rate is reduced to allow the model to make more precise adjustments. The third training round can be determined according to the actual scenario. As the training progresses, the model has gradually approached the optimal solution. At this time, if the learning rate is still large, it will cause the model parameters to be updated too much, miss the optimal solution, and even cause the model to oscillate and fail to converge. By gradually reducing the learning rate based on the number of training rounds, the model can adjust parameters more smoothly when it is close to convergence, improve the accuracy and stability of the model, and thus better fit the data, improve the performance of the generative adversarial network, make the images it generates more realistic, and the discriminator has a stronger ability to distinguish between real images and generated images.

[0050] Specifically, the generator learning rate can be determined by the second formula, and the discriminator learning rate can be determined by the third formula. Second formula: , the third formula: ,in is the generator learning rate, is the first initial learning rate, To generate the decay rate, is the discriminator learning rate, is the second initial learning rate, To determine the attenuation rate, is the number of training rounds. , , , It can be obtained by fitting the data or set based on experience.

[0051] Finally, the loss function and training termination conditions are discussed: Multimodal loss functions, including: adversarial loss, adversarial loss weight, content loss, content loss weight, semantic loss, and semantic loss weight; A resistor defect detection method further comprising: In response to the number of training rounds of the generative adversarial network being greater than the first number of training rounds and the number of training rounds of the generative adversarial network being less than the second number of training rounds, reducing the adversarial loss weight based on the first adversarial step length, increasing the content loss weight based on the first content step length, and increasing the semantic loss weight based on the first semantic step length; Wherein, the first adversarial step is equal to the sum of the first content step and the first semantic step; In response to the number of training rounds of the generative adversarial network being greater than or equal to the second number of training rounds, reducing the adversarial loss weight based on the second adversarial step length, increasing the content loss weight based on the second content step length, and increasing the semantic loss weight based on the second semantic step length; The second adversarial step is equal to the sum of the second content step and the second semantic step, the first content step is greater than the second content step, and the first semantic step is less than the second semantic step.

[0052] In this embodiment, the multimodal loss function consists of adversarial loss, adversarial loss weight, content loss, content loss weight, semantic loss and semantic loss weight. Adversarial loss measures the degree of adversarial game between the generator and the discriminator; content loss focuses on the similarity between the generated image and the real image in content, such as pixel value, texture, etc.; semantic loss considers the semantic information of the image, such as the type and location of the resistor defect. The weight corresponding to each loss determines the relative importance of the loss term when calculating the total loss.

[0053] Semantic loss is an indicator used to measure the difference between generated images and real images at the semantic level. In the generative adversarial network for resistor defect detection, the main focus is on the semantic information related to the defects in the image, such as the type, location, size, etc. of the defects. The target detection algorithm is used to locate the defect target in the image and obtain the location, category and other information of the defect. For the real image and the generated image, the corresponding detection results are obtained by the target detection algorithm respectively, and then the semantic loss is calculated based on the difference in the detection results. For example, the error of the detected defect location, the accuracy of the category prediction, etc. can be calculated, and these indicators can be converted into loss values. For example, the mean square error (MSE) is used to calculate the loss of the defect location. Assuming that the real defect location is , the defect position detected in the generated image is , then the position loss can be expressed as: ,in is the number of defects, is the position loss.

[0054] In the early stage of training, that is, when the number of training rounds of the generative adversarial network is less than or equal to the first training round, no adjustment is made, because at this time the generative adversarial network needs to quickly learn the approximate distribution of the data, and the adversarial loss plays a key role in the convergence of the model, so it is given a larger weight; As the training progresses, when the generator is gradually able to generate more realistic images (that is, when the number of training rounds is greater than the first training round and less than the second training round), in order to further improve the quality and accuracy of the image, it is necessary to increase the weights of content loss (such as MSE loss and SSIM loss) and semantic loss so that the model pays more attention to the details, structure and semantic information of the image.

[0055] When the number of training rounds reaches or exceeds the second number of training rounds, the weights are further adjusted to reduce the increase in the content loss weights and increase the increase in the semantic loss weights (i.e., the first content step is greater than the second content step, and the first semantic step is less than the second semantic step). This is because in the later stages of training, the model has already learned the content of the image well, and paying more attention to semantic information can help the model more accurately generate images with semantic features such as specific defect types and locations. For example, for resistor defect detection, different types of defects (such as scratches, holes, etc.) can be generated more accurately and the locations of the defects can be accurately located. The first and second training rounds can be determined based on experience, but it should be noted that the first training round, the second training round, and the aforementioned third training round should all be less than the preset round threshold. The loss threshold and round threshold can be determined based on experience.

[0056] From the above, it can be concluded that the present invention, through the generator in the generative adversarial network, adjusts the weight of the generated noise according to the defect type, so that the generated defect image not only meets the characteristics of the specific defect, but also maintains the diversity and authenticity of the data, thereby improving the quality of the defect image, and providing more abundant and realistic training samples for the subsequent detection model, thereby improving the training effect of the random forest model, thereby improving the accuracy and reliability of resistor defect detection.

[0057] A high initial learning rate is used at the beginning of training, so that the generative adversarial network can quickly adapt to the data and initially establish the basic functions of the generator and discriminator. As the training progresses, the learning rate is gradually reduced, so that the generative adversarial network can make more detailed adjustments when it is close to the optimal solution, avoiding model oscillation and non-convergence problems caused by excessive learning rate, improving the training efficiency of the generative adversarial network, and enhancing the stability and accuracy of the generative adversarial network.

[0058] The multimodal loss function comprehensively considers adversarial loss, content loss and semantic loss. By dynamically adjusting the weights of these losses, the generated images can maintain similarity with real images while also having richer semantic information, thereby improving the accuracy of defective image data.

[0059] Corresponding to a resistor defect detection method of the above embodiment, Figure 2 This is a structural block diagram of a resistor defect detection device provided by an embodiment of the present disclosure. For ease of description, only the parts related to the embodiment of the present disclosure are shown. Figure 2 The resistor defect detection device 20 includes: a pre-detection module 21, a pre-processing module 22 and a defect detection module 23.

[0060] Wherein, the pre-detection module is used to determine the suspected defective image and the suspected non-defective image based on the image features of the first image, and the first image is the resistor sheet image to be detected; A preprocessing module, used for performing a first preprocessing on the suspected defective image and a second preprocessing on the suspected non-defective image to obtain a target image, wherein the processing method of the first preprocessing is different from the processing method of the second preprocessing; The defect detection module is used to input the target image into the target random forest model to obtain the defect detection result; wherein the training process of the target random forest model includes generating multiple types of defect images based on the generative adversarial network; determining the first data set based on the generation effect value of each type of defect image; and training the random forest model based on the first data set to obtain the target random forest model.

[0061] In one embodiment of the present disclosure, a generative adversarial network includes a generator and a discriminator; A resistor sheet defect detection device 20 further includes: a generative adversarial network training module for determining a generated noise of a generator based on the type of the generated defect image; Determine a first learning rate and a second learning rate based on the number of training rounds of the generative adversarial network, the first learning rate is a learning rate of the generator, and the second learning rate is a learning rate of the discriminator; The generative adversarial network is trained based on the multimodal loss function until the value of the multimodal loss function is less than the loss threshold or the number of training rounds of the generative adversarial network reaches the round threshold.

[0062] In one embodiment of the present disclosure, the multimodal loss function includes: adversarial loss, adversarial loss weight, content loss, content loss weight, semantic loss and semantic loss weight; A resistor defect detection device 20 further includes: a loss function weight adjustment module, configured to, in response to the number of training rounds of the generative adversarial network being greater than the first number of training rounds and the number of training rounds of the generative adversarial network being less than the second number of training rounds, reduce the adversarial loss weight based on the first adversarial step length, increase the content loss weight based on the first content step length, and increase the semantic loss weight based on the first semantic step length; Wherein, the first adversarial step is equal to the sum of the first content step and the first semantic step; In response to the number of training rounds of the generative adversarial network being greater than or equal to the second number of training rounds, reducing the adversarial loss weight based on the second adversarial step length, increasing the content loss weight based on the second content step length, and increasing the semantic loss weight based on the second semantic step length; The second adversarial step is equal to the sum of the second content step and the second semantic step, the first content step is greater than the second content step, and the first semantic step is less than the second semantic step.

[0063] In one embodiment of the present disclosure, generating noise includes: uniformly distributed noise and normally distributed noise; A generative adversarial network training module, specifically configured to determine a generated noise of a generator based on a first uniform weight and a first normal weight in response to the generated defect type being a rule class; In response to the generated defect type being a random class, determining a generated noise of the generator based on a second uniform weight and a second normal weight; Among them, the first uniform weight and the second uniform weight are both weights corresponding to uniformly distributed noise, the first normal weight and the second normal weight are both weights corresponding to normally distributed noise, the first uniform weight is smaller than the second uniform weight, and the first normal weight is larger than the second normal weight.

[0064] In one embodiment of the present disclosure, the generative adversarial network training module is further configured to, in response to the number of training rounds of the generative adversarial network being less than or equal to the third training round, use the first initial learning rate as the first learning rate and use the second initial learning rate as the second learning rate; In response to the number of training rounds of the generative adversarial network being greater than the third training round, the first learning rate and the second learning rate are reduced based on the number of training rounds.

[0065] In one embodiment of the present disclosure, the defect detection module 23 is specifically used to determine the proportion of the corresponding type of generated defect images in the defect image data set of the type based on the generation effect value of each type; Among them, the generated defect image is a defect image generated based on a generative adversarial network; and the first data set includes defect image data sets of various types.

[0066] In one embodiment of the present disclosure, the image features include: average gray value; The pre-detection module 21 is specifically configured to determine a region image in the first image whose average grayscale value is within a first numerical range as a suspected defect image; An area image in the first image whose average grayscale value is not within the first value interval is determined as a suspected defect-free image.

[0067] See also Figure 3 , Figure 3 A schematic block diagram of an electronic device provided by an embodiment of the present disclosure. Figure 3 The electronic device 300 in the embodiment shown may include: one or more processors 301, one or more input devices 302, one or more output devices 303 and one or more memories 304. The processors 301, input devices 302, output devices 303 and memories 304 communicate with each other via a communication bus 305. The memory 304 is used to store computer programs, which include program instructions. The processor 301 is used to execute the program instructions stored in the memory 304. The processor 301 is configured to call the program instructions to execute the functions of each module / unit in the above-mentioned device embodiments, such as Figure 2 The functions of the pre-detection module 21, the pre-processing module 22 and the defect detection module 23 are shown.

[0068] It should be understood that in the embodiment of the present disclosure, the processor 301 may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0069] The input device 302 may include a touch panel, a fingerprint collection sensor (for collecting the user's fingerprint information and fingerprint direction information), a microphone, etc., and the output device 303 may include a display (LCD, etc.), a speaker, etc.

[0070] The memory 304 may include a read-only memory and a random access memory, and provide instructions and data to the processor 301. A portion of the memory 304 may also include a non-volatile random access memory. For example, the memory 304 may also store information about the device type.

[0071] In a specific implementation, the processor 301, input device 302, and output device 303 described in the embodiments of the present disclosure can execute the implementation methods described in the first and second embodiments of a resistor defect detection method provided in the embodiments of the present disclosure, and can also execute the implementation methods of the electronic device described in the embodiments of the present disclosure, which will not be repeated here.

[0072] In another embodiment of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by the processor, all or part of the processes in the above-mentioned embodiment method are implemented, and the computer program can also be completed by instructing the relevant hardware through the computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc.

[0073] The computer-readable storage medium may be an internal storage unit of the electronic device of any of the aforementioned embodiments, such as a hard disk or memory of the electronic device. The computer-readable storage medium may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Furthermore, the computer-readable storage medium may also include both an internal storage unit of the electronic device and an external storage device. The computer-readable storage medium is used to store computer programs and other programs and data required by the electronic device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.

[0074] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this disclosure.

[0075] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the electronic devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0076] In the several embodiments provided in the present application, it should be understood that the disclosed electronic devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces or units, or it can be an electrical, mechanical or other form of connection.

[0077] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present disclosure.

[0078] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0079] The above are only specific embodiments of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present disclosure, and these modifications or replacements should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A resistor defect detection method, characterized in that: include: Determining a suspected defective image and a suspected non-defective image based on image features of a first image, wherein the first image is an image of a resistor sheet to be detected; Performing a first preprocessing on the suspected defective image and a second preprocessing on the suspected non-defective image to obtain a target image, wherein a processing method of the first preprocessing is different from a processing method of the second preprocessing; The target image is input into a target random forest model to obtain a defect detection result; wherein the training process of the target random forest model includes generating multiple types of defect images based on a generative adversarial network; determining a first data set based on generation effect values ​​of each type of defect image; and training the random forest model based on the first data set to obtain a target random forest model.

2. A resistor defect detection method as claimed in claim 1, characterized in that: The generative adversarial network includes a generator and a discriminator; The training process of the generative adversarial network includes: determining a generated noise of the generator based on the type of the generated defect image; Determine a first learning rate and a second learning rate based on the number of training rounds of the generative adversarial network, the first learning rate being a learning rate of the generator, and the second learning rate being a learning rate of the discriminator; The generative adversarial network is trained based on a multimodal loss function until a value of the multimodal loss function is less than a loss threshold or the number of training rounds of the generative adversarial network reaches a round threshold.

3. A resistor defect detection method as claimed in claim 2, characterized in that: The multimodal loss function includes: adversarial loss, adversarial loss weight, content loss, content loss weight, semantic loss and semantic loss weight; A resistor defect detection method further comprising: In response to the number of training rounds of the generative adversarial network being greater than the first number of training rounds and the number of training rounds of the generative adversarial network being less than the second number of training rounds, reducing the adversarial loss weight based on the first adversarial step length, increasing the content loss weight based on the first content step length, and increasing the semantic loss weight based on the first semantic step length; Wherein, the first adversarial step length is equal to the sum of the first content step length and the first semantic step length; In response to the number of training rounds of the generative adversarial network being greater than or equal to the second number of training rounds, reducing the adversarial loss weight based on a second adversarial step length, increasing the content loss weight based on a second content step length, and increasing the semantic loss weight based on a second semantic step length; The second adversarial step is equal to the sum of the second content step and the second semantic step, the first content step is greater than the second content step, and the first semantic step is less than the second semantic step.

4. A resistor defect detection method as claimed in claim 2, characterized in that: The generated noise includes: uniformly distributed noise and normally distributed noise; The step of determining the generated noise of the generator based on the type of the generated defect image comprises: In response to the generated defect type being a regular class, determining a generated noise of the generator based on a first uniform weight and a first normal weight; In response to the generated defect type being a random class, determining a generated noise of the generator based on a second uniform weight and a second normal weight; Among them, the first uniform weight and the second uniform weight are both weights corresponding to the uniformly distributed noise, the first normal weight and the second normal weight are both weights corresponding to the normally distributed noise, the first uniform weight is smaller than the second uniform weight, and the first normal weight is larger than the second normal weight.

5. A resistor defect detection method as claimed in claim 2, characterized in that: The determining of the first learning rate and the second learning rate based on the number of training rounds of the generative adversarial network comprises: In response to the number of training rounds of the generative adversarial network being less than or equal to a third training round, using the first initial learning rate as the first learning rate and using the second initial learning rate as the second learning rate; In response to the number of training rounds of the generative adversarial network being greater than a third training round, reducing the first learning rate and the second learning rate based on the number of training rounds.

6. A resistor defect detection method as claimed in claim 1, characterized in that: The determining of the first data set based on the generation effect values ​​of each type of defect image comprises: Determine the proportion of the generated defect images of the corresponding type in the defect image data set of the type based on the generation effect value of each type; Among them, the generated defect image is a defect image generated based on the generative adversarial network; the first data set includes various types of defect image data sets.

7. A resistor defect detection method as claimed in claim 1, characterized in that: The image features include: average gray value; The determining of the suspected defective image and the suspected non-defective image based on the image feature of the first image includes: Determine an area image in the first image whose average gray value is within a first value interval as a suspected defect image; An area image in the first image whose average grayscale value is not within the first value interval is determined as a suspected defect-free image.

8. A resistor defect detection device, characterized in that: include: A pre-detection module, used to determine a suspected defective image and a suspected non-defective image based on image features of a first image, wherein the first image is an image of a resistor sheet to be detected; A preprocessing module, configured to perform a first preprocessing on the suspected defective image and a second preprocessing on the suspected defect-free image to obtain a target image, wherein a processing method of the first preprocessing is different from a processing method of the second preprocessing; A defect detection module is used to input the target image into a target random forest model to obtain a defect detection result; wherein the training process of the target random forest model includes generating multiple types of defect images based on a generative adversarial network; determining a first data set based on the generation effect value of each type of defect image; and training the random forest model based on the first data set to obtain a target random forest model.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Composite material component defect detection method and device based on generative adversarial learning

    CN111833300A

  • Defect identification method for engineering nondestructive testing image and related equipment

    CN117314914A

  • Glass bottle defect generation method and device, electronic equipment and readable storage medium

    CN118587204A

  • Method and system for visual inspection of sensor chip

    JP2023115913A

  • Deep group disentangled embedding and network weight generation for visual inspection

    US20200097771A1