A method and device for detecting defects of a resistor chip, an electronic device, and a storage medium
By combining image feature screening and differentiated preprocessing to generate defect images by generating adversarial networks, the problem of scarcity of real samples in resistor chip defect detection is solved, and the accuracy and reliability of detection are improved.
Patent Information
- Application Number
- CN202510330981.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2045-03-20
AI Technical Summary
The prior art has scarce real defect samples in resistor chip defect detection, small data volume and unbalanced categories, resulting in poor generalization capabilities of the model and the inability to accurately detect various resistor chip defects.
By initially screening suspected defects and defect-free images based on image features, and performing differentiated preprocessing, combining the generation adversarial network to generate multiple types of defect images, expand the training data set, and use a random forest model for training, adjust the proportion of defective images in the data set to improve detection accuracy.
The accuracy and reliability of resistor chip defect detection are significantly improved. Through the combination of image preprocessing and generation and adversarial network, defect characteristics are effectively highlighted, noise interference is reduced, and the recognition ability of the model is improved.
Smart Images

Figure CN119850624B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure belongs to the technical field of defect detection, and more specifically, relates to a method and device for detecting resistor chip defects, an electronic device, and a storage medium. Background Art
[0002] In the field of electronic device manufacturing, as a basic and key electronic component, the quality of the resistor chip directly affects the performance and stability of the entire electronic device.
[0003] For the defect detection of resistor chips, although automated detection technologies are applied, there are limitations. Although machine learning algorithms have made certain progress, in the production process, the number of normal resistor chips is usually much larger than that of defective resistor chips. Therefore, in the actual scenario of resistor chip defect detection, real defect data is scarce, resulting in difficulties in collecting real defect samples, small data volume, and class imbalance, leading to poor model generalization ability and inability to accurately detect various resistor chip defects.
[0004] Therefore, an accurate and reliable method for detecting resistor chip defects is needed. Summary of the Invention
[0005] The purpose of the present disclosure is to provide a method and device for detecting resistor chip defects, an electronic device, and a storage medium, so as to improve the accuracy and reliability of resistor chip defect detection.
[0006] In the first aspect of the embodiments of the present disclosure, a method for detecting resistor chip defects is provided, including:
[0007] Determining a suspected defect image and a suspected non-defect image based on the image features of a first image, where the first image is an image of a resistor chip to be detected;
[0008] Performing a first preprocessing on the suspected defect image and a second preprocessing on the suspected non-defect image to obtain a target image, where the processing methods of the first preprocessing and the second preprocessing are different;
[0009] Inputting 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 various types of defect images based on a generative adversarial network; determining a first data set based on the generation effect values of the defect images of each type; and training a random forest model based on the first data set to obtain the target random forest model.
[0010] In the second aspect of the embodiments of the present disclosure, a device for detecting resistor chip defects is provided, including:
[0011] A pre-detection module for determining a suspected defect image and a suspected non-defect image based on the image features of a first image, where the first image is an image of a resistor chip to be detected;
[0012] A preprocessing module, configured to perform a first preprocessing on a suspected defective image and a second preprocessing on a suspected non-defective image to obtain a target image, wherein the processing method of the first preprocessing is different from that of the second preprocessing;
[0013] A defect detection module, configured 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 various types of defective images based on a generative adversarial network; determining a first data set based on the generation effect values of the defective images of each type; and training a random forest model based on the first data set to obtain the target random forest model.
[0014] In a third aspect of the embodiments of the present disclosure, there is provided an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the steps of the above-mentioned method for detecting defects in a resistor chip are implemented.
[0015] In a fourth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned method for detecting defects in a resistor chip are implemented.
[0016] The beneficial effects of the method, device, electronic device, and storage medium for detecting defects in a resistor chip provided by the embodiments of the present disclosure are as follows:
[0017] In the present disclosure, suspected defective images and suspected non-defective images are initially screened through image features, and then these two types of images are subjected to differential preprocessing, which can more effectively highlight defect features and reduce noise interference. This not only improves the image quality but also lays a solid foundation for subsequent model detection, thereby significantly improving the accuracy of resistor chip defect detection. In view of the problem of scarce real defect samples, the present disclosure uses a generative adversarial network to generate various types of defective images, effectively expanding the training data set, and determining the data set for training the random forest model based on the generated effects, enabling the random forest model to better identify various defects and improving the accuracy and reliability of resistor chip defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings in the following description are only some embodiments of the present disclosure. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0019] Figure 1 It is a schematic flowchart of a method for detecting defects in a resistor chip provided by an embodiment of the present disclosure;
[0020] Figure 2 The structural block diagram of a resistor chip defect detection device provided by an embodiment of the present disclosure;
[0021] Figure 3 The schematic block diagram of an electronic device provided by an embodiment of the present disclosure. Detailed implementation manners
[0022] In the following description, for the purpose of illustration rather than limitation, specific details such as specific system architectures, technologies, etc. are presented to thoroughly understand the embodiments of the present disclosure. However, those skilled in the art should understand that the present disclosure can also 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 unnecessary details from interfering with the description of the present disclosure.
[0023] To make the objectives, technical solutions, and advantages of the present disclosure clearer, the following will be described through specific embodiments with reference to the accompanying drawings.
[0024] Please refer to Figure 1 , Figure 1 The flowchart of a resistor chip defect detection method provided by an embodiment of the present disclosure, the method includes:
[0025] S101: Determine a suspected defective image and a suspected non-defective image based on the image features of a first image, where the first image is an image of a resistor chip to be detected.
[0026] In this embodiment, the first image refers to an image of a resistor chip that needs to be defect-detected, and can be obtained through a camera or a high-precision camera during the production process of the resistor chip. The image features can be the average gray value or the gray distribution, etc. The suspected defective image is a part of the image area that is preliminarily judged to possibly have defects after analyzing and processing the first image. It is only a preliminary judgment and does not necessarily mean that there are definitely defects, and further detection and verification are required. The suspected non-defective image, in contrast to the suspected defective image, is a part of the image area that is preliminarily judged not to have defects after analysis.
[0027] In this embodiment, the image features include: the average gray value; the suspected defective image and the suspected non-defective image can be determined by the following method:
[0028] Determining a suspected defective image and a suspected non-defective image based on the image features of the first image includes:
[0029] Determine the area image in the first image whose average gray value is within the first numerical interval as the suspected defective image;
[0030] Determine the area image in the first image whose average gray value is not within the first numerical range as the suspected defect-free image.
[0031] In this embodiment, the average gray value can be obtained by summing the gray values of all pixels in the image and then dividing by the total number of pixels. The first numerical range can be determined based on the average gray value of the images when a large number of resistor chips have defects or set according to experience.
[0032] This embodiment takes into account that when a resistor chip has a defect, its physical structure or surface characteristics will change, which will cause the optical reflection or absorption characteristics of this area to be different from those of the normal area. From the perspective of the image, this difference will be reflected in the gray value.
[0033] For example, when there are defects such as scratches, cracks or impurities on the surface of the resistor chip, these areas may absorb more light, thus showing a lower gray value in the image; while if there are defects such as protrusions or reflections, this area may reflect more light, resulting in a higher gray value. Therefore, by determining whether the average gray value of the image is within the preset first numerical range, it is possible to preliminarily determine whether there may be defects in certain areas.
[0034] S102: Perform a first preprocessing on the suspected defect image and a second preprocessing on the suspected defect-free image to obtain a target image. The processing methods of the first preprocessing and the second preprocessing are different.
[0035] In this embodiment, the first preprocessing is the preprocessing for the suspected defect image, and the second preprocessing is for the suspected defect-free image. Since the suspected defect image and the suspected defect-free image have different characteristics, different processing methods need to be used to better retain or highlight their respective characteristics. Therefore, the processing methods of the first preprocessing and the second preprocessing are different.
[0036] The first preprocessing can be enhancement processing, denoising and sharpening, and the second preprocessing can be normalization processing and filtering.
[0037] Specifically, the first preprocessing is to enhance the local contrast of the image by methods such as contrast-limited adaptive histogram equalization to highlight the detailed information of the defects, making the defect features that may not be obvious originally clearer. Secondly, a median filter is used to remove salt-and-pepper noise, etc. Then, a sharpening filter, such as the Laplacian operator or the Sobel operator, is used to sharpen the image to enhance the edge information of the defects, which helps to accurately identify the shape and boundary of the defects subsequently. The second preprocessing is to perform normalization, mapping the pixel values to a specific range, such as [0, 1] or [-1, 1] to eliminate the brightness differences caused by factors such as illumination between different images, facilitating subsequent feature extraction and model processing. Secondly, a mean filter or a Gaussian filter is used for smoothing to reduce the noise in the image and make the image smoother, which is beneficial to the subsequent extraction of features such as normal textures.
[0038] The target image is the image obtained after the first preprocessing and the second preprocessing of the first image. Specifically, it can be understood that the target image is the image obtained after the first preprocessing of the suspected defect image in the first image and the image obtained after the second preprocessing of the suspected defect-free image in the first image, and the image obtained by splicing these two images.
[0039] By performing targeted preprocessing on the suspected defect image and the suspected defect-free image respectively, the obtained target image can better meet the input requirements of the model and improve the accuracy of defect detection.
[0040] S103: Input the target image into the target random forest model to obtain the defect detection result; among them, the training process of the target random forest model includes generating various types of defect images based on the generative adversarial network; determining the first data set based on the generation effect values 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.
[0041] In this embodiment, inputting the obtained target image into the target random forest model can obtain the defect detection result, and the defect detection result is the defect detection result of the resistor sheet to be detected.
[0042] The target random forest model is composed of multiple decision trees and is trained by 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.
[0043] However, in the actual training process, it is found that the image data of defective resistor chips is relatively scarce. Therefore, this disclosure uses a Generative Adversarial Network (GAN) to generate defective images of various types. Considering the influence of factors such as the characteristics of the defects themselves, training data, network structure, and parameters, the generation effects of the GAN on defective images of various types are different. Therefore, different weights should be assigned to the defective images generated in the data of each defect type and the real defective images during the training of the random forest model. However, each decision tree in the random forest randomly selects a part of the features to find the optimal splitting point when splitting nodes, that is, there is no parameter directly providing feature weights in the random forest implementation. Therefore, this application considers implementing a similar weight setting by changing the data composition in the data set (i.e., the first data set) extracted by the random forest.
[0044] That is, the lower the generation effect value for a certain defect, the smaller the proportion of the generated defective quantity in the defective data set of this type, the lower the extraction probability of each decision tree in the random forest model for the defective images generated in this type of defect, and the more inclined to learn the real defective images in this type of defect, thus achieving a similar weight effect. The defect types of the resistor chips can include surface scratches, deformations, resistor body size deviations, pits, etc.
[0045] In this embodiment, the first data set can be determined in the following manner. The first data set is determined based on the generation effect values of defective images of various types, including:
[0046] Determine the proportion of the generated defective images of the corresponding type in the defective image data set of this type based on the generation effect values of various types;
[0047] Among them, the generated defective images are defective images generated based on the generative adversarial network; the first data set includes defective image data sets of various types.
[0048] In this embodiment, the generation effect value refers to a quantitative evaluation of the quality of defective images of each type generated by the GAN, which can be obtained by calculating the Inception score or the Frechet distance. The larger the Frechet distance, the lower the generation effect value. The generation effect value can be determined according to the Frechet distance through a simple mapping relationship, such as taking the reciprocal and normalizing, etc.
[0049] The process of determining the proportion of the generated defective images of the corresponding type in the defective image data set of this type based on the generation effect values of various types can be determined by the first formula. The first formula is:
[0050] , where represents the proportion of the generated defective images in the defective image data set of this type, Represents the generation effect value of this type, Represents the scarcity degree coefficient, which is used to measure the scarcity degree of real defect images of this type, Is a preset parameter, which is used to adjust the influence degree of the generation effect value on the proportion, Represents the weight of the generation effect value, Is a bias term, which is used to ensure a certain proportion even when the generation effect value is low.
[0051] Among them, , Is the number of real defect images of this type, Is the average number of real defect images of all types. The larger it is, the scarcer the real defect images of this type are.
[0052] The logic of the first formula is Represents the comprehensive influence after considering the scarcity degree of real data and the generation effect value. When the real defect images of a certain type are scarce and the generation effect value is high, the value of the numerator will be large, indicating that the proportion of generated defect images should be high to supplement the scarce real data. The denominator is for normalization, which is used to map the numerator to between 0 and 1.
[0053] After the above, the proportions of generated defect images and real defect images in the defect image data of each type can be obtained. Mixing them can obtain the first data set.
[0054] It can be concluded from the above that the present disclosure preliminarily screens suspected defect images and suspected non-defect images through image features, and then performs differential preprocessing on these two types of images, which can more effectively highlight defect features and reduce noise interference. It not only improves the image quality, but also lays a solid foundation for subsequent model detection, thus significantly improving the accuracy of resistor chip defect detection. Aiming at the problem of scarce real defect samples, the present disclosure uses a generative adversarial network to generate various types of defect images, effectively expanding the training data set, and determining the data set for training the random forest model according to the generation effect, so that the random forest model can better identify various defects and improve the accuracy and reliability of resistor chip defect detection.
[0055] In an embodiment of the present disclosure, the generative adversarial network includes a generator and a discriminator;
[0056] The training process of the generative adversarial network includes:
[0057] Determine the generation noise of the generator based on the type of generated defect images;
[0058] Determine a first learning rate and a second learning rate based on the number of training rounds of the generative adversarial network, where the first learning rate is the learning rate of the generator and the second learning rate is the learning rate of the discriminator;
[0059] Train the generative adversarial network based on the multi-modal loss function until the value of the multi-modal loss function is less than the loss threshold or the number of training rounds of the generative adversarial network reaches the round threshold.
[0060] In this embodiment, the role of the generator is to generate various defect images of the resistor chip according to information such as the input noise, and the discriminator is responsible for determining whether the input image is real defect data or generated by the generator.
[0061] In the generative adversarial network, the parameters to be determined include the generated noise of the generator, the learning rates of the generator and the discriminator, the loss function, and the training termination condition.
[0062] In this embodiment, first, the determination process of the generated noise is discussed:
[0063] Considering that for resistor chips, there are various types of defects, and different types of defects have different characteristics and distributions. By determining the generated noise according to the type of defect image, the generator can generate images that meet the requirements more targeted.
[0064] Specifically, the generated noise includes: uniformly distributed noise and normally distributed noise;
[0065] Determine the generated noise of the generator based on the type of the generated defect image, including:
[0066] In response to the generated defect type being a regular type, determine the generated noise of the generator based on the first uniform weight and the first normal weight;
[0067] In response to the generated defect type being a random type, determine the generated noise of the generator based on the second uniform weight and the second normal weight;
[0068] Wherein, 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 less than the second uniform weight, and the first normal weight is greater than the second normal weight.
[0069] In this embodiment, the regular types include scratches and cracks, etc., and the random type defects include impurities and deformations, etc. A table can be preset to determine whether the defects of various resistors correspond to regular types or random types.
[0070] Rule - type defects have a certain regularity, orderliness, and predictability, while normal - distribution noise has the characteristic of concentrating around the mean and can generate image features with patterns or regularities. Therefore, when generating images of rule - type defects, assigning a relatively large weight to the normal - distribution noise (i.e., the first normal weight) can guide the generator to generate images that better conform to the characteristics of rule - type defects. The first normal weight and the first uniform weight can be set according to experience.
[0071] On the contrary, random - type defects are characterized by uncertainty and randomness. Uniform - distribution noise takes values evenly within a certain range and can better reflect this randomness. Therefore, when generating images of random - type defects, giving a relatively large weight to the uniform - distribution noise (i.e., the second uniform weight) helps to generate defect images with random characteristics. The second normal weight and the second uniform weight can be set according to experience.
[0072] Secondly, the learning rates of the generator and the discriminator are discussed:
[0073] Determining the first learning rate and the second learning rate based on the number of training rounds of the generative adversarial network, including:
[0074] In response to the number of training rounds of the generative adversarial network being less than or equal to the third training round, taking the first initial learning rate as the first learning rate and the second initial learning rate as the second learning rate;
[0075] In response to the number of training rounds of the generative adversarial network being greater than the third training round, reducing the first learning rate and the second learning rate based on the number of training rounds.
[0076] In this embodiment, considering that in the initial stage of training, that is, when the number of training rounds is less than or equal to the third training round, a fixed initial learning rate is used. 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 enable 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 training and avoid the instability of model training caused by frequent changes in the learning rate.
[0077] After the number of training rounds is greater than the third training round, reducing the learning rate is to allow the model to make more refined adjustments, and 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 the parameters more smoothly when approaching convergence, improve the accuracy and stability of the model, so as to better fit the data, improve the performance of the generative adversarial network, make the generated images more realistic, and the discriminator's ability to distinguish between real images and generated images is also stronger.
[0078] Specifically, the learning rate of the generator can be determined by the second formula, and the learning rate of the discriminator can be determined by the third formula. The second formula: , the third formula: , where is the learning rate of the generator, is the first initial learning rate, is the generation decay rate, is the learning rate of the discriminator, is the second initial learning rate, is the discriminant decay rate, is the number of training rounds. 、 、 、 can be obtained by fitting the data or set according to experience.
[0079] Finally, the loss function and the training termination condition are discussed:
[0080] The multi-modal loss function includes: adversarial loss, adversarial loss weight, content loss, content loss weight, semantic loss, and semantic loss weight;
[0081] A method for detecting resistor chip defects further includes:
[0082] In response to the number of training rounds of the generative adversarial network being greater than the first training round and less than the second training round, reducing the adversarial loss weight based on the first adversarial step size, increasing the content loss weight based on the first content step size, and increasing the semantic loss weight based on the first semantic step size;
[0083] wherein, the first adversarial step size is equal to the sum of the first content step size and the first semantic step size;
[0084] In response to the number of training rounds of the generative adversarial network being greater than or equal to the second training round, reducing the adversarial loss weight based on the second adversarial step size, increasing the content loss weight based on the second content step size, and increasing the semantic loss weight based on the second semantic step size;
[0085] Among them, the second adversarial step size is equal to the sum of the second content step size and the second semantic step size. The first content step size is greater than the second content step size, and the first semantic step size is less than the second semantic step size.
[0086] In this embodiment, the multi-modal loss function consists of adversarial loss, adversarial loss weight, content loss, content loss weight, semantic loss, and semantic loss weight. The adversarial loss measures the degree of adversarial game between the generator and the discriminator; the content loss focuses on the similarity between the generated image and the real image in terms of content, such as pixel values, textures, etc.; the semantic loss considers the semantic information of the image, such as the type, location, etc. of the resistor chip defect. The weights corresponding to each loss determine the relative importance of the loss term when calculating the total loss.
[0087] Semantic loss is an index used to measure the difference between the generated image and the real image at the semantic level. In the generative adversarial network for resistor chip defect detection, it mainly focuses on the semantic information related to defects in the image, such as the differences in the type, location, size, etc. of the defects. The object detection algorithm is used to locate the defect targets in the image and obtain information such as the location and category of the defects. For the real image and the generated image, the corresponding detection results are obtained respectively through the object detection algorithm, and then the semantic loss is calculated according to the differences 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 indexes are converted into loss values. For example, the mean square error (MSE) is used to calculate the loss of the defect location. Suppose the real defect location is , and the detected defect location in the generated image is , then the location loss can be expressed as: , where is the number of defects, is the location loss.
[0088] In the initial 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 number, no adjustment is made because at this time the generative adversarial network needs to quickly learn the general distribution of the data, and the adversarial loss plays a key role in the convergence of the model, so a larger weight is given;
[0089] As the training progresses, when the generator can gradually generate more realistic images (that is, when the number of training rounds is greater than the first training round number and less than the second training round number), in order to further improve the quality and accuracy of the images, it is necessary to increase the weights of the content loss (such as MSE loss and SSIM loss) and the semantic loss, so that the model pays more attention to the details, structure, and semantic information of the images.
[0090] When the number of training rounds reaches or exceeds the second training round, the weights are further adjusted to reduce the increasing amplitude of the content loss weight and increase the increasing amplitude of the semantic loss weight (i.e., the first content step size is greater than the second content step size, and the first semantic step size is less than the second semantic step size). This is because in the later stage of training, the model has already learned the content of the image well. At this time, paying more attention to semantic information can help the model generate images with semantic features such as specific defect types and positions more accurately. For example, for the defect detection of resistor chips, it can generate different types of defects (such as scratches, holes, etc.) more accurately and locate the positions of the defects accurately. The first training round and the second training round can be determined according to experience. However, 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 the round threshold can be determined according to experience.
[0091] As can be seen from the above, the present disclosure adjusts the weight of the generated noise according to the defect type through the generator in the generative adversarial network, so that the generated defect images not only conform to the characteristics of specific defects, but also maintain the diversity and authenticity of the data, improve the quality of the defect images, provide richer and more real training samples for the subsequent detection model, and thus improve the training effect of the random forest model, thereby improving the accuracy and reliability of the resistor chip defect detection.
[0092] A relatively high initial learning rate is adopted at the initial stage of training, so that the generative adversarial network can quickly adapt to the data and initially establish the basic functions of the generator and the discriminator. As the training progresses, the learning rate is gradually reduced, so that the generative adversarial network can make more refined adjustments when approaching the optimal solution, avoiding problems such as model oscillation and non-convergence caused by too large a learning rate, improving the training efficiency of the generative adversarial network, and enhancing the stability and accuracy of the generative adversarial network.
[0093] The multi-modal loss function comprehensively considers the adversarial loss, the content loss, and the semantic loss. By dynamically adjusting the weights of these losses, the generated images not only maintain similarity with the real images, but also have richer semantic information, improving the accuracy of the defect image data.
[0094] Corresponding to the resistor chip defect detection method in the above embodiment, Figure 2 This is a structural block diagram of a resistor chip defect detection device provided by an embodiment of the present disclosure. For the sake of convenience of description, only the parts related to the embodiments of the present disclosure are shown. Refer to Figure 2 As shown in, the resistor chip defect detection device 20 includes: a pre-detection module 21, a pre-processing module 22, and a defect detection module 23.
[0095] Among them, a pre-detection module is used to determine suspected defective images and suspected non-defective images based on the image features of the first image, and the first image is an image of a resistor chip to be detected;
[0096] A preprocessing module is used to perform a first preprocessing on the suspected defective images and a second preprocessing on the suspected non-defective images to obtain target images, and the processing methods of the first preprocessing and the second preprocessing are different;
[0097] A defect detection module is used to input the target image into the target random forest model to obtain a defect detection result; among them, the training process of the target random forest model includes generating various types of defective images based on a generative adversarial network; determining a first data set based on the generation effect values of the defective images of each type; and training the random forest model based on the first data set to obtain the target random forest model.
[0098] In an embodiment of the present disclosure, the generative adversarial network includes a generator and a discriminator;
[0099] A resistor chip defect detection device 20 further includes: a generative adversarial network training module, which is used to determine the generation noise of the generator based on the types of the generated defective images;
[0100] Determine a first learning rate and a second learning rate based on the number of training rounds of the generative adversarial network, where the first learning rate is the learning rate of the generator and the second learning rate is the learning rate of the discriminator;
[0101] Train the generative adversarial network based on a multi-modal loss function until the value of the multi-modal loss function is less than a loss threshold or the number of training rounds of the generative adversarial network reaches a round threshold.
[0102] In an embodiment of the present disclosure, the multi-modal loss function includes: adversarial loss, adversarial loss weight, content loss, content loss weight, semantic loss, and semantic loss weight;
[0103] A resistor chip defect detection device 20 further includes: a loss function weight adjustment module, which is used to respond to the number of training rounds of the generative adversarial network being greater than a first training round and less than a second training round, reduce the adversarial loss weight based on a first adversarial step size, increase the content loss weight based on a first content step size, and increase the semantic loss weight based on a first semantic step size;
[0104] Among them, the first adversarial step size is equal to the sum of the first content step size and the first semantic step size;
[0105] In response to the number of training rounds of the generative adversarial network being greater than or equal to the second training round, reduce the adversarial loss weight based on the second adversarial step size, increase the content loss weight based on the second content step size, and increase the semantic loss weight based on the second semantic step size;
[0106] Wherein, the second adversarial step size is equal to the sum of the second content step size and the second semantic step size, the first content step size is greater than the second content step size, and the first semantic step size is less than the second semantic step size.
[0107] In an embodiment of the present disclosure, the generated noise includes: uniformly distributed noise and normally distributed noise;
[0108] The generative adversarial network training module is specifically configured to, in response to the generated defect type being a regular type, determine the generated noise of the generator based on the first uniform weight and the first normal weight;
[0109] In response to the generated defect type being a random type, determine the generated noise of the generator based on the second uniform weight and the second normal weight;
[0110] Wherein, both the first uniform weight and the second uniform weight are the weights corresponding to the uniformly distributed noise, both the first normal weight and the second normal weight are the weights corresponding to the normally distributed noise, the first uniform weight is less than the second uniform weight, and the first normal weight is greater than the second normal weight.
[0111] In an embodiment of the present disclosure, the generative adversarial network training module is specifically 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 the second initial learning rate as the second learning rate;
[0112] In response to the number of training rounds of the generative adversarial network being greater than the third training round, reduce the first learning rate and the second learning rate based on the number of training rounds.
[0113] In an embodiment of the present disclosure, the defect detection module 23 is specifically configured to determine the proportion of the generated defect images of the corresponding type in the defect image dataset of the corresponding type based on the generation effect values of each type;
[0114] Wherein, the generated defect images are defect images generated based on the generative adversarial network; the first dataset includes defect image datasets of each type.
[0115] In an embodiment of the present disclosure, the image features include: average gray value;
[0116] The pre-detection module 21 is specifically configured to determine the regional image in the first image with the average gray value within the first numerical range as the suspected defect image;
[0117] Determine the area image in the first image whose average gray value is not within the first numerical range as a suspected defect-free image.
[0118] See Figure 3 , Figure 3 which is a schematic block diagram of an electronic device provided by an embodiment of the present disclosure. As Figure 3 shown, the electronic device 300 in this embodiment 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 above-mentioned processors 301, input devices 302, output devices 303, and memories 304 communicate with each other through a communication bus 305. The memory 304 is used to store computer programs, and the computer programs include program instructions. The processor 301 is used to execute the program instructions stored in the memory 304. Among them, 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 preprocessing module 22, and the defect detection module 23 shown.
[0119] It should be understood that in the embodiments of the present disclosure, the so-called processor 301 may be a central processing unit (CPU), and this processor may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or this processor may also be any conventional processor, etc.
[0120] The input device 302 may include a touchpad, a fingerprint acquisition sensor (for acquiring the fingerprint information and the direction information of the fingerprint of the user), a microphone, etc., and the output device 303 may include a display (such as an LCD), a speaker, etc.
[0121] The memory 304 may include a read-only memory and a random access memory, and provide instructions and data to the processor 301. A part 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.
[0122] In a specific implementation, the processor 301, input device 302, and output device 303 described in the embodiments of the present disclosure may execute the implementation manners described in the first and second embodiments of a method for detecting defects in resistor chips provided by the embodiments of the present disclosure, and may also execute the implementation manner of the electronic device described in the embodiments of the present disclosure, which will not be elaborated herein.
[0123] In another embodiment of the present disclosure, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and the computer program includes program instructions. When the program instructions are executed by a processor, all or part of the processes in the methods of the above embodiments are implemented. It can also be completed by instructing relevant hardware through the computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal, and software distribution medium, etc.
[0124] The computer-readable storage medium may be an internal storage unit of the electronic device in any of the foregoing embodiments, such as the 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, smart media card (SMC), secure digital (SD) card, flash card, etc. equipped on the electronic device. Further, the computer-readable storage medium may also include both the internal storage unit and the external storage device of the electronic device. The computer-readable storage medium is used to store the computer program and other programs and data required by the electronic device. The computer-readable storage medium may also be used to temporarily store the data that has been output or will be output.
[0125] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this disclosure.
[0126] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the above-described electronic devices and units can refer to the corresponding processes in the foregoing method embodiments, and will not be described herein again.
[0127] In several embodiments provided in this 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 merely illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed couplings or direct couplings or communication connections to each other can be indirect couplings or communication connections through some interfaces or units, or can be electrical, mechanical, or other forms of connection.
[0128] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiments of this disclosure.
[0129] In addition, the functional units in various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0130] The above is only the specific implementation manner of this disclosure, but the protection scope of this disclosure is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or substitutions within the technical scope disclosed by this disclosure, and these modifications or substitutions should be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be subject to the protection scope of the claims.
Claims
1. A method for detecting defects of a resistor chip, characterized in that, Including: Determine a suspected defective image and a suspected non-defective image based on the image features of a first image, where the first image is an image of a resistor chip to be detected; Perform a first preprocessing on the suspected defective image and a second preprocessing on the suspected non-defective image to obtain a target image, where the processing method of the first preprocessing is different from that of the second preprocessing; The target image is an image obtained by splicing the image of the suspected defective image in the first image after the first preprocessing and the image of the suspected non-defective image in the first image after the second preprocessing; Input the target image into a target random forest model to obtain a defect detection result; where the training process of the target random forest model includes generating various types of defective images based on a generative adversarial network; determining a first data set based on the generation effect values of the defective images of each type; and training a random forest model based on the first data set to obtain the target random forest model.
2. The method for detecting defects of a resistor chip according to claim 1, characterized in that The generative adversarial network includes a generator and a discriminator; The training process of the generative adversarial network includes: Determine the generation noise of the generator based on the type of the generated defective image; Determine a first learning rate and a second learning rate based on the training rounds of the generative adversarial network, where the first learning rate is the learning rate of the generator and the second learning rate is the learning rate of the discriminator; Train the generative adversarial network based on a multi-modal loss function until the value of the multi-modal loss function is less than a loss threshold or the training rounds of the generative adversarial network reach a round threshold.
3. The method for detecting defects of a resistor chip according to claim 2, wherein, The multi-modal loss function includes: adversarial loss, adversarial loss weight, content loss, content loss weight, semantic loss, and semantic loss weight; A method for detecting defects in a resistor chip further includes: In response to the training rounds of the generative adversarial network being greater than a first training round and less than a second training round, reduce the adversarial loss weight based on a first adversarial step size, increase the content loss weight based on a first content step size, and increase the semantic loss weight based on a first semantic step size; Wherein, the first adversarial step size is equal to the sum of the first content step size and the first semantic step size; In response to the training rounds of the generative adversarial network being greater than or equal to the second training round, reduce the adversarial loss weight based on a second adversarial step size, increase the content loss weight based on a second content step size, and increase the semantic loss weight based on a second semantic step size; Wherein, the second adversarial step size is equal to the sum of the second content step size and the second semantic step size, the first content step size is greater than the second content step size, and the first semantic step size is less than the second semantic step size.
4. The method for detecting defects of a resistor chip according to claim 2, wherein The generation noise includes: uniformly distributed noise and normally distributed noise; The determining the generation noise of the generator based on the type of the generated defective image includes: In response to the generated defect type being a regular type, determine the generation 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 type, determine the generation 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 less than the second uniform weight, and the first normal weight is greater than the second normal weight.
5. The method for detecting defects of a resistor chip according to claim 2, characterized in that, Determining the first learning rate and the second learning rate based on the number of training rounds of the generative adversarial network includes: In response to the number of training rounds of the generative adversarial network being less than or equal to the third training round, taking the first initial learning rate as the first learning rate and taking 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, reducing the first learning rate and the second learning rate based on the number of training rounds.
6. The method for detecting defects of a resistor chip according to claim 1, wherein Determining the first data set based on the generation effect values of defect images of each type includes: Determining the proportion of the generated defect images of the corresponding type in the defect image data set of this type based on the generation effect values of each type; Among them, the generated defect images are defect images generated based on the generative adversarial network; the first data set includes defect image data sets of each type.
7. The method for detecting defects of a resistor chip according to claim 1, wherein The image features include: average gray value; Determining the suspected defect image and the suspected non-defect image based on the image features of the first image includes: Determining the regional image of the first image with the average gray value within the first numerical interval as the suspected defect image; Determining the regional image of the first image with the average gray value not within the first numerical interval as the suspected non-defect image.
8. A resistor chip defect detection device, characterized in that, Including: A pre-detection module for determining the suspected defect image and the suspected non-defect image based on the image features of the first image, where the first image is a resistor chip image to be detected; A preprocessing module for performing a first preprocessing on the suspected defect image and a second preprocessing on the suspected non-defect image to obtain a target image, where the processing method of the first preprocessing is different from the processing method of the second preprocessing; The target image is an image obtained by splicing the image of the suspected defect image in the first image after the first preprocessing and the image of the suspected non-defect image in the first image after the second preprocessing; A defect detection module for inputting the target image into the target random forest model to obtain a defect detection result; among them, the training process of the target random forest model includes generating various types of defect images based on the generative adversarial network; determining the first data set based on the generation effect values of defect images of each type; training the random forest model based on the first data set to obtain the 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 the processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
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