Method and device for judging defect of object
The machine learning model established through the ternary loss supervised learning algorithm uses the dissimilarity value to determine object defects, solving the problems of high defect judgment error rate and "overkill" in the existing technology, and achieving more accurate and consistent defects. Judgment, applicable to a variety of objects and parts.
Patent Information
- Application Number
- CN202010080289.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2019-12-30
- Filing Date
- 2020-02-05
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2040-02-05
AI Technical Summary
Existing industrial automation technology is prone to "overkill" problems in defect judgment, and artificial intelligence technology is difficult to train an effective defect classification model when the amount of data is insufficient, resulting in a high judgment error rate.
The ternary loss supervised learning algorithm is used to establish a shared machine learning algorithm model. Good products, defective products and good product template data are used as training data sets to calculate the dissimilarity value to judge the defects of the object. It is suitable for a variety of objects and parts, which reduces the model development time for different objects, and can still make effective judgments when the amount of data is insufficient.
It reduces the error rate of defect judgment, reduces the "overkill" phenomenon, and improves the accuracy and consistency of judgment. It is suitable for a variety of objects and parts, and is especially effective when performing secondary inspections based on automatic optical inspection technology.
Smart Images

Figure CN113125440B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a technology for automatically judging object defects, and more particularly to a method for automatically judging object defects using an artificial intelligence algorithm and a device for implementing the method. Background Art
[0002] In the field of industrial automation, due to the booming development of industrial Internet of Things, collaborative robots and artificial intelligence technologies, manufacturing companies hope to use image recognition technologies such as automated robots and automated optical inspection (AOI) to replace manual operations, which can not only save production costs but also improve defect recognition rate.
[0003] However, since industrial automation technology strictly follows the predetermined inspection standards in defect judgment, when the inspection standards are too high and lead to the so-called "over-kill (many inspected objects are considered defective objects due to over-high inspection standards)", additional manpower is still needed to conduct a second inspection on these objects that are considered defective, so as to redefine the products that are over-killed by the instruments using industrial automation technology back to good objects. Therefore, many companies are trying to introduce artificial intelligence into industrial automation technology, hoping to make the judgment results of the inspected objects more accurate, rapid and consistent.
[0004] However, the artificial intelligence technology currently used usually manually classifies different types of objects or parts on the circuit board, and then uses machine learning algorithms to establish a supervised binary classification model that can distinguish whether each object or part is normal or defective based on the large amount of classified information. If the amount of data for certain types of objects or parts is insufficient, it is difficult for artificial intelligence technology to train a model that can well classify the defects of such objects / parts, resulting in a high error rate in defect judgment. Summary of the invention
[0005] The present invention provides a method and device for determining defects of an object, which can be applied to a variety of objects, circuit elements or parts at the same time, and utilizes a ternary artificial intelligence algorithm to automatically determine defects of the object, so that the embodiment of the present invention is more versatile and can further reduce the error rate in defect determination based on the original automatic optical inspection technology.
[0006] The defect judgment method of an object according to an embodiment of the present invention comprises the following steps: obtaining a test image of the test object, obtaining selected good sample data corresponding to the test object, and calculating the dissimilarity value between the test image and the selected good sample data using a dissimilarity model, and judging whether the test object is a good product or a defective product according to the dissimilarity value.
[0007] The defect judgment device of an object in an embodiment of the present invention includes an object database, an image source device and a processor. The object database has at least one good sample data corresponding to a plurality of objects. The image source device obtains a tested image of the tested object. The processor is coupled to the object database and the image source device. The processor obtains the tested image of the tested object through the image source device, and obtains the selected good sample data in the training data set corresponding to the tested object. And, the processor calculates the dissimilarity value between the tested image and the selected good sample data using a dissimilarity model, and judges whether the tested object is a good product or a defective product according to the dissimilarity value.
[0008] Based on the above, the embodiment of the present invention uses different types of objects / parts to establish a shared machine learning algorithm model to automatically judge the defects of objects, so that it can be applied to a variety of objects, circuit elements or parts at the same time, and further reduce the error rate in defect judgment on the basis of the original automatic optical inspection technology. Therefore, the embodiment of the present invention does not need to establish different machine learning algorithm models for different objects / parts, which can reduce the development time of defect classification models for new objects / parts when new production lines are established, and can also establish a more effective machine learning algorithm model when the amount of good product data and defective product data of new objects / parts is insufficient. In addition, secondary inspection based on the automatic optical inspection and recognition technology that has been performed can reduce the so-called "overkill" situation. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 It is a hardware block diagram of a defect judgment device for an object according to some embodiments of the present invention.
[0010] Figure 2 It is a schematic diagram of the operation of a method for determining a defect of an object and a corresponding device according to some embodiments of the present invention.
[0011] Figure 3 It is a flow chart of a method for determining a defect of an object according to some embodiments of the present invention.
[0012] Figure 4A and Figure 4B It is a schematic diagram of using the ternary loss supervised learning algorithm to establish and adjust the dissimilarity model f.
[0013] Figure 5 The first embodiment Figure 2 Schematic diagram of the internal flow of the triplet loss supervised learning algorithm.
[0014] Figure 6 According to some embodiments of the present invention, Figure 3 Schematic diagram of the process of step S350.
[0015] Figure 7It is a schematic diagram for illustrating defective product data, good product data and good product sample data of two objects according to some embodiments of the present invention.
[0016] Figure 8 According to some embodiments of the present invention and Figure 7 A schematic diagram for explaining selected good sample data of a second object as a tested object and images of the tested object that do not exist in the training data set. DETAILED DESCRIPTION
[0017] For defect judgment related technologies used in industrial modernization, machine learning algorithm models for defect classification are trained separately for different types of objects or parts (for example, circuit elements, capacitors, inductors, etc. commonly used on circuit boards). As a result, each type of object requires a certain number of defective product data samples to more completely train the above-mentioned machine learning algorithm model, and it is dependent on the amount of data for each type of object. The currently commonly used second-degree inspection technology is the technology of defect classification "for each type of object or part." However, when the amount of defect information (or defect training data) of certain objects or parts is insufficient, it is difficult to obtain better judgment results in the defect judgment scenario.
[0018] Therefore, the embodiment of the present invention uses different types of objects / parts to establish a shared machine learning algorithm model, that is, a triplet loss supervised learning algorithm is used to establish a model to automatically judge the defects of objects, so that it can be applied to a variety of objects, circuit elements or parts at the same time, and the error rate in defect judgment is further reduced on the basis of the original automatic optical inspection technology. Therefore, the embodiment of the present invention does not need to establish different machine learning algorithm models for different objects, which can reduce the development time of the defect classification model of new objects when a new production line is established, and can also establish a more effective machine learning algorithm model when the amount of good product data and defective product data of new objects is insufficient.
[0019] In other words, the embodiment of the present invention uses three types of data (i.e., good product data, defective product data, and good product samples of various types of objects (or parts)) as training data sets, also known as ternary training data sets, and uses a triplet loss supervised learning algorithm to establish a dissimilarity model that can be used by multiple objects / parts. This dissimilarity model therefore has the ability to measure the "difference between good product samples and inspected objects", so that the embodiment of the present invention can use artificial intelligence technology to perform a second inspection on objects that are considered to be defective, thereby reducing the so-called "overkill". The "shared machine learning algorithm model" and related technologies of this embodiment can be applied to many aspects, especially after the automatic optical inspection and recognition technology has been performed, the technology described in the embodiment of the present invention is used to replace manpower to perform a second inspection on objects that are considered to be defective, thereby reducing the so-called "overkill".
[0020] The so-called "objects" in this embodiment are circuit components used on printed circuit boards, such as capacitors, resistors, inductors, packaged chips, etc. Most defective circuit components can be seen from the appearance, such as broken pins of circuit components, cracks on the appearance, dropped solder joints of circuit components, crushed edges of component shells, etc. Those who apply this embodiment can use the embodiment of the present invention to determine whether these objects are good or defective based on the appearance.
[0021] Figure 1 is a hardware block diagram of a defect judgment device for an object according to some embodiments of the present invention, Figure 2 is a schematic diagram of an object defect determination method and a corresponding device according to some embodiments of the present invention. In particular, Figure 2 It is mainly used to explain the process of operations such as object image data, artificial intelligence algorithms, trained models, and defect recognition. Figure 2 The blocks in the figure are not hardware modules, but functional modules drawn for the convenience of explanation. These blocks can be implemented in the form of software, firmware, algorithms or databases in conjunction with the processor and stored in corresponding storage devices, such as Figure 1 The object database 110 or the server 140. Figure 1 and Figure 2 The defect determination device 100 mainly includes an object database 110, an image source device 120, and a processor 130. The object database 110 at least has a plurality of training data sets corresponding to a plurality of objects. Figure 2The objects PT1~PTn (n is a positive integer) shown include multiple image data IM1~IMn respectively, and can use automatic optical inspection recognition technology or artificial intelligence training to collect images by presenting the position of each object in the bill of materials (BOM) table, so as to collect the circuit elements in these image data IM1~IMn respectively and classify them into various data in the training data sets 200-1~200-n. The training data sets 200-1~200-n of this embodiment have at least three data types in each object PT1~PTn, namely defective product data DPT1~DPTn, good product data GPT1~GPTn and good product sample data SGPT1~SGPTn. In other words, each training data set 200-1~200-n includes at least one defective product data DPT1~DPTn, at least one good product data GPT1~GPTn and at least one good product sample data SGPT1~SGPTn of the corresponding object PT1~PTn. These training data sets 200-1~200-n are stored in Figure 1 The object database 110 is shown in FIG.
[0022] In this embodiment, the "defective product data", "good product data" and "good product sample data" of the corresponding objects described here are pre-labeled image data. Those who apply this embodiment can also use other methods to distinguish the image data of objects corresponding to specific categories as good or defective, so as to organize the above-mentioned "defective product data", "good product data" and "good product sample data". When the number of "defective product data" and "good product data" is larger, the machine learning algorithm model used in this embodiment will be more accurate in subsequent defect judgments of the tested objects after training. Good product sample data SGPT1~SGPTn is selected from a large number of good product data GPT1~GPTn in a pre-labeled manner. One or several of the most representative good product data. In this embodiment, each object PT1~PTn has at least one good product sample data SGPT1~SGPTn.
[0023] The image source device 120 is used to obtain the tested images TPT, TPT1 and TPT2 of the tested object. The defect judgment device 100 of this embodiment can communicate with the automatic optical inspection and recognition system and transfer data. The user of this embodiment can first use the automatic optical inspection and recognition system to perform the first defect detection, and then use the defect judgment device 100 described in the embodiment of the present invention to perform the second defect detection on the object judged as a defect, so as to avoid "overkilling". Therefore, the defect judgment device 100 can obtain the image data of the object through the automatic optical inspection and recognition system that performs the first detection, that is, the automatic optical inspection and recognition system can be regarded as the image source device 120 in this embodiment. The user of this embodiment can also set up an additional image acquisition device (such as a camera, a video camera), and collect the image of the object to perform the subsequent operations of this embodiment.
[0024] The processor 130 is used to access the object database 110 and the image source device 120, calculate the corresponding trained model using an artificial intelligence algorithm, and implement the relevant processes described in this embodiment. The processor 130 of this embodiment can be a processor in a notebook computer, a personal computer, or a specific server. The processor 130 can also communicate with other servers (such as Figure 1 The servers 140 shown in the figure communicate and cooperate with each other to effectively utilize hardware computing resources to implement this embodiment.
[0025] Figure 3 is a flow chart of a method for determining a defect of an object according to some embodiments of the present invention. Figures 1 to 3 In step S310, the processor 130 obtains a plurality of training data sets 200-1 to 200-n corresponding to a plurality of objects PT1 to PTn from the object database 110. Each training data set 200-1 to 200-n includes at least one defective product data DPT1 to DPTn, at least one good product data GPT1 to GPTn, and at least one good product sample data SGPT1 to SGPTn corresponding to the object PT1 to PTn.
[0026] In step S320, the processor 130 trains the artificial intelligence algorithm based on the defective product data DPT1-DPTn, good product data GPT1-GPTn and good product sample data SGPT1-SGPTn of each object PT1-PTn in the training data set 200-1-200-n (that is, Figure 2 The ternary loss supervised learning algorithm 210 in ) is used to calculate the corresponding trained model (that is, Figure 2 The dissimilarity model in 220).
[0027] In summary, the steps of the ternary loss supervised learning algorithm 210 in performing artificial intelligence learning are described in sequence as follows. First, a trained model (e.g., dissimilarity model f) for calculating dissimilarity values is constructed. In this embodiment, the dissimilarity model that is being trained is referred to as dissimilarity model f, and the dissimilarity model that has completed training is referred to as dissimilarity model 220. Those who apply this embodiment should know that the dissimilarity model 220 that has completed training may also need to be retrained due to the addition of a new training data set. Therefore, this embodiment is slightly distinguished because the dissimilarity model f is easier to explain in the subsequent equations, and the dissimilarity model 220 is easier to draw in the diagram and is presented in different ways. The two are the same object. Then, during each training, the training data sets 200-1 to 200-n corresponding to the same object (e.g., object PT1) and the ternary loss supervised learning algorithm 210 are used to enable the dissimilarity model f to learn the difference between the good sample data and the defective data of this object PT1 and the difference between the good sample data and the good data. For example, the dissimilarity model f is used to make the dissimilarity between the good sample data SGPT1 and the plurality of good data GPT1 low (that is, the calculated dissimilarity value is low), and the dissimilarity model f is used to make the dissimilarity between the good sample data SGPT1 and the plurality of defective data DPT1 high (that is, the calculated dissimilarity value is high). Moreover, the processor 130 of this embodiment uses these objects PT1 to PTn and the corresponding training data sets 200-1 to 200-n to train the dissimilarity model f one by one. During the training process, the dissimilarity model f needs to undergo a large number of iterative training until the ternary loss function converges and the training can be considered completed. The number of times the dissimilarity model f is trained will be affected by the number of types of objects PT1~PTn and related parameters. Therefore, after the above-mentioned large amount of training, when the calculations of different objects PT1~PTn are converged, the trained dissimilarity model 220 can be made into a model that can "compare the similarities and differences between all different objects and their corresponding good sample data." The so-called "convergence" means that after the neural network or artificial intelligence algorithm is trained with a large amount of data, the parameters / weights on each neuron that constitutes the neural network or artificial intelligence algorithm tend to approach certain values. This phenomenon is called "convergence." In other words, in this embodiment, the loss value obtained after calculation through the ternary loss function during training, after multiple trainings, when the loss value obtained in each training is close to a small and stable value, it represents "convergence."
[0028] Figure 4A and Figure 4B It is a schematic diagram of establishing and adjusting the dissimilarity model f using the ternary loss supervised learning algorithm 210 . Figure 4Ais a schematic diagram of the state of the dissimilarity model f when it is trained by the training data set 200-1 in the object PT1 and the training is not completed (or called, not converged); Figure 4B is a schematic diagram of the state of the dissimilarity model f' when it is trained by the training data set 200-1 in the object PT1 and the training is completed (or called convergence). Figure 4A As for the mathematical operation result of the dissimilarity model f, the distance between the cluster DPT1s of the defective data and the good sample data SGPT1 (the dissimilarity is represented by f(SGPT1, DPT1s)) is shorter than the distance between the cluster GPT1s of the good data and the good sample data SGPT1 (the dissimilarity is represented by f(SGPT1, GPT1s)). At this time, the result calculated by the dissimilarity model f is not the result preset by the ternary loss supervised learning algorithm 210 (that is, the dissimilarity between the cluster DPT1s of the defective data and the good sample data SGPT1 is low, while the dissimilarity between the cluster GPT1s of the good data and the good sample data SGPT1 is high), which will make the result (that is, the dissimilarity value) calculated by the dissimilarity model f using the good sample data SGPT1 and the tested object not meet the requirements of this embodiment. That is to say, when the dissimilarity model f calculates that the dissimilarity value between the tested image and the good product sample data SGPT1 is higher (e.g., higher than the threshold), the tested image and the cluster GPT1s of the good product data are closer, making the tested object more similar to a good product; when the dissimilarity model f calculates that the dissimilarity value is lower (e.g., lower than the threshold), the tested image and the cluster GPT1s of the good product data are farther away, making the tested object more similar to a defective product.
[0029] In contrast, Figure 4B As for the mathematical operation result of the dissimilarity model f', the distance between the cluster DPT1s of the defective data and the good sample data SGPT1 (the dissimilarity is represented by f'(SGPT1, DPT1s)) is longer than the distance between the cluster GPT1s of the good data and the good sample data SGPT1 (the dissimilarity is represented by f'(SGPT1, GPT1s)). Only in this way can the result (that is, the dissimilarity value) calculated by the dissimilarity model f using the good sample data SGPT1 and the tested object meet the requirements of this embodiment. That is to say, when the dissimilarity model f' calculates a higher dissimilarity value between the tested image and the good sample data SGPT1 (e.g., higher than the threshold), the tested object is farther away from the cluster GPT1s of the good data, making the tested object more similar to a defective product; when the dissimilarity model f calculates a lower dissimilarity value (e.g., lower than the threshold), the tested object is closer to the cluster GPT1s of the good data, making the tested object more similar to a good product.
[0030] Back to Figure 2 and Figure 3After the dissimilarity model 220 of step S320 is trained (that is, converged), in step S330, the processor 130 obtains the test images TPT1 and TPT2 of the test object from the image source device 120. Specifically, after obtaining the test image TPT, the processor 130 may collect at least one test object on the test image TPT by using an automatic optical inspection and recognition system or image processing. Figure 2 The image data are labeled as the test objects TPT1 and TPT2.
[0031] In step S340, the processor 130 uses the image data of the test objects TPT1 and TPT2 to determine whether the two test objects are one of the objects PT1-PTn in the object database 110 (the object is called a selected object), and obtains the selected good sample data in the training data set corresponding to the selected object from the object database 110. For example, Figure 2 The good product sample data corresponding to the tested object TPT1 is the selected good product sample data SGPTa, and the good product sample data corresponding to the tested object TPT2 is the selected good product sample data SGPTb, wherein a and b are positive integers less than or equal to n.
[0032] In step S350, in response to the tested image and the selected good sample data (e.g., the tested image TPT1 and the selected good sample data SGPTa of the tested object; the tested image TPT2 and the selected good sample data SGPTb of the tested object), the processor 130 uses the dissimilarity model 220 to respectively calculate the dissimilarity values of the tested image TPT1, the tested image TPT2 and the selected good sample data SGPTa, SGPTb of the tested object, and judges the tested objects TPT1 and TPT2 as good or defective based on the dissimilarity values. In other words, based on the dissimilarity model 220 trained in the aforementioned step S320, when the dissimilarity value calculated by the dissimilarity model 220 is higher than the threshold value, the tested objects TPT1 and TPT2 are judged as defective (e.g. Figure 2 When the dissimilarity value calculated by the dissimilarity model 220 is lower than the threshold value, the tested objects TPT1 and TPT2 are judged as good products (such as Figure 2 230).
[0033] Describe it in detail here Figure 2Detailed process of the ternary loss supervised learning algorithm 210. The ternary loss supervised learning algorithm 210 uses a convolutional neural network (CNN) for feature collection, and then compares the feature values of the good sample data with the good data or the defective data as the dissimilarity value. Convolutional neural network is one of the commonly used techniques for deep learning, and has achieved good results in various image processing. Convolutional neural network uses feature vectors in image data for comparison. "Feature vector" means that after the image has been condensed through a large number of convolutional neural network operations, it will have a 128-dimensional or 64-dimensional feature vector (the dimension is also an adjustable parameter in the convolutional neural network). This embodiment uses feature vectors to compare the object under test with good data, defective data, and good sample data.
[0034] In this embodiment, the "threshold" related to the dissimilarity value is determined by experimental data as a standard for the dissimilarity value to be sufficiently low. This standard is also generally regarded as a parameter of the deep learning algorithm. Usually, the exact value of the threshold is determined after the dissimilarity model 220 is trained and then based on the overall data cross-experimental conditions. In addition, this embodiment uses the same set of feature vector acquisition methods whether processing good product data or defective product data, so the dissimilarity calculation method is the same.
[0035] In this embodiment, taking the convolutional neural network with the ternary loss function as an example, the training method of the dissimilarity model 220 can be described as follows. First, a pair of good product data and defective product data belonging to the same type of object is selected from the training data set. The above two and the pre-determined good product sample data are put into the convolutional neural network model to calculate the feature vectors corresponding to the three respectively. The three feature vectors of the above three are put into the ternary loss function, and the user of this embodiment can adjust the weights of the CNN model for these three feature vectors according to the actual situation. If the weight setting of the CNN model is not appropriate, the difference between the good product sample data and the good product data will increase, and the loss value will increase at the same time; conversely, if the weight setting of the CNN model is appropriate, the difference between the good product sample data and the good product data will decrease, and the loss value will decrease at the same time. The size of the weight that needs to be adjusted for this training is determined by the size of the ternary loss function to adjust the weight again. Repeatedly train and adjust the above weights until the loss value reaches the minimum and is stable (called convergence). At this time, the dissimilarity model and the weights corresponding to this corresponding degree model can be said to have been trained.
[0036] In this embodiment, the defective data of an object may also have only one image data. This embodiment may also infer that similar defects may occur in this type of object by using the defective data of other different types of objects. For example, by training a common trained model (e.g., a dissimilarity model) with defective data of multiple objects, the trained model can simultaneously determine whether the solder joint of object TP1 is detached and whether the edge of the shell of object TP2 is crushed. Since the trained model also has the knowledge of the edge crushing of the shell of object TP2, when the trained model is used to perform defect judgment on object TP1, if the image of the edge crushing of object TP1 appears for the first time (that is, the image of the edge crushing of object TP1 has not been used to train the trained model before), the trained model can also determine that it is a defective product. The trained model can identify different types of defects with a small amount of defective data.
[0037] Therefore, in Figure 3 In step S350, after the converged dissimilarity model 220 is trained, the processor can obtain good sample data of the same type as the object under test, and use the dissimilarity model 220 to calculate the feature vector of the good sample data (represented by f(good sample data)) and the feature vector of the image data of the object under test (represented by f(object under test)). Then, the dissimilarity value is calculated using the above two feature vectors, for example, a value is calculated as the dissimilarity value by using the minimum sum of squares of the above two feature vectors. Finally, the threshold determined in the process of training the dissimilarity model f can be compared with the above dissimilarity value to determine whether the object under test is a good product or a defective product. For example, assuming the threshold value is 0.6, the dissimilarity value of the first tested object calculated by this embodiment is 0.2, and the dissimilarity value of the second tested object calculated by this embodiment is 0.8, then the first tested object is determined to be a good product (because 0.2<0.6), and the second tested object is determined to be a defective product (because 0.8>0.6).
[0038] This embodiment can cooperate with the automatic optical inspection system to obtain better defect judgment results. After the automatic optical inspection system detects the image data of the problematic object, the image data of the problematic object is provided to the processor 130, and the processor 130 determines the name of the problematic object (for example, by searching the bill of materials (BOM) table shared with the automatic optical inspection system, or by using image recognition technology), and then obtains the good sample data corresponding to the problematic object from the object database. Figure 3 The corresponding steps are shown in the figure to make defect judgment.
[0039] Figure 5 The first embodiment Figure 2 Schematic diagram of the internal flow of the triple loss supervised learning algorithm 210. Figure 5 In the ternary loss supervised learning algorithm 210, there is a feature model 510 (presented as g(X,w)) and a ternary loss function 520. The feature model 510 and the ternary loss function 520 of this embodiment can be implemented in the form of software, firmware, algorithm or database in conjunction with a processor, and stored in a corresponding storage device. First, the training data sets 200-1 to 200-n and the weights w corresponding to the multiple objects PT1 to PTn are placed in the feature model 510 to obtain multiple feature vectors in each image data in the training data set 200-1 to 200-n. In addition, the ternary loss value (presented as L1 to Ln) of each object PT1 to PTn is calculated using the ternary loss function 520 and the aforementioned feature vector. Afterwards, these ternary loss values L1 to Ln corresponding to each object are summed up to obtain the total ternary loss value ML of all training data sets. Next, the back propagation method 530 is used to calculate the gradient of the ternary loss value and the weight w. 540, and using the gradient descent method 550 to use the gradient 540 performs an iterative operation on the weight w to obtain a new iterated weight w, and uses the iterated weight w to bring it into the feature model 510 for training to retrain the dissimilarity model. The iterated weight w has a smaller total ternary loss value ML than the weight w before the iterative operation. In addition, in response to multiple trainings and when the total ternary loss value ML approaches a certain value, it means that the total ternary loss value ML "converges" and the dissimilarity model f training is completed and becomes the dissimilarity model 220. At this time, the iterated weight w can be called a trained weight. The dissimilarity model 220 will use the trained weight to calculate the dissimilarity value between the tested object and the selected good sample data. The weight w of this embodiment during the first training is usually randomly generated, or the corresponding parameters are set according to the experience of this embodiment. Since the losses of different objects (even their different defects) are calculated in each training, the weight w used at the final convergence will be a trained weight that can be applied to various situations.
[0040] The feature model 510 presented as g(X,w) is an example of using CNN to establish a feature model calculation structure, which can be implemented by a three-layer CNN. In this embodiment, the first layer of CNN uses eight different convolution kernels, the second layer of CNN uses 16 different convolution kernels, and the last layer of CNN uses a fully connected layer to calculate a 64-dimensional vector. This 64-dimensional vector is the feature vector of the object data. This embodiment calls this architecture a g function. The weight w of this embodiment can be composed of a combination of multiple weights of the convolution kernel of the first layer of CNN, the convolution kernel of the second layer of CNN, and the fully connected layer of the third layer of CNN. The weight w can be a single value or a set of multiple values. The above three layers of CNN can retain more feature information and reduce the amount of feature information. Those who apply this embodiment can also use other methods to calculate the feature model 510, and are not limited to this.
[0041] The ternary loss function 520 can be expressed by the following equation (1), where a 2-dimensional feature vector is used as an example:
[0042] L(X A ,X P ,X N ,w)=max(||g(X A ,w)-g(X P ,w)|| 2 -||g(X A ,w)-g(X N ,w)|| 2 +α,0)…(1)
[0043] In equation (1), “w” is the weight and “X” is the image data of the object. A , X P , X N" respectively represent the aforementioned good sample, good product and defective product. "α" represents a neural network hyperparameter. The user of this embodiment can adjust this neural network hyperparameter α according to their needs. In this embodiment, the neural network hyperparameter α can usually be set to 0.2 or a similar value. The reason for taking the maximum value (that is, taking max) of these values in equation (1) is that it is hoped that better mathematical properties can be used during the training process. When calculating the value of the ternary loss function 520, if a negative value is added to a positive value, the loss will be offset. For example, suppose there are two sets of ternary training data sets and two weights Wa and Wb. The loss values calculated for the two sets of ternary training data sets using weight Wa are "-10" and "10", and the sum of the losses calculated using weight Wa is "0" (that is, (-10) + 10). On the other hand, the loss values calculated for the two sets of ternary training data sets using weight Wb are "0" and "0", and the sum of the losses of this ternary training data set W2 is also "0". In this way, the above situation will not be able to distinguish that weight Wb is actually better than weight Wa.
[0044] Taking this embodiment as an example, the convolution kernel of the first layer of CNN has 80 weights, the convolution kernel of the second layer of CNN has 1168 weights, and the fully connected layer of the third layer of CNN has 262,208 weights, so w is a set of 263,456 weights. For example, this embodiment sets the neural network hyperparameter α to 0.2 and uses a two-dimensional feature vector as an example. The weight w1, the corresponding feature model 510 (g(X, w1)) and the ternary loss function 520 (Equation (1)) are illustrated as follows Equation (2):
[0045] g(X A ,w1)=(1,0),g(X P ,w1)=(0.5,0.5),g(X N ,w1)=(0.8,0), L=max((0.5,-0.5) 2 -(0.2,0) 2 ,0)=max(0.5071,0)=0.5071…(2)
[0046] Among them, g(X A ,w1) represents the use of weight w1 and good sample data into the g function to calculate the eigenvector, and obtain the eigenvector (1,0). g(X P ,w1) represents the use of weight w1 and good product data into the g function to calculate the feature vector, and obtain the feature vector (0.5,0.5). g(X N,w1) represents the use of weight w1 and defective product data into the g function to calculate the feature vector, and obtain the feature vector (0.8,0). Substituting the three feature vectors into the ternary loss function, the loss value is 0.5071.
[0047] The weight w2, the corresponding feature model 510 (g(X, w2)), and the ternary loss function 520 (Equation (1)) are exemplified as follows:
[0048] g(X A ,w2)=(1,0),g(X P ,w2)=(0.9,0),g(X N ,w2)=(0.2,0.3), L=max((0.1,0) 2 -(0.8,-0.3) 2 ,0)=max(-0.7544,0)=0…(3)
[0049] Among them, g(X A ,w2) represents the use of weight w2 and good sample data into the g function to calculate the eigenvector, and obtain the eigenvector (1,0). g(X P ,w2) represents the use of weight w2 and good product data into the g function to calculate the feature vector, and obtain the feature vector (0.9,0). g(X N ,w2) represents the use of weight w2 and defective product data into the g function to calculate the feature vector, and obtain the feature vector (0.2,0.3). Substituting the three feature vectors into the ternary loss function, the loss value is 0.
[0050] Comparing the loss amount of weight w1 (L=0.5071) with the loss amount of weight w2 (L=0), since the loss amount of using weight w2 is less than the loss amount of using weight w1, the difference value between the tested object and the selected good sample data can be better determined when using weight w2.
[0051] The choice of weights will affect the convolution kernel of CNN. In this embodiment, the most suitable convolution kernel for training using CNN can be presented by the following equation:
[0052] It represents the jth weight of the i-th layer during the k-th training.
[0053]
[0054] Indicates that each iteration w ij The amount of change; "learning rate" is a controllable parameter, called the learning rate, which determines the proportion of each change in weight; It is used to represent the information propagated to the i-th layer by the loss of this time, and it is a nonlinear function that changes with the loss, but not necessarily in direct or inverse proportion; This means that the weight in this layer is related to the value of the weight of the whole layer. This calculation method of weight w is the calculation method of back propagation and gradient descent.
[0055] Here is an example to illustrate how to calculate the weight. If the loss value of the initial weight w0 is 0.985, set the initial weight The initial weight is 0.3. is 0.7, and the learning rate is 0.01. According to the back propagation formula, we get equation (5):
[0056]
[0057] And, after one iteration of the weights using the above parameters, the following results are obtained:
[0058]
[0059]
[0060] In this way, the loss corresponding to the weight will change. Although the above loss will not necessarily decrease, and This is a direction of change that will decrease in mathematical theory, so after a long period of iteration, the loss corresponding to the weight will generally decrease, thereby obtaining the converged weight.
[0061] The threshold value set in the dissimilarity model 220 can be determined according to the requirements of the user of this embodiment, where the "requirement" here refers to the requirements of the application end for accuracy, sensitivity, specificity or false alarm rate, etc. In other embodiments, the receiver operating characteristic curve (ROC Curve) is used to determine.
[0062] Here with Figure 6 With corresponding description how to achieve Figure 3 Step S350 is "calculating the dissimilarity value of the tested image using the dissimilarity model". Figure 6 According to some embodiments of the present invention, Figure 3 Flow chart of step S350. Figure 5 After completing the training of the dissimilarity model 220 according to the corresponding description, Figure 6 In this embodiment, the trained weights (herein denoted as trained weights), and based on the trained weights Construct the second feature model 610 (with The second feature model 610 and Figure 5 The feature model 510 in FIG. 5 is an example of using CNN to establish a feature model calculation structure. However, Figure 5 The difference between the feature model 510 is that the weights in the second feature model 610 are the trained weights that have converged as described above. "X" is the image data of the object. On the other hand, the present embodiment obtains the tested images TPT and TPT1 of the tested object. Specifically, after obtaining the tested image TPT, at least one tested object, such as TPT1, on the tested image TPT can be captured by an automatic optical inspection and recognition system or image processing.
[0063] Then, the selected good product sample data corresponding to the tested object (herein, SGPTa is used as an example) is put into the second feature model 610 to obtain the first feature vector of the selected good product sample data SGPTa. In addition, the image of the object under test (TPT1 is used as an example here) is placed into the second feature model 610 to obtain the second feature vector of the object under test. The second eigenvector is presented. And, according to the first eigenvector and the second eigenvector Calculate the dissimilarity value, such as Figure 6 As shown in block 620 .
[0064] The calculation of the dissimilarity value in block 620 is to convert the first eigenvector Subtract the second eigenvector The absolute value is then taken and then squared to form the following equation (6):
[0065]
[0066] Figure 6 The above is one of the feasible calculation methods for calculating the dissimilarity value. The calculation of the dissimilarity value can be adjusted according to the requirements when applying this embodiment, and is not limited thereto.
[0067] Here, actual images are used as training data to illustrate the embodiments of the present invention. Figure 7 The diagram is a diagram for illustrating defective product data, good product data and good product sample data of two objects according to some embodiments of the present invention. In this embodiment, two objects are used as examples, the first object is an image showing the number "4", and the second object is an image showing the number "0". Figure 7Two good sample data SGPT1, two good sample data GPT1, and two defective sample data DPT1 of the first object are presented, as well as two good sample data SGPT2, two good sample data GPT2, and two defective sample data DPT2 of the second object. The defective sample data DPT1 is covered by a triangle shadow covering the image of the number "4", so it is determined to be a defective object; the defective sample data DPT2 is covered by a rectangle shadow covering the image of the number "0", so it is determined to be a defective object. Figure 7 It can be seen that the defective product data DPT2 only has the second object image covered by the rectangular shadow, but not the second object image covered by the triangular shadow. Therefore, after training, this embodiment can detect the second object image covered by the triangular shadow as having a high dissimilarity, which is one of the test purposes of this embodiment.
[0068] Figure 8 According to some embodiments of the present invention and Figure 7 A schematic diagram for explaining selected good sample data of a second object as a tested object and images of the tested object that do not exist in the training data set. Figure 8 The upper horizontal row presents, from left to right, the first tested object image DM1 of the second object, the good sample data SGPT2-1 of the second object, and the second tested object image DM2 of the second object in sequence; Figure 8 The lower horizontal row presents, from left to right, the third tested object image DM3 of the second object, the good sample data SGPT2-2 of the second object, and the fourth tested object image DM4 of the second object. Figure 8 It can be seen that the first and third tested object images DM1 and DM3 are good products, the second tested object image DM2 is a defective product covered by a rectangular shadow, and the fourth tested object image DM4 is a defective product covered by a triangular shadow.
[0069] If Figure 7 As a training data set, and using Figure 8 If the dissimilarity value is calculated for the selected good sample data SGPT2-1 and the first tested object image DM1, the first dissimilarity value calculated by this embodiment is 0.3237, which means that the first dissimilarity value is low and the good sample data SGPT2-1 and the first tested object image DM1 are similar, so it can be determined as a good product; Figure 7 As a training data set, and using Figure 8 If the dissimilarity value is calculated for the selected good sample data SGPT2-1 and the second tested object image DM2, the second dissimilarity value calculated by this embodiment is 1.3341, indicating that the second dissimilarity value is high and the good sample data SGPT2-1 and the second tested object image DM2 are not similar, so it can be determined as a defective product. Figure 7The second object image covered by a rectangular shadow has appeared in the training data set of Figure 8 The test object images DM1 and DM2 in the upper horizontal row are the control group for normal judgment.
[0070] On the other hand, if Figure 7 As a training data set, and using Figure 8 If the dissimilarity value is calculated for the selected good sample data SGPT2-2 and the third tested object image DM3, the third dissimilarity value calculated by this embodiment is 0.2422, indicating that the third dissimilarity value is low and the good sample data SGPT2-2 and the third tested object image DM3 are similar, so it can be determined as a good product; Figure 7 As a training data set, and using Figure 8 If the dissimilarity value is calculated for the selected good sample data SGPT2-2 and the fourth tested object image DM4, the fourth dissimilarity value calculated by this embodiment is 1.5664, indicating that the fourth dissimilarity value is high and the good sample data SGPT2-2 and the fourth tested object image DM4 are not similar, so it can be determined as a defective product. It should be particularly noted that Figure 7 The type of the fourth test object image DM4 does not appear in the training data set in, that is, Figure 7 The second object image covered by the triangle shadow does not appear in the image, so this embodiment can use the dissimilarity model trained on both the first object and the second object to determine the defect that originally appeared on the first object but now appears on the second object. Figure 7 There is no training data set of the second object image covered by the triangle shadow, but the high dissimilarity can be calculated by the trained dissimilarity model of this embodiment.
[0071] In summary, the embodiments of the present invention utilize different types of objects / parts to establish a shared machine learning algorithm model to automatically judge the defects of objects, so that it can be applied to a variety of objects, circuit elements or parts at the same time, and further reduce the error rate in defect judgment on the basis of the original automatic optical inspection technology. Therefore, the embodiments of the present invention do not need to establish different machine learning algorithm models for different objects / parts, which can reduce the development time of defect classification models for new objects / parts when new production lines are established, and can also establish more effective machine learning algorithm models when the amount of good product data and defective product data of new objects / parts is insufficient. In addition, secondary inspection based on the automatic optical inspection and recognition technology that has been performed can reduce the so-called "overkill" situation.
[0072]
Explanation of symbols
[0073] 100: Object defect judgment device
[0074] 110: Object Database
[0075] 120: Image source device
[0076] 130: Processor
[0077] 140: Server
[0078] 200-1~200-n: training data set
[0079] 210: Ternary Loss Supervised Learning Algorithm
[0080] 220: Dissimilarity Model
[0081] 230: Good product
[0082] 240: Defective goods
[0083] S310~S350: Steps
[0084] 510: Feature Model
[0085] 520: Ternary Loss Function
[0086] 530: Back Propagation
[0087] 540: Gradient
[0088] 550: Gradient Descent
[0089] PT1~PTn:object
[0090] IM1~IMn: Image data
[0091] DPT1~DPTn: Defective product data
[0092] GPT1~GPTn: Good product data
[0093] SGPT1~SGPTn, SGPT2-1, SGPT2-2: Good product sample data
[0094] SGPTa, SGPTb: Selected good product sample data
[0095] DPT1s: Clustering of defective product data
[0096] GPT1s: Clustering of good data
[0097] f(SGPT1,DPT1s), f'(SGPT1,DPT1s): The distance between the cluster of defective data and the good sample data
[0098] f(SGPT1, GPT1s), f'(SGPT1, GPT1s): The distance between the cluster of good product data and the good sample data
[0099] DM1~DM4: Image of the object under test
Claims
1. A method for determining a defect of an object, comprising: Obtaining a plurality of training data sets corresponding to a plurality of objects of different types, wherein one of the plurality of training data sets corresponds to one of the plurality of objects, wherein each of the plurality of training data sets includes at least one defective product data of each object, at least one good product data of each object, and at least one good product sample data of each object, wherein the good product sample data is one or more most representative good product data selected from a plurality of good product data in a pre-labeled manner; Training a dissimilarity model based on the defective product data, the good product data, and the good product sample data in the plurality of training data sets, wherein the dissimilarity model is trained by a ternary loss supervised learning algorithm; Obtaining a test image of the test object; Obtaining selected good product sample data corresponding to the tested object, wherein the selected good product sample data is good product sample data corresponding to the tested object; and The dissimilarity model is used to calculate the dissimilarity value between the tested image and the selected good product sample data, and the tested object is judged to be a good product or a defective product according to the dissimilarity value.
2. The object defect determination method according to claim 1, wherein training the dissimilarity model comprises: Putting the training data set and weight corresponding to the object into a first feature model to obtain a feature vector; Calculate the ternary loss value of the object by using the ternary loss function and the feature vector; Adding up the multiple ternary loss values corresponding to each of the objects to obtain a total ternary loss value of the training data set; The back propagation method is used to calculate the gradient of the ternary loss value and the weight, and the gradient descent method and the gradient are used to iteratively calculate the weight to obtain the iterated weight; as well as retraining the dissimilarity model using the iterated weights, Wherein the iterated weight has a smaller total ternary loss value than the weight, and in response to the total ternary loss value approaching a constant value after multiple trainings, it represents that the dissimilarity model training is completed and the iterated weight is regarded as the trained weight, and the dissimilarity model will use the trained weight to calculate the dissimilarity value between the tested image and the selected good sample data.
3. The object defect judgment method as described in claim 2, wherein the weight is composed of a combination of multiple weights of the convolution kernel of the first convolutional neural network, the convolution kernel of the second convolutional neural network, and the fully connected layer of the third convolutional neural network.
4. The object defect determination method according to claim 2, wherein the step of calculating the dissimilarity value between the tested image and the selected good product sample data by using the dissimilarity model comprises: Obtaining the trained weights, and reconstructing a second feature model based on the trained weights; Putting the selected good product sample data into the second feature model to obtain a first feature vector of the selected good product sample data; placing the tested image of the tested object into the second feature model to obtain a second feature vector of the tested object; and Calculating the dissimilarity value according to the first eigenvector and the second eigenvector, The dissimilarity value is a value obtained by subtracting the second eigenvector from the first eigenvector and then squaring the absolute value.
5. The object defect determination method according to claim 1, wherein determining whether the object under test is a good product or a defective product according to the dissimilarity value comprises: When the dissimilarity value is higher than a threshold, the object under test is judged to be a defective product; as well as When the dissimilarity value is lower than the threshold value, the tested object is judged to be a good product. 6 . The object defect judgment method according to claim 1 , wherein the dissimilarity model makes the dissimilarity between the cluster of the defective product data and the good product sample data higher than the dissimilarity between the cluster of the good product data and the good product sample data. 7 . The object defect determination method as claimed in claim 1 , wherein the at least one defective product data, the at least one good product data and the good product sample data are all image data.
8. The object defect determination method as claimed in claim 1, wherein the object is a circuit element used on a circuit board.
9. A device for determining a defect of an object, comprising: An object database, comprising a plurality of training data sets corresponding to a plurality of objects of different types, wherein one of the plurality of training data sets corresponds to one of the plurality of objects, wherein each of the plurality of training data sets comprises at least one defective product data of each object, at least one good product data of each object, and at least one good product sample data of each object, wherein the good product sample data is one or more most representative good product data selected from a plurality of good product data in a pre-labeled manner; An image source device for obtaining a test image of the test object; and A processor coupled to the object database and the image source device, wherein the processor obtains the tested image of the tested object through the image source device, obtains selected good sample data corresponding to the tested object through the object database, wherein the selected good sample data is good sample data corresponding to the tested object, and The processor calculates the dissimilarity value between the tested image and the selected good sample data using a dissimilarity model, and determines whether the tested object is a good product or a defective product based on the dissimilarity value, wherein the dissimilarity model is trained based on the defective product data, the good product data, and the good sample data in the multiple training data sets, and the dissimilarity model is trained using a ternary loss supervised learning algorithm.
10. The object defect judgment device as claimed in claim 9, wherein training the dissimilarity model comprises: Putting the training data set and weight corresponding to the object into a first feature model to obtain a feature vector; Calculate the ternary loss value of the object by using the ternary loss function and the feature vector; Adding up the multiple ternary loss values corresponding to each of the objects to obtain a total ternary loss value of the training data set; Using a back propagation method to calculate the gradient of the ternary loss value and the weight, and using a gradient descent method and the gradient to iteratively calculate the weight, thereby obtaining an iterated weight; as well as retraining the dissimilarity model using the iterated weights, Wherein the iterated weight has a smaller total ternary loss value than the weight, and in response to the total ternary loss value approaching a constant value after multiple trainings, it represents that the dissimilarity model training is completed and the iterated weight is regarded as the trained weight, and the dissimilarity model will use the trained weight to calculate the dissimilarity value between the tested image and the selected good sample data.
11. The object defect judgment device as described in claim 10, wherein the weight is composed of a combination of multiple weights of the convolution kernel of the first convolutional neural network, the convolution kernel of the second convolutional neural network, and the fully connected layer of the third convolutional neural network.
12. The defect judgment device for an object as claimed in claim 10, wherein the processor obtains the trained weights, reconstructs a second feature model according to the trained weights, puts the selected good product sample data into the second feature model to obtain a first feature vector of the selected good product sample data, puts the tested image of the tested object into the second feature model to obtain a second feature vector of the tested object, and the processor calculates the dissimilarity value according to the first feature vector and the second feature vector. in, The dissimilarity value is a value obtained by subtracting the second eigenvector from the first eigenvector and then squaring the absolute value.
13. The defect judgment device for an object as claimed in claim 9, wherein when the dissimilarity value is higher than a threshold value, the processor judges that the object under test is a defective product; and when the dissimilarity value is lower than the threshold value, the processor judges that the object under test is a good product.
14. The defect judgment device of an object as claimed in claim 9, wherein the dissimilarity model makes the dissimilarity between the cluster of the defective product data and the good product sample data higher than the dissimilarity between the cluster of the good product data and the good product sample data.
15. The object defect judgment device as claimed in claim 9, wherein the image source device is an image acquisition device or an automatic optical inspection and recognition system. 16 . The object defect judgment device as claimed in claim 9 , wherein the at least one defective product data, the at least one good product data and the good product sample data are all image data.
17. The object defect judgment device as claimed in claim 9, wherein the object is a circuit element used on a circuit board.
