AIGC-based training dataset determination method, apparatus, storage medium, and terminal
By using an AIGC-based training dataset determination method, and combining preliminary and subsequent iterations of training with data augmentation and feature fusion, the high cost and insufficient accuracy of training dataset acquisition in existing technologies are addressed, enabling efficient and accurate product defect labeling and model optimization.
Patent Information
- Application Number
- CN202310956278.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-31
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2043-07-31
AI Technical Summary
In existing technologies, obtaining training datasets with product defect labels is costly and inefficient, or the labeling accuracy is insufficient, affecting the model training effect.
The training dataset determination method based on AIGC is adopted. Through initial and subsequent iterations of training, the dataset is expanded using AIGC technology. Combined with feature extraction and feature fusion, an expanded set of product defect images is generated. The product defect prediction and annotation are then performed by retraining the model to obtain the third training dataset.
This approach enables the rapid acquisition of a large training dataset labeled with accurate product defect tags, reducing acquisition costs and improving model training performance and product defect prediction accuracy.
Smart Images

Figure CN117036852B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a method, apparatus, storage medium, and terminal for determining training datasets based on AIGC. Background Technology
[0002] In the field of industrial continuous casting technology, it is often necessary to detect defects in continuously cast products (including steel billets, copper bars, etc.), such as checking for cracks, ripples, and inclusions in copper bars. Existing product defect detection methods typically involve acquiring images of the products from the actual production process, and then using manual analysis or automated detection models to determine the specific defects of the corresponding products.
[0003] Manual analysis is costly and inefficient, and is rarely used in practice. The accuracy of detection results using automated detection models depends on the model's inherent precision. This necessitates acquiring a large number of product sample images with defect labels to train the detection model and improve its performance.
[0004] However, in practical applications, training datasets labeled with product defects are often difficult to obtain quickly, requiring high manual annotation costs, or the accuracy of the product defect labels on the training dataset is insufficient, which in turn affects the effect of subsequent model training. Summary of the Invention
[0005] The technical problem solved by the embodiments of the present invention is how to quickly obtain a large number of training datasets labeled with accurate product defect tags.
[0006] To address the aforementioned technical problems, this invention provides a method for determining a training dataset based on AIGC, comprising the following steps: Using a first loss function, inputting the first training dataset into an initial model for preliminary iterative training until the function value of the first loss function reaches a first threshold, then stopping the iterative training to obtain a pre-trained model, wherein the first training dataset contains a first number of product sample images; Using a second loss function, inputting the second training dataset into the pre-trained model for further iterative training until the function value of the second loss function reaches a second threshold, then stopping the iterative training to obtain a retrained model, wherein the second training dataset is obtained by expanding the first training dataset based on AIGC technology, and the second training dataset contains a second number of product sample images, both the first and second training datasets are labeled with product defect tags; Inputting multiple images to be labeled into the retrained model for product defect prediction, and using the product defect prediction results output by the retrained model to label the images to be labeled, thereby obtaining a third training dataset; wherein the ratio of the second number to the first number is greater than or equal to 10, and the ratio of the first threshold to the second threshold is greater than or equal to 2.
[0007] Optionally, before inputting the second training dataset into the pre-trained model for iterative training, the method further includes: augmenting the first training dataset using AIGC technology to obtain an augmented product defect image set; and using the combination of the augmented product defect image set and the first training dataset as the second training dataset.
[0008] Optionally, based on AIGC technology, the first training dataset is augmented to obtain an augmented product defect image set, including: extracting features from the product sample images in the first training dataset to obtain a feature vector for each product sample image; clustering the product sample images according to the similarity between the feature vectors of every two product sample images to obtain one or more product sample image subsets; performing feature fusion on each product sample image subset based on the feature vectors of the product sample images therein to obtain multiple fused feature vectors corresponding to that product sample image subset; and generating the augmented product defect image set based on the obtained fused feature vectors.
[0009] Optionally, for each subset of product sample images, feature fusion is performed based on the feature vectors of the product sample images therein to obtain multiple fused feature vectors corresponding to the subset of product sample images. This includes: for each subset of product sample images, grouping the product sample images into multiple product sample image groups with every n product sample images; for each product sample image group, concatenating the feature vectors of the n product sample images in the group to obtain the fused feature vector corresponding to the product sample image group, thereby obtaining multiple fused feature vectors corresponding to the subset of product sample images; where 2≤n≤N, N is the total number of product sample images in the subset of product sample images, and n and N are both positive integers.
[0010] Optionally, the product defect labels in the expanded product defect image set are obtained by predicting product defects using the pre-trained model.
[0011] Optionally, before performing feature extraction on the product sample images in the first training dataset, the method further includes: performing binarization processing on the product sample images in the first training dataset.
[0012] Optionally, each product sample image in the first training dataset and the second training dataset is obtained by stitching together a single product sample sub-image by inverting it once or multiple times; wherein each product sample sub-image contained in the product sample image has its own product defect label.
[0013] Optionally, the first loss function can be represented by the following expression:
[0014]
[0015] Where loss1 represents the function value of the first loss function, M represents the first quantity, j represents the index of the product sample image in the first training dataset, q represents the number of product sample sub-images contained in the product sample image, i represents the index of the product sample sub-image in the product sample image, and x represents the product sample image index. ij y represents the product defect prediction result of the i-th product sample sub-image of the j-th product sample image in the first training dataset. ij W represents the product defect label of the i-th product sample sub-image of the j-th product sample image in the first training dataset. ij Let b represent the weight value of the i-th product sample sub-image of the j-th product sample image, where b represents the first coefficient and σ represents the second coefficient.
[0016] Optionally, the second loss function can be represented by the following expression:
[0017]
[0018] Where loss2 represents the function value of the second loss function, N represents the second quantity, i represents the index of the product sample image in the second training dataset, and y i y represents the product defect prediction result for the i-th product sample image in the second training dataset. i ' represents the product defect label of the i-th product sample image in the second training dataset.
[0019] Optionally, after obtaining the third training dataset, the method further includes: labeling the third training dataset with defect location tags to obtain a fourth training dataset; using the fourth training dataset to train a preset detection model to obtain an optimized detection model; and using the optimized detection model to perform defect detection on the product image to be detected, so as to obtain the product defects and defect locations in the product image to be detected.
[0020] This invention also provides a training dataset determination device based on AIGC, comprising: a preliminary training module, used to input a first training dataset into an initial model for preliminary iterative training using a first loss function, until the function value of the first loss function reaches a first threshold, and then stop iterative training to obtain a pre-trained model, wherein the first training dataset contains a first number of product sample images; a retraining module, used to input a second training dataset into the pre-trained model for further iterative training using a second loss function, until the function value of the second loss function reaches a second threshold, and then stop iterative training to obtain a retrained model, wherein the second training dataset is obtained by expanding the first training dataset based on AIGC technology, and the second training dataset contains a second number of product sample images, and both the first and second training datasets are labeled with product defect tags; and a training dataset determination module, used to input multiple images to be labeled into the retrained model for product defect prediction, and use the product defect prediction results output by the retrained model to label the images to be labeled to obtain a third training dataset; wherein the ratio of the second number to the first number is greater than or equal to 10, and the ratio of the first threshold to the second threshold is greater than or equal to 2.
[0021] This invention also provides a storage medium storing a computer program, which, when run by a processor, executes the steps of the AIGC-based training dataset determination method described above.
[0022] This invention also provides a terminal, including a memory and a processor. The memory stores a computer program that can run on the processor. When the processor runs the computer program, it executes the steps of the above-described training dataset determination method based on AIGC.
[0023] Compared with the prior art, the technical solution of the embodiments of the present invention has the following beneficial effects:
[0024] In this embodiment of the invention, a deep optimization of the initial model can be achieved through a two-step training process: initial iterative training and subsequent iterative training. Furthermore, in the subsequent iterative training process, a larger amount of training data and a smaller loss function convergence threshold are set. Specifically, in the subsequent iterative training process, the first training dataset is expanded using AIGC technology to obtain a second training dataset, and the amount of training data in the second training dataset is at least 10 times that of the training data in the initial iterative training process, and the loss function convergence threshold in the initial iterative training process is at least twice that of the loss function convergence threshold in the initial iterative training process.
[0025] By employing the aforementioned step-by-step training method, the number of iterations in the subsequent training process can be significantly greater than the number of iterations in the initial process. This helps improve the training effect of the model, resulting in a retrained model with stronger performance and higher accuracy in predicting product defects. Furthermore, by using the optimized retrained model to predict product defects in the labeled images and obtaining product defect labels, it is possible to quickly obtain a large training dataset with accurate product defect labels (i.e., the third training dataset).
[0026] Furthermore, in this embodiment of the invention, the first training dataset can be augmented using AIGC technology to obtain an augmented product defect image set; the combination of the augmented product defect image set and the first training dataset is used as the second training dataset. Thus, compared to the conventional method of acquiring the second training dataset based on image capture / collection, this implementation scheme effectively reduces the cost of acquiring the second training dataset; on the other hand, it efficiently obtains a large number of rich product defect images for subsequent iterative training.
[0027] Furthermore, for each subset of product sample images, feature fusion is performed based on the feature vectors of the product sample images within it to obtain multiple fused feature vectors corresponding to that subset of product sample images. This includes: for each subset of product sample images, grouping every n product sample images into multiple product sample image groups; for each product sample image group, concatenating the feature vectors of the n product sample images in that group to obtain the fused feature vector corresponding to that product sample image group, thereby obtaining multiple fused feature vectors corresponding to the subset of product sample images; where 2≤n≤N, N is the total number of product sample images in the subset of product sample images, and both n and N are positive integers.
[0028] In this embodiment of the invention, by employing the above-described combination method, compared to simply combining images in a subset of product sample images, the number of product sample image groups can be significantly increased, thereby obtaining a larger number of fused feature vectors. Furthermore, based on a larger number of fused feature vectors, a correspondingly larger number of richer and more diverse expanded product defect images can be generated, improving the model training effect during subsequent iterations.
[0029] Furthermore, each product sample image in the first training dataset is obtained by stitching together a single product sample sub-image after one or more forward and backward inversions; wherein each product sample sub-image contained in the product sample image has its own product defect label. Compared with the conventional method of using a whole image as input, in this embodiment of the invention, each product sample image is obtained by stitching together product sample sub-images one or more times. On the one hand, it can adaptively obtain product sample images with appropriate resolution according to the image resolution requirements of the initial model input in the actual application scenario, thereby improving the model training effect; on the other hand, different forms of product sample sub-images can be contained in the same product sample image, thereby increasing the richness of the training dataset and further improving the training accuracy of the model.
[0030] Furthermore, in this embodiment of the invention, the existing mean squared error loss function is improved to obtain a first loss function in the initial training process. Specifically, by setting corresponding weight values for the defect prediction results of each product sample sub-image, and performing a linear transformation in combination with preset first and second coefficients, the linearly transformed defect prediction results are obtained. Then, the difference between this linearly transformed result and the product defect label of the same product sample sub-image is calculated. Using the aforementioned method, the defect prediction results of each product sample sub-image can be corrected, and a more accurate difference value (i.e., the difference between the labeled product defect label and the predicted product defect) can be obtained, thereby improving the accuracy of model training. Furthermore, the weight values can be adaptively set according to factors such as the image quality of each product sample sub-image. For example, higher weights can be set for higher-quality product sample sub-images, making them have a greater impact on the training process. This improves the targeting of training and further enhances the training effect. Attached Figure Description
[0031] Figure 1 This is a flowchart of a training dataset determination method based on AIGC in an embodiment of the present invention;
[0032] Figure 2 This is a partial flowchart of another training dataset determination method based on AIGC in an embodiment of the present invention;
[0033] Figure 3This is a schematic diagram of the structure of a training dataset determination device based on AIGC in an embodiment of the present invention. Detailed Implementation
[0034] To make the above-mentioned objectives, features and beneficial effects of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0035] Reference Figure 1 , Figure 1 This is a flowchart of a training dataset determination method based on AIGC according to an embodiment of the present invention. The method may include steps S11 to S13:
[0036] Step S11: Using a first loss function, input the first training dataset into the initial model for preliminary iterative training until the function value of the first loss function reaches a first threshold, then stop the iterative training to obtain a pre-trained model. The first training dataset contains a first number of product sample images.
[0037] Step S12: Using the second loss function, input the second training dataset into the pre-trained model for iterative training again until the function value of the second loss function reaches the second threshold, and stop iterative training to obtain a retrained model. The second training dataset is obtained by expanding the first training dataset based on AIGC technology. The second training dataset contains a second number of product sample images. Both the first training dataset and the second training dataset are labeled with product defect labels.
[0038] Step S13: Input multiple images to be labeled into the retrained model to predict product defects, and use the product defect prediction results output by the retrained model to label the images to obtain a third training dataset.
[0039] Wherein, the ratio of the second quantity to the first quantity is greater than or equal to 10, and the ratio of the first threshold to the second threshold is greater than or equal to 2.
[0040] In the specific implementation of step S11, the product sample images in the first training dataset can be obtained by collecting images of semi-finished or finished products in one or more process segments (or process flows) of the product production line, targeting the actual scenario of the process segment. The objects collected are usually finished or finished products with defects.
[0041] In a non-limiting sense, the product production line can be selected based on the application scenario of the training dataset. For example, it can be selected from copper casting production lines and steel casting production lines in the industrial continuous casting field, machinery and equipment production lines in the machinery manufacturing field, and food processing production lines in the food manufacturing field. Correspondingly, the products in the product sample images can be selected from, but are not limited to, copper bars, steel billets, machinery and equipment, parts, and food.
[0042] The initial model can be a machine learning model capable of image processing and supervised training, such as deep learning-based convolutional neural network (CNN), recurrent neural network (RNN), long short-term memory (LSTM), generative adversarial network (GAN), etc.
[0043] Furthermore, each product sample image in the first training dataset is obtained by stitching together a single product sample sub-image by inverting it once or multiple times; wherein each product sample sub-image contained in the product sample image has its own product defect label.
[0044] The product sample sub-image can be obtained by cropping the defect area of the original product sample image.
[0045] As a non-limiting embodiment, the method for obtaining the first training dataset may include: (1) acquiring images of semi-finished or finished products in the actual scenario of the process section to obtain a first number of original product sample images; (2) cropping the defect areas of the first number of original product sample images, for example, for the acquired original copper rod sample images, a resolution of 1024×256 (i.e., 4:1 format) can be selected for cropping; (3) since the resolution format of each cropped sample image is 4:1, while the image input during model training is generally 1024×1 The resolution is 024 (i.e., 1:1 format). Therefore, for each cropped product sample image (i.e., the product sample sub-image), it can be stitched together by inverting it (e.g., forward + reverse + forward + reverse) to obtain a first number of 1024×1024 resolution product sample images; (4) For each product sample sub-image contained in each product sample image, product defect labels are labeled to obtain the first training dataset labeled with product defect labels, wherein the product defect labels can be determined manually or by existing product defect prediction models.
[0046] It should be noted that, compared to existing conventional methods that typically use the entire image as input, in this embodiment of the invention, product sample sub-images are obtained by cropping defective areas, and then each product sample image is obtained by inverting and stitching the product sample sub-images one or more times. On the one hand, this can adaptively obtain product sample images with appropriate resolutions based on the image resolution requirements of the initial model input in actual application scenarios, thereby improving the model training effect. On the other hand, different forms of product sample sub-images can be contained in the same product sample image, thereby increasing the richness of the training dataset and further improving the training accuracy of the model.
[0047] Without limitation, for copper bars in industrial copper casting production lines, the type of product defect label can be selected from: cracks, ripples, inclusions, etc.
[0048] Specifically, different numerical values can be used to identify the type of product defect label. For example, the value "1" can be used to identify "cracking", the value "2" to identify "ripples", and the value "3" to identify "inclusions". However, this is not the only option. In practice, other conventional methods can also be used to identify different product defect label types to facilitate the subsequent calculation of loss function values.
[0049] Specifically, during the initial iterative training process of inputting the first training dataset into the initial model using the first loss function, the function value of the first loss function is minimized until the function value of the first loss function reaches a first threshold, at which point the iterative training stops. In each iteration, the parameters of the initial model are optimized until the iterative training stops, at which point the optimized model parameters and the pre-trained model are obtained.
[0050] In practical implementation, the first loss function can be represented by the following expression:
[0051]
[0052] Where loss1 represents the function value of the first loss function, M represents the first quantity, j represents the index of the product sample image in the first training dataset, q represents the number of product sample sub-images contained in the product sample image, i represents the index of the product sample sub-image in the product sample image, and x represents the product sample image index. ij y represents the product defect prediction result of the i-th product sample sub-image of the j-th product sample image in the first training dataset. ij W represents the product defect label of the i-th product sample sub-image of the j-th product sample image in the first training dataset. ij Let b represent the weight value of the i-th product sample sub-image of the j-th product sample image, where b represents the first coefficient and σ represents the second coefficient.
[0053] Among them, W ij The specific values of b and σ can be appropriately set and adjusted according to the actual application scenario.
[0054] It should be noted that, compared to using other conventional loss functions as the first loss function (e.g., mean squared error loss function), this embodiment of the invention improves upon the existing mean squared error loss function by setting corresponding weight values for the defect prediction results of each product sample sub-image and performing a linear transformation using preset first and second coefficients to obtain the linearly transformed defect prediction results. Then, the difference between this linearly transformed result and the product defect label of the same product sample sub-image is calculated. Using the aforementioned method, the defect prediction results of each product sample sub-image can be corrected, and a more accurate difference value (i.e., the difference between the labeled product defect label and the predicted product defect) can be obtained, thereby improving the accuracy of model training.
[0055] Furthermore, using this implementation scheme, weight values can be adaptively set based on factors such as the image quality of each product sample sub-image. For example, higher weights can be assigned to product sample sub-images of higher quality, making them have a greater impact on the training process. This improves the targeting of training and further enhances the training effect. In the specific implementation of step S12, the types of products contained in the product sample images in the second training dataset should be the same as the types of products contained in the product sample images in the first training dataset. For example, they should all be finished or semi-finished copper rods from one or more process segments of a copper casting production line, or finished or semi-finished steel billets from one or more process segments of a steel casting production line.
[0056] Both the first and second training datasets contain product sample images labeled with product defect tags. Product sample images with the same product defect tag can be grouped into the same product sample image group. Therefore, the first and / or second training datasets can be image sets comprising multiple product sample image groups.
[0057] Specifically, during the process of using the second loss function and inputting the second training dataset into the initial model for iterative training, the function value of the second loss function is minimized until the function value of the second loss function reaches the second threshold, at which point the iterative training stops. In each iteration, the parameters of the pre-trained model are optimized until the iterative training stops, at which point further optimized model parameters and the retrained model are obtained.
[0058] Wherein, the ratio of the total number of product sample images contained in the second training dataset (i.e., the second number) to the total number of product sample images contained in the first training dataset (i.e., the first number) is greater than or equal to 10. Wherein, the ratio of the convergence threshold of the function value of the first loss function (i.e., the first threshold) to the convergence threshold of the function value of the second loss function (i.e., the second threshold) is greater than or equal to 2.
[0059] As a non-limiting embodiment, the ratio of the second quantity to the first quantity can be selected from an appropriate value in the range [10, 50], for example, the second quantity is 40 times the first quantity; the ratio of the first threshold to the second threshold can be selected from an appropriate value in the range [2, 5], for example, the first threshold is twice the second threshold.
[0060] It should be noted that, in this embodiment of the invention, since the second training dataset is used for further iterative training to optimize the initially trained model, based on the initial iterative training using the first training dataset, the number of iterations in the second iterative training process is much greater than the number of iterations in the initial iterative process. Research has shown that setting the ratio of the second quantity to the first quantity to be greater than or equal to 10, rather than setting it to a smaller ratio (e.g., 3 times, 5 times, etc.), is to achieve an order-of-magnitude increase in the number of images, thereby significantly improving the effect of the second iterative training. Furthermore, using the retrained model obtained from the training, more accurate product defect prediction results can be obtained.
[0061] Non-limiting, the first quantity can be selected from an appropriate value in the range [300, 500], for example, 500; the second quantity can be selected from an appropriate value in the range [3000, 25000], for example, 20000. The first threshold can be selected from an appropriate value in the range [0.02, 0.05], for example, 0.02; the second threshold can be selected from an appropriate value in the range [0.004, 0.01], for example, 0.01.
[0062] It should be noted that, in this embodiment of the invention, since the second loss function is used for further optimization of the initially trained model through iterative training based on the first loss function, in order to achieve a greater convergence of the second loss function in the iterative training and to ensure that the number of iterations in the iterative training process is much greater than the number of iterations in the initial iterative process, research has found that setting the ratio of the first threshold to the second threshold to be greater than or equal to 2, compared to setting it to a smaller ratio (e.g., 1.1 times, 1.2 times, etc.), is to achieve a multiple reduction in the convergence value of the loss function, thereby significantly increasing the convergence effectiveness of the iterative training and improving the effect of the iterative training. Furthermore, using the retrained model obtained from the training, more accurate product defect prediction results can be obtained.
[0063] In one specific implementation, the product sample images in the second training dataset can be obtained in the same way as the first training dataset. For example, it can be obtained by acquiring images of semi-finished or finished products in one or more process sections of a product production line, followed by image cropping, inverted stitching, and labeling with product defect tags, to obtain the product sample images used to train the pre-trained model. For details on how the second training dataset is obtained, please refer to the relevant content in step S11 regarding the method for obtaining the first training dataset; it will not be repeated here.
[0064] In another specific implementation, the second training dataset can be obtained by augmenting the first training dataset using AIGC technology. Specifically, the first training dataset can be augmented using AIGC technology to obtain an augmented product defect image set; the combination of the augmented product defect image set and the first training dataset is used as the second training dataset.
[0065] AIGC technology is short for Generative Artificial Intelligence (AIG), which specifically refers to artificial intelligence-based techniques that use existing data to learn and recognize information and generate similar or related content with appropriate generalization capabilities.
[0066] It should be noted that, compared with the conventional method of obtaining the second training dataset based on image capture / collection, this implementation scheme obtains the second training dataset by adopting the above-mentioned data augmentation scheme. On the one hand, it can reduce the cost of obtaining the second training dataset; on the other hand, it can more efficiently obtain a sufficient number of product defect images with rich content for subsequent iterative training processes.
[0067] Furthermore, the step of augmenting the first training dataset using AIGC technology to obtain an augmented product defect image set may specifically include: extracting features from the product sample images in the first training dataset to obtain a feature vector for each product sample image; clustering the product sample images based on the similarity between the feature vectors of every two product sample images to obtain one or more product sample image subsets; performing feature fusion on each product sample image subset based on the feature vectors of the product sample images therein to obtain multiple fused feature vectors corresponding to that product sample image subset; and generating the augmented product defect image set based on the obtained fused feature vectors.
[0068] In a specific implementation, a pre-built AIGC image generation model can be used to perform the aforementioned data augmentation operation on the first training dataset and output the augmented product defect image set. Specifically, the pre-built AIGC image generation model may include: an image feature extraction module, a clustering module, a feature fusion module, and an augmented product defect image generation module.
[0069] The image feature extraction module is used to extract features from the product sample images in the input first training dataset to obtain a feature vector for each product sample image; the clustering module is used to cluster the product sample images according to the similarity between the feature vectors of every two product sample images to obtain one or more product sample image subsets; the feature fusion module is used to perform feature fusion on each product sample image subset based on the feature vectors of the product sample images therein to obtain multiple fused feature vectors corresponding to the product sample image subset; and the expanded product defect image generation module is used to generate the expanded product defect image set based on the obtained fused feature vectors.
[0070] In practical implementation, the similarity between feature vectors can be calculated using existing conventional methods, such as Euclidean distance or cosine similarity calculation methods. The method for clustering the product sample images based on the similarity between the feature vectors of every two product sample images can be selected from methods such as K-means clustering or hierarchical clustering.
[0071] In some embodiments, the feature fusion method based on the feature vectors of the product sample images in each subset of product sample images may specifically include: arbitrarily combining the product sample images in pairs within the subset of product sample images to obtain multiple product sample image groups; for each product sample image group, concatenating the feature vectors of the two product sample images in the group to obtain the fused feature vector (i.e., the concatenated vector) corresponding to the product sample image group, thereby obtaining multiple fused feature vectors corresponding to the subset of product sample images.
[0072] In other embodiments, the product sample images in each product sample image subset can be combined in other appropriate ways. For example, multiple product sample image groups can be obtained by grouping n product sample images together. Then, for each product sample image group, the feature vectors of the multiple product sample images in the group are concatenated to obtain the fused feature vector corresponding to the product sample image group, thereby obtaining multiple fused feature vectors corresponding to the product sample image subset. Here, n can be selected from an appropriate value in [2, N], N is the total number of images in the product sample image subset, and both n and N are positive integers.
[0073] Furthermore, the number of product sample images in different product sample image groups can be the same or different.
[0074] Without limitation, for the subset of product sample images, all possible product sample image groups can be obtained by combining every 2 product sample images as a group, every 3 product sample images as a group, and so on, and by combining N product sample images as a group to obtain a group containing all product sample images. Then, from at least a portion of the obtained product sample image groups, the subsequent step of vector concatenation of the feature vectors of multiple product sample images in the group is performed to obtain the corresponding fused feature vector.
[0075] In this embodiment of the invention, during the feature fusion process, by employing the aforementioned image combination method, compared to the conventional arbitrary combination of two images, the number of product sample image groups can be significantly increased, thereby obtaining a larger number of fused feature vectors. Furthermore, based on the larger number of fused feature vectors, a correspondingly larger number of richer and more diverse expanded product defect images can be generated, improving the model training effect during subsequent iterations.
[0076] It is understood that, based on the fused feature vectors, the total number of expanded product defect images (denoted as the target number) in the generated expanded product defect image set is equal to the difference between the total number of product sample images in the second training dataset (i.e., the second number) and the total number of product sample images in the first training dataset (i.e., the first number). Therefore, if each fused feature vector generates a single expanded product defect image, it means that in the above embodiment, the total number of product sample image groups obtained by combining product sample images should be greater than or equal to the target number.
[0077] It should be noted that in practical applications, when the total number of product sample image groups obtained by exhausting all combination methods is still less than the required target number, we can preprocess the feature vectors of the product sample images within the product sample image group by scrambling the order or removing some of the encoding, and then concatenate the preprocessed feature vectors to obtain the corresponding fused feature vector.
[0078] In specific implementation, the concatenation of feature vectors from product sample images in each product sample image group refers to inserting one vector into a specified position of another vector. This specified position can be the tail of the concatenated vector, that is, the position after the last encoding of the concatenated vector. Thus, compared to inserting from the middle or other encoding positions of the vector, inserting after the last encoding of the vector preserves the encoding order of the concatenated vectors, ensuring that the information contained in the vectors is not destroyed.
[0079] Furthermore, the concatenation can be a complete concatenation (also known as a whole concatenation). In this way, compared to dividing the vector into multiple sub-vectors and then inserting them in a scattered or random manner, adopting a complete concatenation method can reduce the probability of concatenation errors and also help to further preserve the original information contained in the vector.
[0080] Furthermore, before performing feature extraction on the product sample images in the first training dataset, the method further includes: performing binarization processing on the product sample images in the first training dataset. After binarization, a binary image corresponding to the product sample image is obtained, where each pixel in the binary image is either black or white (for example, each pixel has only two possible values: 0 or 255).
[0081] In this embodiment of the invention, on the one hand, compared with the multi-channel color images used in conventional AIGC technology, this implementation uses binary images. Since binary images occupy less space, the computational overhead of feature extraction can be reduced and efficiency improved. On the other hand, feature extraction based on binary images helps to obtain the edge or contour features of the product, so that an expanded product defect image similar to the contour and shape of the product sample image in the first training dataset can be obtained through subsequent feature fusion.
[0082] In practice, the product defect labels in the expanded product defect image set are obtained by predicting product defects using the pre-trained model.
[0083] In this embodiment of the invention, the pre-trained model is used to predict product defects in the expanded product defect image set to obtain its product defect labels. Since the pre-trained model is a relatively optimized model trained on a first training dataset labeled with product defect labels, it can accurately predict product defects in the input images after training. Therefore, compared to manually labeling the expanded product defect image set, this method helps reduce labeling costs and improve labeling efficiency.
[0084] In practical implementation, the second loss function can be represented by the following expression:
[0085]
[0086] Where loss2 represents the function value of the second loss function, N represents the second quantity, i represents the index of the product sample image in the second training dataset, and y i y represents the product defect prediction result for the i-th product sample image in the second training dataset. i ' represents the product defect label of the i-th product sample image in the second training dataset.
[0087] It should be noted that the second loss function can also be other appropriate loss functions that are already used for training machine learning models, such as the cross-entropy loss function.
[0088] In the specific implementation of step S13, the image to be labeled can also be obtained by image acquisition of semi-finished or finished products in one or more process sections (or process flows) of the product production line, targeting the actual scenario of the process section. In order to obtain more accurate product defect prediction results, the type of product contained in the image to be labeled should be the same as the type of product contained in the product sample images of the first training dataset and the second training dataset.
[0089] In this embodiment of the invention, the initial model can be deeply optimized through a two-step training process of initial iterative training and subsequent iterative training, compared to single-step training. Furthermore, in the subsequent iterative training process, a larger amount of training data and a smaller loss function convergence threshold are set. Specifically, the amount of training data in the subsequent iterative training process is at least 10 times that in the initial iterative training process, and the loss function convergence threshold in the initial iterative training process is at least twice that of the initial iterative training process.
[0090] By employing the aforementioned step-by-step training method, the number of iterations in the subsequent training process can be significantly greater than the number of iterations in the initial training process. This helps improve the training effect of the model and obtain a retrained model with stronger performance and higher accuracy in predicting product defects. Furthermore, by using the optimized retrained model to predict product defects in the labeled images, it is possible to quickly obtain a large training dataset with accurate product defect labels (i.e., the third training dataset).
[0091] It should be noted that the third training dataset obtained using this implementation scheme has been accurately labeled with product defect labels (denoted as the first label). These product defect labels indicate the type of defect the product possesses (for example, for copper rods, the product defect labels could be selected from: cracking, ripples, inclusions, etc.). Based on this, in the subsequent model training phase using the third training dataset, other appropriate labels (denoted as the second label) can be added to the third training dataset according to the actual application scenario requirements. For example, each product image in the third training dataset can be labeled with a product defect location label (manual labeling or automatic algorithm labeling), which indicates the defect location information of the product.
[0092] Therefore, a fourth training dataset can be obtained, which includes both product defect labels (or product defect type labels) and product defect location labels. This fourth training dataset can be used to train a pre-defined detection model, resulting in an optimized detection model capable of simultaneously detecting both product defects and their locations in the product image to be detected.
[0093] Reference Figure 2 , Figure 2 This is a partial flowchart of another AIGC-based training dataset determination method in an embodiment of the present invention. The other AIGC-based training dataset determination method may include... Figure 1 Steps S11 to S13 in the illustrated embodiment may further include steps S21 to S23, wherein step S21 is executed after step S13. The following describes... Figure 1 The different contents of the embodiments shown are explained.
[0094] In step S21, defect location labels are annotated on the third training dataset to obtain the fourth training dataset.
[0095] In step S22, the fourth training dataset is used to train the preset detection model to obtain an optimized detection model.
[0096] In practice, the detection model can be selected from existing models that can achieve target detection, such as the YOLOV model version 5.
[0097] In step S23, the optimized detection model is used to perform defect detection on the product image to be detected, so as to obtain the product defects and defect locations in the product image to be detected.
[0098] For more detailed information on steps S21 to S23 in the specific implementation, please refer to the preceding text and... Figure 1 The steps described in the document will be executed, and will not be repeated here.
[0099] Reference Figure 3 , Figure 3 This is a schematic diagram of a training dataset determination device based on AIGC according to an embodiment of the present invention. The training dataset determination device based on AIGC may include:
[0100] The preliminary training module 31 is used to input the first training dataset into the initial model for preliminary iterative training using a first loss function until the function value of the first loss function reaches a first threshold, thereby stopping the iterative training and obtaining a pre-trained model. The first training dataset contains a first number of product sample images.
[0101] The retraining module 32 is used to input the second training dataset into the pre-trained model using a second loss function for iterative training until the function value of the second loss function reaches a second threshold, at which point the iterative training stops and a retrained model is obtained. The second training dataset is obtained by expanding the first training dataset based on AIGC technology. The second training dataset contains a second number of product sample images. Both the first and second training datasets are labeled with product defect tags.
[0102] The training dataset determination module 33 is used to input multiple images to be labeled into the retraining model for product defect prediction, and to label the images to be labeled using the product defect prediction results output by the retraining model to obtain a third training dataset.
[0103] Wherein, the ratio of the second quantity to the first quantity is greater than or equal to 10, and the ratio of the first threshold to the second threshold is greater than or equal to 2.
[0104] For the principles, implementation details, and beneficial effects of this AIGC-based training dataset determination device, please refer to the preceding text. Figures 1 to 2 The description of the training dataset determination method based on AIGC shown is not repeated here.
[0105] This invention also provides a readable storage medium, such as a computer-readable storage medium, on which a computer program is stored, the computer program being executed by a processor. Figures 1 to 2 The steps of the AIGC-based training dataset determination method are shown. The computer-readable storage medium may include non-volatile or non-transitory memory, and may also include optical discs, hard disk drives, solid-state drives, etc.
[0106] Specifically, in this embodiment of the invention, the processor can be a central processing unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0107] It should also be understood that the memory in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDR SDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0108] This invention also provides a terminal, including a memory and a processor. The memory stores a computer program that can run on the processor, and when the processor runs the computer program, it performs the above-described... Figures 1 to 2 The steps of the AIGC-based training dataset determination method are shown. The terminal may include, but is not limited to, mobile phones, computers, tablets, and other terminal devices, as well as servers, cloud platforms, etc.
[0109] It should be understood that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article indicates that the preceding and following related objects have an "or" relationship.
[0110] In the embodiments of this application, "multiple" refers to two or more.
[0111] The descriptions of "first," "second," etc., appearing in the embodiments of this application are for illustrative purposes and to distinguish the objects being described. They have no order and do not indicate any special limitation on the number of devices in the embodiments of this application, nor do they constitute any limitation on the embodiments of this application.
[0112] It should be noted that the sequence number of each step in this embodiment does not represent a limitation on the execution order of each step.
[0113] While the present invention has been disclosed above, it is not limited thereto. Any person skilled in the art can make various modifications and alterations without departing from the spirit and scope of the invention; therefore, the scope of protection of the present invention should be determined by the scope defined in the claims.
Claims
1. A method for determining an AIGC-based training data set, characterized in that, The method comprises the following steps: using a first loss function, inputting a first training data set into an initial model for preliminary iterative training until the function value of the first loss function reaches a first threshold value, stopping the iterative training, and obtaining a pre-trained model, wherein the first training data set contains a first number of product sample images; using a second loss function, inputting a second training data set into the pre-trained model for re-iterative training until the function value of the second loss function reaches a second threshold value, stopping the iterative training, and obtaining a re-trained model, wherein the second training data set is obtained by expanding the first training data set based on AIGC technology, the second training data set contains a second number of product sample images, and the first training data set and the second training data set are both labeled with product defect labels; inputting a plurality of images to be labeled into the re-trained model for product defect prediction, and labeling the images to be labeled using the product defect prediction result output by the re-trained model to obtain a third training data set; wherein the ratio of the second number to the first number is greater than or equal to 10, and the ratio of the first threshold value to the second threshold value is greater than or equal to 2; wherein the first loss function is represented by the following expression: ; in, This represents the function value of the first loss function. This indicates the first quantity. This represents the sequence number of the product sample image in the first training dataset. This indicates the number of product sample sub-images contained in a product sample image. This indicates the sequence number of the product sample sub-image within the product sample image. This represents the j-th product sample image in the first training dataset. Product defect prediction results for Zhang's product sample sub-image This represents the j-th product sample image in the first training dataset. Product defect labels in Zhang's product sample sub-image. Represents the j-th product sample image. The weight values of the product sample subplot. Indicates the first coefficient. This indicates the second coefficient.
2. The method of claim 1, wherein, Before inputting the second training data set into the pre-trained model for re-iterative training, the method further comprises: expanding the first training data set based on AIGC technology to obtain an expanded product defect image set; using the expanded product defect image set and the set of the first training data set as the second training data set.
3. The method of claim 2, wherein, Expanding the first training data set based on AIGC technology to obtain an expanded product defect image set comprises: extracting features from the product sample images in the first training data set to obtain a feature vector for each product sample image; clustering the product sample images according to the similarity between the feature vectors of every two product sample images to obtain one or more product sample image subsets; for each product sample image subset, performing feature fusion based on the feature vectors of the product sample images therein to obtain a plurality of fusion feature vectors corresponding to the product sample image subset; generating the expanded product defect image set based on the obtained fusion feature vectors.
4. The method of claim 3, wherein, For each product sample image subset, performing feature fusion based on the feature vectors of the product sample images therein to obtain a plurality of fusion feature vectors corresponding to the product sample image subset comprises: grouping the product sample images in each product sample image subset into groups of n product sample images each to obtain a plurality of product sample image groups; for each product sample image group, performing vector splicing on the feature vectors of the n product sample images in the product sample image group to obtain a fusion feature vector corresponding to the product sample image group, thereby obtaining a plurality of fusion feature vectors corresponding to the product sample image subset; wherein 2≤n≤N, N is the total number of product sample images in the product sample image subset, and n and N are both positive integers.
5. The method according to claim 2 or 3, characterized in that, The product defect label of the expanded product defect image set is obtained by using the pre-trained model to predict product defects.
6. The method of claim 3, wherein, Before feature extraction is performed on the product sample images in the first training data set, the method further comprises: The product sample images in the first training data set are subjected to binarization processing.
7. The method of claim 1, wherein, Each product sample image of the first training data set is obtained by one or more times of forward and reverse inversion splicing of a single product sample sub-image. Each product sample sub-image contained in the product sample image has a respective product defect label.
8. The method of claim 1, wherein, The second loss function is expressed by the following expression: ; wherein, denotes a function value of the second loss function, denotes the second quantity, denotes a serial number of a product sample image in the second training data set, denotes a product defect prediction result of the i-th product sample image of the second training data set, denotes a product defect label of the i-th product sample image of the second training data set.
9. The method of claim 1, wherein, After the third training data set is obtained, the method further comprises: The third training data set is labeled with defect position labels to obtain a fourth training data set; The fourth training data set is used to train a preset detection model to obtain an optimized detection model; The optimized detection model is used to detect defects in a product image to be detected to obtain product defects and defect positions in the product image to be detected.
10. An AIGC-based training data set determination apparatus, characterized by, Comprise: A preliminary training module is configured to use a first loss function to input a first training data set into an initial model for preliminary iterative training until the function value of the first loss function reaches a first threshold value, at which point the iterative training is stopped, to obtain a pre-trained model, wherein the first training data set contains a first number of product sample images; A retraining module is configured to use a second loss function to input a second training data set into the pre-trained model for reiterative training until the function value of the second loss function reaches a second threshold value, at which point the iterative training is stopped, to obtain a retrained model, wherein the second training data set is obtained by expanding the first training data set based on AIGC technology, the second training data set contains a second number of product sample images, and the first training data set and the second training data set are both labeled with product defect labels; A training data set determination module is configured to input a plurality of images to be labeled into the retrained model for product defect prediction, and to label the images to be labeled based on the product defect prediction results output by the retrained model to obtain a third training data set; The ratio of the second number to the first number is greater than or equal to 10, and the ratio of the first threshold value to the second threshold value is greater than or equal to 2. The first loss function is expressed by the following expression: ; in, This represents the function value of the first loss function. This indicates the first quantity. This represents the sequence number of the product sample image in the first training dataset. This indicates the number of product sample sub-images contained in a product sample image. This indicates the sequence number of the product sample sub-image within the product sample image. This represents the j-th product sample image in the first training dataset. Product defect prediction results for Zhang's product sample sub-image This represents the j-th product sample image in the first training dataset. Product defect labels in Zhang's product sample sub-image. Represents the j-th product sample image. The weight values of the product sample subplot. Indicates the first coefficient. This indicates the second coefficient.
11. A storage medium having stored thereon a computer program, characterized in that The computer program is run by the processor to perform the steps of the AIGC-based training data set determination method of any one of claims 1 to 9.
12. A terminal comprising a memory and a processor, said memory having stored thereon a computer program capable of running on said processor, characterized in that, The processor runs the computer program to perform the steps of the AIGC-based training data set determination method of any one of claims 1 to 9.
Citation Information
Patent Citations
Casting defect identification model training method, defect identification method, device and system
CN115661572A
Algorithm training platform based on AIGC
CN116204325A
Model training and defect detection method and device, medium, equipment and program product
CN116385838A