Industrial quality inspection application method based on incremental learning
By adopting the incremental learning method in the industrial quality inspection system, the problems of increased training time and data complexity caused by new defect data are solved, efficient incremental learning training is achieved, the prediction accuracy of the model is improved and the cost is reduced.
Patent Information
- Application Number
- CN202310904260.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-24
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2043-07-24
AI Technical Summary
When faced with the continuous generation of new defect data, the existing industrial quality inspection system faces increasing training time, complex data and uneven sample distribution, and a lack of practical application cases for incremental learning.
An industrial quality inspection application method based on incremental learning is adopted. By loading task configuration files, judging the training mode, and archiving samples, initial training, joint training, sample increment and mixed increment are realized, incremental learning samples are generated, and the training process is optimized.
It achieves the effects of short training time, equal sample distribution and low cost, adapts to complex and changeable incremental data, improves the prediction accuracy of the model, and reduces hardware costs.
Smart Images

Figure CN116910554B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an industrial quality inspection application method, in particular to an industrial quality inspection application method based on incremental learning. Background Art
[0002] The existing training acceleration methods mainly include the following:
[0003] (1) Model compression: By compressing the model and reducing the number of model parameters, the training speed can be increased without affecting the model accuracy. The disadvantage is that the accuracy will decrease when the compression is too large. The compression process increases the computational burden of the model, resulting in increased training time. The selection and parameter adjustment of the compression algorithm requires certain experience and skills, which increases the complexity of the model design.
[0004] (2) Pre-trained model: Use large-scale data to pre-train the model, and use the pre-trained model and a small amount of sampled data to accelerate training. The disadvantage is that the pre-trained model relies on large-scale datasets, requires a lot of computing resources, is not suitable for specific fields, and the inaccuracy of the pre-training data will have an adverse effect on the model.
[0005] (3) Distributed training: Distribute the training tasks to multiple computing nodes for parallel computing to improve training efficiency. The disadvantage is that it takes up a lot of computing resources and has high hardware costs.
[0006] (4) Incremental learning algorithm: The model is updated and optimized by continuously adding new data. The disadvantage is that the research on incremental learning is based on a specific number of incremental categories and a specified number of samples, and lacks consideration for actual application.
[0007] Incremental learning methods are primarily a field of academic exploration. As far as we know, there are still few relevant examples in the industry. Currently, academic research on incremental learning is primarily focused on image classification. Typical algorithms in recent years include:
[0008] (1) Bic algorithm was the first to explore the problem of large-scale incremental learning. By adding bias correction to the old class, it can achieve better distinction between new and old classes, thereby improving the accuracy of the incremental learning model.
[0009] (2) WA algorithm: After training on an unbalanced training set, the linear classifier corresponding to the new class often has a larger weight than the linear classifier of the old class. Comparing the L2 norm of the weights of the new and old class classifiers, it can be found that the L2 norm of the new class is significantly larger than that of the old class. WA achieves high accuracy for both new and old classes by flattening the L2 norm of the new and old classes;
[0010] (3) DER algorithm, in order to achieve a better stability-plasticity trade-off, a dynamically scalable representation and a two-stage category incremental learning strategy are developed. An auxiliary loss is proposed to promote the newly added feature module to effectively learn new categories, and a model pruning step is proposed to learn compact features.
[0011] The disadvantage of these technologies is that the number of incremental categories is fixed and the number of samples is sufficient. For example, the experiments in the Bic algorithm paper used the public ImgNet dataset and CIFAR dataset, and the number of experimental incremental categories was 5, 10, 20, and 50. Because the number of newly added categories varies in actual industrial quality inspection scenarios, and there is also an increase in samples of old categories, the incremental category number defined by academia cannot be directly applied to the field of industrial quality inspection. In addition, the harsh conditions for generating new defect samples result in a very scarce new data, which is completely different from the abundant data of ImgNet and CIFAR, making it difficult to implement existing technologies. Existing technologies also lack a corresponding data archiving mechanism, and fail to achieve timely updates and management of the data accumulation process.
[0012] In summary, the present invention needs to solve the problems that the existing industrial quality inspection constantly generates new defect data, which makes the training time longer and longer; the new data is complex and the sample distribution is uneven; and the incremental learning lacks practical application cases. Summary of the Invention
[0013] The technical problem to be solved by the present invention is: in order to solve the problems that the existing industrial quality inspection constantly generates new defect data, which makes the training time longer and longer; the newly added data is complex and the sample distribution is uneven; and the incremental learning lacks actual application cases, an industrial quality inspection application method based on incremental learning is provided.
[0014] The technical solution adopted by the present invention to solve the technical problem is: an industrial quality inspection application method based on incremental learning, characterized by comprising the following steps:
[0015] Step 1: Load the task configuration file and perform sample data reading and analysis on the information in the file;
[0016] Step 2: Determine the training mode used for the current task through the function, including the following steps:
[0017] Step 21: Read the current training data, select a non-empty folder, and form a category list for the current training;
[0018] Step 22: Determine whether the known category list of the data set is empty. If so, it is determined to be in "initial training" mode;
[0019] Step 23: Determine whether the difference between the currently trained category list and the known category list in the dataset is empty. If it is empty, it is in "sample increment" mode; if it is not empty, it is in "mixed increment" mode.
[0020] Step 24: Obtain the category list of sample increments by the intersection of the currently trained category list and the category list known in the dataset;
[0021] Obtain the category list of category increments by taking the difference between the currently trained category list and the category list known in the dataset;
[0022] Merge the newly added class list with the known class list to form a new known class list after this task;
[0023] Step 25: The mode judgment function returns the initial training mode, the sample increment mode or the mixed increment mode, as well as the new known class list, the sample increment class list and the category increment class list;
[0024] Step 3: Sample archiving;
[0025] Step 4: Perform initial training, joint training, sample increment or mixed increment;
[0026] Step 5: Output the model;
[0027] Step 6: Update the configuration file in step 1;
[0028] Step 7: Repeat steps 1 to 6.
[0029] Furthermore, the sample archiving in step 3 is to archive the new sample data before starting any mode of incremental learning. After the archiving is completed, the validation set data is read from the archiving path for subsequent incremental learning training;
[0030] Joint training will directly read all the data in the archive folder for training.
[0031] Furthermore, the sample archiving in step 3 also includes calculating and storing the mean of each category of the sample library in advance, calculating and storing the mean of a single subtype sample using an unsupervised clustering method, or manually selecting a single subtype sample to calculate and store the mean.
[0032] Furthermore, the initial training in step 4 is the first and most original training of the model;
[0033] Joint training is model training on archived data in the mid-term of model increment, using the same training mode as initial training.
[0034] Furthermore, the sample increment in step 4 includes the following steps:
[0035] Step 411: Initialize the incremental network and load the previous model parameters;
[0036] Step 412: Read the archived data and form a data management class;
[0037] Step 413: Count the current sample increment data through a statistical function, and obtain the maximum value of the sample increment according to the statistical result;
[0038] Step 414: Generate training samples required for incremental learning using a sample generation strategy. The sample generation strategy adopts an incremental learning sample generation method, including the following steps:
[0039] Step 4-1: Get the number of samples to be supplemented in the current category. Use the statistical result dictionary of the current training data to obtain each category of the current training data and the number of samples corresponding to each category. Subtract the number of samples from the pre-set threshold to get the number of samples that still need to be supplemented in this category. The specific calculation formula is as follows:
[0040] m c =tn c
[0041] m c is the number of samples that still need to be supplemented for category C.
[0042] t represents the preset threshold, that is, the upper limit of the number of single-class training samples. By adjusting the t value, the incremental learning training time can be effectively controlled.
[0043] n c Indicates the number of samples contained in the c-type folder in the incremental data;
[0044] Step 4-2: Determine whether category c is a known category or an unknown category through the unknown incremental category list. If category c does not exist in the unknown incremental category list, it is determined that category c is a known category.
[0045] Skip steps 4-3;
[0046] Step 4-4: Generate known class samples, including the following steps:
[0047] Step 4-41: Determine whether the number of samples that need to be supplemented is less than or equal to zero, that is, m c ≤0;
[0048] Step 4-42: When the number of samples that still need to be supplemented is less than or equal to zero, directly merge m c ;
[0049] When the number of samples that still need to be supplemented is greater than zero, the known class samples are obtained from the sample library, and the number is called o c , the number of known class samples in the sample library and the number of known class samples that need to be supplemented mc Compare the sizes to determine whether the known class sample library has sufficient samples. If the known class sample library does not have enough samples, calculate the difference between the two as the number of random sampling times. The calculation formula is as follows:
[0050] s=m c -o c
[0051] s represents the number of random sampling of the known class,
[0052] m c is the number of samples that still need to be supplemented for category C.
[0053] o c Indicates the number of samples in the known class sample library,
[0054] When the number of known class samples is sufficient, the most representative samples are extracted through the nearest zero mean algorithm and its optimization algorithm and added to the known class example set;
[0055] Skip steps 4-5, or perform steps 4-5: merge an empty training sample to generate the final training sample;
[0056] Step 415: Archive the samples of this training and use the archived validation set as the incremental learning validation set;
[0057] Step 416: Complete the training output model of incremental learning, calculate the score, and automatically update the configuration file.
[0058] Furthermore, the industrial quality inspection application method based on incremental learning according to claim 1 is characterized in that the mixed increment in step 4 is used to process the newly added samples as pure unknown category increments or unknown category increments containing some known categories, and the specific steps are as follows:
[0059] Step 421: Get the old class list and read the number of incremental tasks of the known class;
[0060] Step 422: Build an incremental network and load historical model parameters;
[0061] Step 423: Read the archived data of the old class according to the old class list to form a data management class;
[0062] Step 424: Count the current incremental sample data through a statistical function, and provide maximum value filling or threshold filling to achieve "performance optimization strategy" or "time optimization strategy";
[0063] Step 425: Generate hybrid incremental learning samples using a sample generation strategy. The sample generation strategy adopts an incremental learning sample generation method, including the following steps:
[0064] Step 4-1: Get the number of samples to be supplemented in the current category. Use the statistical result dictionary of the current training data to obtain each category of the current training data and the number of samples corresponding to each category. Subtract the number of samples from the pre-set threshold to get the number of samples that still need to be supplemented in this category. The specific calculation formula is as follows:
[0065] m c =tn c
[0066] m c is the number of samples that still need to be supplemented for category C.
[0067] t represents the preset threshold, that is, the upper limit of the number of single-class training samples. By adjusting the t value, the incremental learning training time can be effectively controlled.
[0068] nc represents the number of samples contained in the c-type folder in the incremental data;
[0069] Step 4-2: Determine whether category c is a known class or an unknown class through the unknown incremental class list. If category c exists or partially exists in the unknown incremental class list, determine that category c is a pure unknown class increment or an unknown class increment that contains some known classes.
[0070] Step 4-3: Generate unknown class samples, find the index of the category in the unknown incremental category list, add it to the number of known categories to get the label of the unknown category, calculate the difference between the threshold and the number of samples in the current unknown class incremental data, and get the number of unknown class samples to be supplemented. The calculation formula is as follows:
[0071] e=tp c
[0072] e represents the number of samples of unknown class to be supplemented,
[0073] t represents the preset threshold,
[0074] p c Indicates the number of samples in the incremental data of the unknown class;
[0075] When step 4-2 determines that category c is a simple unknown category increment, skip step 4-4;
[0076] When step 4-2 determines that category c is an unknown category increment that contains some known categories, step 4-4 is executed: generating known category samples, including the following steps:
[0077] Step 4-41: Determine whether the number of samples that need to be supplemented is less than or equal to zero, that is, m c ≤0;
[0078] Step 4-42: When the number of samples that still need to be supplemented is less than or equal to zero, directly merge mc ;
[0079] When the number of samples that still need to be supplemented is greater than zero, the known class samples are obtained from the sample library, and the number is called o c , the number of known class samples in the sample library and the number of known class samples that need to be supplemented m c Compare the sizes to determine whether the known class sample library has sufficient samples. If the known class sample library does not have enough samples, calculate the difference between the two as the number of random sampling times. The calculation formula is as follows:
[0080] s=m c -o c
[0081] s represents the number of random sampling of the known class,
[0082] m c is the number of samples that still need to be supplemented for category C.
[0083] o c Indicates the number of samples in the known class sample library,
[0084] When the number of known class samples is sufficient, the most representative samples are extracted by the nearest zero mean algorithm and its optimization algorithm and added to the known class example set
[0085] Step 4-5: Merge and generate training samples. From step 4-1 to step 4-4, obtain the generated known class sample example set and the generated unknown class sample example set. After merging the unknown class example set into the known class sample example set, the final incremental learning training sample is formed.
[0086] Step 426: Archive the samples of this training and use the archived validation set as the incremental learning validation set;
[0087] Step 427: Complete the training output model of incremental learning, calculate the score, and automatically update the configuration file.
[0088] Furthermore, in step 5, in addition to saving the model during the model output stage, a confusion matrix is automatically generated, and single-class recall, precision, and accuracy details are generated, as well as single-class false positives and missed detections details and a single-class details diagram of the original data set.
[0089] Furthermore, the configuration file includes the following information:
[0090] 1) Dataset information;
[0091] 2) Classification list information;
[0092] 3) Model save information;
[0093] 4) Current data information;
[0094] 5) Basic model information;
[0095] 6) Device information;
[0096] 7) Batch size information;
[0097] 8) Subprocess information;
[0098] After completing the training output model, update the following:
[0099] ①. Update 2) category list information. In mixed incremental mode, the information of new categories will be added after the known categories.
[0100] ②. Update 3), model save information,
[0101] Sample increment: the original model information will be replaced by the new model information;
[0102] Category increment: new model information will be added after the known model information;
[0103] ③. Update 4) the current data information. After completing the incremental training, the number of tasks is automatically increased by one to prepare for the next incremental data reading.
[0104] Furthermore, in step 4-1, while obtaining the number of samples to be supplemented in the current category, the current training data folder path is generated through the parameters passed in from the external configuration file.
[0105] Furthermore, the unknown incremental category list in step 4-2 is statistically generated by an external function and then passed to this method.
[0106] Furthermore, the step 4-3 adopts a for loop, and after sampling incremental data samples of the unknown class through the random algorithm e times, the data and its corresponding labels are added to the unknown class example set at the same time.
[0107] Furthermore, the step 4-4 adopts a for loop, and after sampling the known class data samples through the random algorithm s times, the data and its corresponding labels are added to the known class example set at the same time.
[0108] The beneficial effect of the present invention is that the industrial quality inspection application method based on incremental learning includes four modes of automated incremental learning solutions:
[0109] (1) Initial training: The first training of the model. Training in this mode will produce the first version of the most basic model.
[0110] (2) Sample increment: By analyzing the new data set and the archived data set, it is automatically determined that the categories of the new data are all known categories, thereby starting the sample increment training program. The relevant detailed information generated by the training will update the json file and achieve training acceleration.
[0111] (3) Hybrid Increment: This mode is used to handle situations where there is both sample increment and category increment, or only category increment. In this mode, a sample generation strategy is adopted to achieve training acceleration.
[0112] (4) Joint training: used to regularly train archived samples, improve model performance in the background, and ensure the quality of subsequent incremental learning.
[0113] The detailed information generated by each training session is automatically written to a JSON file, facilitating automated mode selection for subsequent incremental learning training. Except for the joint training mode, all other modes archive the new training data after training, facilitating joint training.
[0114] Based on a classification-based incremental learning approach, this invention designs multiple incremental learning modes to address the complexities of industrial quality inspection. This accelerates training and expedites on-site model iteration. Using this invention, existing models can be updated and optimized by continuously adding new data, resulting in more accurate predictions. Compared to retraining the entire model, only new data needs to be trained, significantly saving time and resources. In the real world of industrial quality inspection, new data distribution is complex, and academic incremental learning methods are not well suited to the complex and volatile nature of industrial incremental data. This invention adapts to new data distributions and promptly updates models. By processing large amounts of data in batches through incremental learning, hardware costs can be reduced.
[0115] In summary, the present invention has the characteristics of short training time, equal sample distribution and low cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0116] The present invention will be further described below with reference to the accompanying drawings and examples.
[0117] Figure 1 It is a simple flow chart of the present invention.
[0118] Figure 2 It is a simple flowchart of the incremental learning sample generation method. DETAILED DESCRIPTION
[0119] The present invention will now be described in further detail with reference to the accompanying drawings and preferred embodiments. These drawings are simplified schematic diagrams, which only illustrate the basic structure of the present invention in a schematic manner, and therefore only show the components related to the present invention.
[0120] like Figure 1 and Figure 2 The method for industrial quality inspection based on incremental learning shown in the figure includes the following steps:
[0121] Step 1: Sample data reading and analysis
[0122] Load the task configuration file json (if it is initial training, the file is usually empty). The json file contains the following information:
[0123] 1) Dataset information, i.e. the name of the dataset to be read;
[0124] 2) Classification list information, that is, the list of categories known in the dataset;
[0125] 3) Model saving information, i.e. the saved model path and the number of categories contained in the model;
[0126] 4) Current data information, that is, the data sample path to be trained for this task;
[0127] 5) Basic model information, that is, the backbone of the model (basic model), generally resnet18;
[0128] 6) Device information, i.e. the graphics card device ID for training;
[0129] 7) Batch size information, that is, the number of images in each batch during training;
[0130] 8) Sub-process information, i.e. the number of data loading sub-processes;
[0131] Step 2: Automatically determine the training mode
[0132] Use the mode judgment function to determine which training mode is used for the current task:
[0133] Step 21: First read the current training data, select a non-empty folder, and form a category list for the current training;
[0134] Step 22: Determine whether the known category list of the dataset is empty. If it is empty, it is the "initial training" mode;
[0135] Step 23: Determine whether the "sample increment" mode is in progress by checking whether the difference between the currently trained category list and the category list known in the dataset is empty. If it is not empty, it is in the "mixed increment" mode; if it is empty, it is in the "sample increment" mode.
[0136] Step 24: Obtain the category list of sample increments by the intersection of the currently trained category list and the category list known in the dataset; obtain the category list of category increments by the difference of the currently trained category list and the category list known in the dataset; merge the newly added category list with the known category list to form a new known category list after this task.
[0137] Step 25: The mode judgment function returns three modes (initial training, sample increment, or mixed increment), as well as a list of new known classes, a list of sample increment classes, and a list of class increment classes;
[0138] Step 3: Sample Archive
[0139] Because the validation set for incremental learning in real-world scenarios is incremental, new sample data must be archived (copied into an archive folder) before starting any incremental learning mode. Once archived, the validation set data is read from the archive path for subsequent incremental learning training. Joint training directly accesses all data in the archive folder for training. The sample archiving module also includes functions such as precalculating and storing the mean of each category in the sample library, calculating and storing the mean of individual subtype samples using unsupervised clustering methods, and manually calculating and storing the mean of individual subtype samples.
[0140] Step 4: Perform initial training, joint training, sample increment, or mixed increment, where:
[0141] Initial training (joint training)
[0142] Initial training is the first, most basic training of the model. Joint training on archived data during the mid-term model increment also uses the same training model and can be considered a phased initial training. This mode has a simple process: build the DER network, load the current training data, and you can start training.
[0143] Sample increment includes the following steps:
[0144] Step 411: Initialize the incremental network (e.g., DER network) and load the previous model parameters;
[0145] Step 412: Read the archived data and form a data management class;
[0146] Step 413: A statistical function is used to count the current sample increment data, and the maximum value of the sample increment padding is obtained based on the statistical results. If padding is performed based on the maximum value, it is a "performance-optimal strategy." However, since the maximum value of each incremental sample padding is not fixed, the sample increment training time is not fixed. If padding is performed based on a threshold, it is a "time-optimal strategy." This fixes the training time by fixing the number of training samples, but does not necessarily guarantee high training accuracy.
[0147] Step 414: Generate training samples required for incremental learning through a sample generation strategy;
[0148] Step 415: Archive the samples of this training and use the archived validation set as the incremental learning validation set;
[0149] Step 416: Complete the training output model of incremental learning, calculate the score, and automatically update the json file.
[0150] Mixed Increment
[0151] Since the actual newly added samples include both category increments of unknown classes and sample increments of known classes, and sometimes only category increments, the hybrid increment scheme can well cope with these situations. It is a training scheme used to solve complex on-site situations. The specific steps are as follows:
[0152] Step 421: Get the old class list and read the number of incremental tasks of the known class;
[0153] Step 422: Build an incremental network and load historical model parameters;
[0154] Step 423: Read the archived data of the old class according to the old class list to form a data management class;
[0155] Step 424: Count the current incremental sample data through a statistical function, and provide two optional filling methods: maximum value filling or threshold filling, so as to achieve "performance optimization strategy" or "time optimization strategy";
[0156] Step 425: Generate hybrid incremental learning samples through a sample generation strategy;
[0157] Step 426: Archive the samples of this training and use the archived validation set as the incremental learning validation set;
[0158] Step 427: Complete the training output model of incremental learning, calculate the score, and automatically update the json file.
[0159] The sample generation strategies in step 414 and step 425 both adopt an incremental learning sample generation method, including the following steps:
[0160] Step 4-1: Get the number of samples to be supplemented in the current category
[0161] Through the statistical result dictionary of the current training data, each category of the current training data and the number of samples corresponding to each category are obtained. The number of samples that still need to be supplemented for this category is obtained by subtracting the number of samples from the pre-set threshold. The specific calculation formula is as follows:
[0162] m c =tn c
[0163] t represents the preset threshold, that is, the upper limit of the number of single-class training samples. By adjusting the t value, the incremental learning training time can be effectively controlled. c Indicates the number of samples contained in the c-type folder in the incremental data. m c The number of samples that still need to be added to class C. At the same time, the current training data folder path is generated through the parameters passed in the external configuration file.
[0164] Step 4-2: Determine known and unknown classes
[0165] The unknown incremental category list determines whether category c is a known or unknown class. If category c exists or partially exists in the unknown incremental category list, then category c is simply a newly added unknown incremental category, or an unknown incremental category that contains some known categories. Otherwise, category c is a known class. The unknown incremental category list is generated by an external function and passed to this strategy.
[0166] Step 4-3: Generate unknown class samples
[0167] Find the index of the category in the list of unknown incremental categories and add it to the number of known categories to get the label of the unknown category. Calculate the difference between the threshold and the number of samples in the current unknown class incremental data to get the number of samples to be added to the unknown class. The calculation formula is as follows:
[0168] e=tp c
[0169] e represents the number of samples to be supplemented in the unknown class, t represents the preset threshold, and p c Indicates the number of samples in the incremental data of unknown class. Due to the insufficient number of new samples, p c The value of e is often less than the threshold, in which case e is greater than 0. A for loop is used here to randomly sample incremental data samples of the unknown class e times, adding the data and its corresponding label to the unknown class example set. Random sampling can also provide data augmentation and subtype analysis capabilities.
[0170] Step 4-4: Generate known class samples
[0171] For known classes, step 4-41: First, determine whether the number of samples that still need to be supplemented is less than or equal to zero, that is, m c ≤0.
[0172] Step 4-42: If the number of samples that still need to be supplemented is less than or equal to zero, it means that the number of new samples of the known class is sufficient, so they can be directly merged.
[0173] On the contrary, it is necessary to obtain samples of the known class from the sample library, the number of which is called o c The number of known class samples in the sample library and the number of known class samples that need to be supplemented m c Compare the sizes to determine whether the known class sample library has sufficient samples. If the known class sample library does not have enough samples, then calculate the difference between the two as the number of random samplings. The calculation formula is as follows:
[0174] s=m c -o c
[0175] s represents the number of random sampling of the known class, m c is the number of samples that still need to be supplemented in category C, o c Represents the number of samples in the known class sample library. This example uses a for loop to randomly sample data samples of the known class s times, adding the data and its corresponding label to the known class example set. Random sampling can also provide additional features such as data augmentation and subtype analysis. If there are sufficient known class samples, the nearest zero mean algorithm and its optimization algorithm can be used to extract the most representative samples and add them to the known class example set.
[0176] Step 4-5: Merge to generate training samples
[0177] From step 4-1 to step 4-4, the generated known class sample example set and the generated unknown class sample example set are obtained, and after the unknown class example set is merged into the known class sample example set, the final incremental learning training sample is formed.
[0178] The difference is: when step 414 determines that category c is a known category, the system automatically skips step 4-3, the system automatically skips step 4-5, or the system executes step 4-5: merges an empty training sample to generate the final training sample (merges the empty set); when step 425 determines that category c is a simple newly added unknown category increment (does not contain known classes), the system automatically skips step 4-4.
[0179] The purpose of determining known and unknown classes mentioned above is to select a training mode and form an incremental class list. Different training modes will build different networks. The incremental learning sample generation method further selects samples based on the generated incremental class list to ultimately form valid training samples.
[0180] Step 5: Export the model
[0181] In addition to saving the model, the model output stage automatically generates a confusion matrix, detailed information on single-class recall, precision, and accuracy, detailed maps of single-class false positives and missed positives, and a single-class detailed map of the original dataset. These statistics and detailed maps facilitate analysis of model issues and facilitate future iterative optimization.
[0182] Step 6: Update the configuration file of step 1 (update json)
[0183] After the training output model is completed, the JSON configuration file will be automatically updated. The main updates focus on the following three points:
[0184] ①. Update 2) category list information. In mixed incremental mode, the information of new categories will be added after the known categories.
[0185] ②. Update 3) Model saved information. If it is a sample increment, the original model information will be replaced by the new model information; if it is a category increment, the new model information will be added to the known model information;
[0186] ③. Update 4) the current data information. After completing the incremental training, the number of tasks will be automatically increased by one to prepare for the next incremental data reading.
[0187] Step 7: Repeat steps 1 to 6.
[0188] The above description only describes specific embodiments of the present invention. Various examples do not limit the essential content of the present invention. After reading the description, ordinary technicians in the relevant technical field can make modifications or variations to the specific embodiments described above without departing from the essence and scope of the invention.
Claims
1. An industrial quality inspection application method based on incremental learning, characterized by: The steps include: Step 1: Load the task configuration file and perform sample data reading and analysis on the information in the file; Step 2: Determine the training mode used for the current task through the function, including the following steps: Step 21: Read the current training data, select a non-empty folder, and form a category list for the current training; Step 22: Determine whether the known category list of the dataset is empty. If so, it is determined to be in "initial training" mode; Step 23: Determine whether the difference between the currently trained category list and the known category list in the dataset is empty. If it is empty, it is in "sample increment" mode; if it is not empty, it is in "mixed increment" mode. Step 24: Obtain the category list of sample increments by the intersection of the currently trained category list and the category list known in the dataset; Obtain the category list of category increments by taking the difference between the currently trained category list and the category list known in the dataset; Merge the newly added class list with the known class list to form a new known class list after this task; Step 25: The mode judgment function returns the initial training mode, the sample increment mode or the mixed increment mode, as well as the new known class list, the sample increment class list and the category increment class list; Step 3: Sample archiving; Step 4: Perform initial training, joint training, sample increment or mixed increment; Step 5: Output the model; Step 6: Update the configuration file in step 1; Step 7: Repeat steps 1 to 6.
2. The industrial quality inspection application method based on incremental learning according to claim 1, characterized in that: The sample archiving in step 3 is to archive the new sample data before starting any mode of incremental learning. After archiving is completed, the validation set data is read from the archiving path for subsequent incremental learning training; Joint training will directly read all the data in the archive folder for training.
3. The industrial quality inspection application method based on incremental learning according to claim 1 or 2, characterized in that: The sample archiving in step 3 also includes calculating and storing the mean of each category of the sample library in advance, calculating and storing the mean of a single subtype sample using an unsupervised clustering method, or manually selecting a single subtype sample to calculate and store the mean.
4. The industrial quality inspection application method based on incremental learning according to claim 1, characterized in that: The initial training in step 4 is the first and most original training of the model; Joint training is model training on archived data in the mid-term of model increment, using the same training mode as initial training.
5. The industrial quality inspection application method based on incremental learning according to claim 1, characterized in that: The sample increment in step 4 includes the following steps: Step 411: Initialize the incremental network and load the previous model parameters; Step 412: Read the archived data and form a data management class; Step 413: Count the current sample increment data through a statistical function, and obtain the maximum value of the sample increment according to the statistical result; Step 414: Generate training samples required for incremental learning using a sample generation strategy. The sample generation strategy adopts an incremental learning sample generation method, including the following steps: Step 4-1: Get the number of samples to be supplemented in the current category. Use the statistical result dictionary of the current training data to obtain each category of the current training data and the number of samples corresponding to each category. Subtract the number of samples from the pre-set threshold to get the number of samples that still need to be supplemented in this category. The specific calculation formula is as follows: m c =t-n c m c is the number of samples that still need to be supplemented for category C. t represents the preset threshold, that is, the upper limit of the number of single-class training samples. By adjusting the t value, the incremental learning training time can be effectively controlled. n c Indicates the number of samples contained in the c-type folder in the incremental data; Step 4-2: Determine whether category c is a known category or an unknown category through the unknown incremental category list. If category c does not exist in the unknown incremental category list, it is determined that category c is a known category. Skip steps 4-3; Step 4-4: Generate known class samples, including the following steps: Step 4-41: Determine whether the number of samples that need to be supplemented is less than or equal to zero, that is, m c ≤0; Step 4-42: When the number of samples that still need to be supplemented is less than or equal to zero, directly merge m c ; When the number of samples that still need to be supplemented is greater than zero, the known class samples are obtained from the sample library, and the number is called o c , the number of known class samples in the sample library and the number of known class samples that need to be supplemented m c Compare the sizes to determine whether the known class sample library has sufficient samples. If the known class sample library does not have enough samples, calculate the difference between the two as the number of random sampling times. The calculation formula is as follows: s=m c -o c s represents the number of random sampling of the known class, m c is the number of samples that still need to be supplemented for category C. o c Indicates the number of samples in the known class sample library, When the number of known class samples is sufficient, the most representative samples are extracted through the nearest zero mean algorithm and its optimization algorithm and added to the known class example set; Skip steps 4-5, or perform steps 4-5: merge an empty training sample to generate the final training sample; Step 415: Archive the samples of this training and use the archived validation set as the incremental learning validation set; Step 416: Complete the training output model of incremental learning, calculate the score, and automatically update the configuration file.
6. The industrial quality inspection application method based on incremental learning according to claim 1, characterized in that: The mixed increment in step 4 is used to process newly added samples that are pure unknown category increments or unknown category increments that contain some known categories. The specific steps are as follows: Step 421: Get the old class list and read the number of incremental tasks of the known class; Step 422: Build an incremental network and load historical model parameters; Step 423: Read the archived data of the old class according to the old class list to form a data management class; Step 424: Count the current incremental sample data through a statistical function, and provide maximum value padding or threshold padding to achieve "performance optimization strategy" or "time optimization strategy"; Step 425: Generate hybrid incremental learning samples using a sample generation strategy. The sample generation strategy adopts an incremental learning sample generation method, including the following steps: Step 4-1: Get the number of samples to be supplemented in the current category. Use the statistical result dictionary of the current training data to obtain each category of the current training data and the number of samples corresponding to each category. Subtract the number of samples from the pre-set threshold to get the number of samples that still need to be supplemented in this category. The specific calculation formula is as follows: m c =t-n c m c is the number of samples that still need to be supplemented for category C. t represents the preset threshold, that is, the upper limit of the number of single-class training samples. By adjusting the t value, the incremental learning training time can be effectively controlled. n c Indicates the number of samples contained in the c-type folder in the incremental data; Step 4-2: Determine whether category c is a known class or an unknown class through the unknown incremental class list. If category c exists or partially exists in the unknown incremental class list, determine that category c is a pure unknown class increment or an unknown class increment that contains some known classes. Step 4-3: Generate unknown class samples, find the index of the category in the unknown incremental category list, add it to the number of known categories to get the label of the unknown category, calculate the difference between the threshold and the number of samples in the current unknown class incremental data, and get the number of unknown class samples to be supplemented. The calculation formula is as follows: e=t-p c e represents the number of samples of unknown class to be supplemented, t represents the preset threshold, p c Indicates the number of samples in the incremental data of the unknown class; When step 4-2 determines that category c is a simple unknown category increment, skip step 4-4; When step 4-2 determines that category c is an unknown category increment that contains some known categories, step 4-4 is executed: generating known category samples, including the following steps: Step 4-41: Determine whether the number of samples that need to be supplemented is less than or equal to zero, that is, m c ≤0; Step 4-42: When the number of samples that still need to be supplemented is less than or equal to zero, directly merge m c ; When the number of samples that still need to be supplemented is greater than zero, the known class samples are obtained from the sample library, and the number is called o c , the number of known class samples in the sample library and the number of known class samples that need to be supplemented m c Compare the sizes to determine whether the known class sample library has sufficient samples. If the known class sample library does not have enough samples, calculate the difference between the two as the number of random sampling times. The calculation formula is as follows: s=m c -o c s represents the number of random sampling of the known class, m c is the number of samples that still need to be supplemented for category C. o c Indicates the number of samples in the known class sample library, When the number of known class samples is sufficient, the most representative samples are extracted by the nearest zero mean algorithm and its optimization algorithm and added to the known class example set Step 4-5: Merge and generate training samples. From step 4-1 to step 4-4, obtain the generated known class sample example set and the generated unknown class sample example set. After merging the unknown class example set into the known class sample example set, the final incremental learning training sample is formed. Step 426: Archive the samples of this training and use the archived validation set as the incremental learning validation set; Step 427: Complete the training output model of incremental learning, calculate the score, and automatically update the configuration file.
7. The industrial quality inspection application method based on incremental learning according to claim 1, characterized in that: In step 5, in addition to saving the model during the model output stage, a confusion matrix is automatically generated, and single-class recall, precision, and accuracy details are generated. Details of single-class false positives and missed positives are generated, as well as single-class details of the original dataset.
8. The industrial quality inspection application method based on incremental learning according to claim 1, 5 or 6, characterized in that: The configuration file contains the following information: 1) Dataset information; 2) Classification list information; 3) Model save information; 4) Current data information; 5) Basic model information; 6) Device information; 7) Batch size information; 8) Subprocess information; After completing the training output model, update the following: ①. Update 2) category list information. In mixed incremental mode, the information of new categories will be added after the known categories. ②. Update 3), model save information, Sample increment: the original model information will be replaced by the new model information; Category increment: new model information will be added after the known model information; ③. Update 4) the current data information. After completing the incremental training, the number of tasks is automatically increased by one to prepare for the next incremental data reading.
9. The industrial quality inspection application method based on incremental learning according to claim 5 or 6, characterized in that: In step 4-1, while obtaining the number of samples to be supplemented in the current category, the current training data folder path is generated through the parameters passed in from the external configuration file.
10. The industrial quality inspection application method based on incremental learning according to claim 5 or 6, characterized in that: The unknown incremental category list in step 4-2 is statistically generated by an external function and then passed to this method.
11. The industrial quality inspection application method based on incremental learning according to claim 6, characterized in that: The step 4-3 adopts a for loop, and after sampling incremental data samples of the unknown class through the random algorithm e times, the data and its corresponding labels are added to the unknown class example set at the same time.
12. The industrial quality inspection application method based on incremental learning according to claim 5 or 6, characterized in that: The step 4-4 adopts a for loop, and after sampling the known class data samples through the random algorithm s times, the data and its corresponding labels are added to the known class example set at the same time.
Citation Information
Patent Citations
Incremental gradient improving decision-making tree updating method
CN106446964A
Incremental learning based classification method and device
CN106778795A