A rapid training method, system, medium and computer for grey cloth defect model

By calculating the feature vector distance measurement function in the deep learning model and constraining the training process, we quickly adapt to new defects, and solving the problem of too long training time of deep learning models, achieving the effect of quickly identifying new defects without affecting the original accuracy.

CN115601300BActive Publication Date: 2025-08-29SHANGHAI ZHIJING INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211090069.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-07
Publication Date
2025-08-29
Estimated Expiration
2042-09-07

AI Technical Summary

Technical Problem

The existing deep learning models have too long training time when identifying new textile defects, which affects production efficiency and cannot quickly adapt to new defects without affecting the original defect detection accuracy.

Method used

By obtaining a pre-trained deep learning neural network model, randomly filtering sample pictures and inputting old and new neural networks, calculating the feature vector distance measurement function, generating an overall loss function and constraining the training process to quickly adapt to new defects while maintaining the detection accuracy of the original defects.

Benefits of technology

It has achieved the significant improvement in training speed without affecting the original detection accuracy, and the training speed is increased by more than 50 times, while maintaining the accuracy of identification of new defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115601300B_ABST
    Figure CN115601300B_ABST
Patent Text Reader

Abstract

The present invention relates to a rapid training method for a grey cloth defect model. The key points of the technical solution are as follows: the present application randomly extracts a set of old defect samples and simultaneously inputs the old samples into a new neural network and an old neural network, thereby generating the corresponding feature vectors of the outputs of each layer. The method also calibrates the differences of the neural networks by calculating the distance metric function of the feature vectors output by each layer, and constrains the neural network through a loss function so that the neural network does not affect the accuracy of the original feature extraction capability while relearning the features of the new defects. Compared with traditional training methods, the training method provided by the present application is faster and does not affect the original feature extraction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of defect detection, and more particularly to a method, system, medium and computer for quickly training a grey cloth defect model. Background Art

[0002] During the weaving process, grey fabric often requires defect detection to determine the location and size of defects. Existing methods for this use a combination of visual inspection and deep learning to photograph and inspect the fabric surface. This deep learning-based detection method requires inputting a large number of defect photos to train a deep learning model. The trained deep learning model can then accurately detect the defects it was trained on. However, this trained deep learning model cannot identify new textile defects that arise during actual production.

[0003] For this situation, the existing solution is usually to mix the newly discovered defect photos into the original training samples and retrain the deep learning model. However, this training method is time-consuming. For factories with strict construction schedules, they need to endure the losses caused by downtime or can only tolerate the losses caused by missed defects. Therefore, in this case, how to shorten the time spent on retraining the deep learning model for new defects while not affecting the deep learning model's detection accuracy for the original defects has become a pressing problem that needs to be solved. Summary of the Invention

[0004] In view of the shortcomings of the existing technology, the purpose of the present invention is to provide a method for quickly training a grey cloth defect model to solve the problem that the existing deep learning model takes too long to train new defects.

[0005] The above technical objectives of the present invention are achieved through the following technical solutions: a method for quickly training a grey cloth defect model, S1, obtaining a number of first sample images containing untrained defects, preprocessing the first sample images, and generating a number of corresponding second sample images;

[0006] S2. Obtain a pre-trained first deep learning neural network model, a second deep learning neural network model, and a corresponding training sample set, and randomly select third sample images from the training sample set, the number of which is equal to the number of second sample images; wherein the first deep learning neural network model and the second deep learning neural network model are the same;

[0007] S3. Input the plurality of third sample images into the first deep learning neural network model, and obtain a first eigenvector output by the backbone network layer, a second eigenvector output by the hybrid network layer, and a third eigenvector output by the prediction network layer of the first deep learning neural network model;

[0008] S4. Inputting the plurality of second sample images into the second deep learning neural network model for training to generate corresponding classification loss function and regression loss function;

[0009] S5. Constrain the second deep learning neural network model according to the classification loss function and the regression loss function to generate a corresponding third deep learning neural network model;

[0010] S6. Input the plurality of third sample images into the third deep learning neural network model, and obtain the fourth eigenvector output by the backbone network layer, the fifth eigenvector output by the hybrid network layer, and the sixth eigenvector output by the prediction network layer of the third deep learning neural network model;

[0011] S7. Calculate a first distance metric function between the first eigenvector and the fourth eigenvector, a second distance metric function between the second eigenvector and the fifth eigenvector, and a third distance metric function between the third eigenvector and the sixth eigenvector, respectively;

[0012] S8. Generate a corresponding overall loss function based on the weighted sum of the weights of the classification loss function, the regression loss function, the first distance metric function, the second distance metric function, and the third distance metric function, and make the overall loss function less than the loss function threshold; to complete one training session, and record the corresponding number of training sessions;

[0013] S9. Determine whether the number of training times reaches the predetermined number of training times. If so, terminate the training; if not, use the third deep learning neural network model as the new second deep learning neural network model, and re-extract defect pictures equal to the number of second sample pictures from the training sample set as new third sample pictures, and return to step S3.

[0014] Optionally, step S1 includes the following steps:

[0015] S11, resizing the first sample images using an image pyramid or an openCV resize function, and generating corresponding first sample cropped images;

[0016] S12, performing grayscale processing on the plurality of first sample cropped images respectively, to generate a plurality of first sample grayscale images accordingly;

[0017] S13: Perform brightness adjustment on the first sample grayscale images respectively, and generate corresponding second sample images.

[0018] Optionally, the step S13 includes performing histogram equalization on each of the first sample grayscale images to generate corresponding second sample images.

[0019] Optionally, the regression loss function uses a GIoU loss function, and the GIoU loss function expression is:

[0020]

[0021] Where A is the actual location bounding box of the untrained defect, B is the bounding box predicted by the neural network, and C is the closure surrounding A and B.

[0022] Optionally, the classification loss function adopts a Focal Loss loss function, and the focal loss function expression is:

[0023] FL(p t )=-(1-p t ) γ log(p t )

[0024]

[0025] Where p is the probability of the label predicted by the first deep learning neural network model, γ is the adjustment factor, and y is the positive and negative samples.

[0026] Optionally, the first distance metric function, the second distance metric function, and the third distance metric function all use a ranking loss function; the rank loss function expression is:

[0027] L(x0,x1,y)=y||f(x0)-f(x1)||+(1-y)max(0,||f(x0)-f(x1)||)

[0028] Where x0 and x1 represent the representation of the two eigenvectors by the sample, respectively, and y is a binary number. When the two input eigenvectors are positive samples, y is 1, and when the two input eigenvectors are negative samples, y is 0.

[0029] Optionally, the loss function threshold is 0.1.

[0030] A rapid training system for a grey cloth defect model, comprising:

[0031] An image acquisition module, configured to acquire a plurality of first sample images containing untrained defects;

[0032] An image processing module, configured to pre-process the plurality of first sample images to generate a plurality of second sample images accordingly;

[0033] Image extraction module: used for randomly selecting third sample images from the training sample set, the number of which is equal to that of the second sample images;

[0034] Feature vector acquisition module; used to obtain the three feature vectors output by the backbone network layer, hybrid network layer, and prediction network layer of the deep learning neural network model;

[0035] A neural network training module is configured to input the plurality of second sample images into the second deep learning neural network model for training, generate a corresponding classification loss function and a regression loss function, and constrain the second deep learning neural network model according to the classification loss function and the regression loss function to generate a corresponding third deep learning neural network model;

[0036] A feature vector comparison module is configured to respectively calculate a first distance metric function between the first feature vector and the fourth feature vector, a second distance metric function between the second feature vector and the fifth feature vector, and a third distance metric function between the third feature vector and the sixth feature vector;

[0037] A loss function calculation module is configured to generate an overall loss function based on the weighted sum of the classification loss function, the regression loss function, the first distance metric function, the second distance metric function, and the third distance metric function, and to make the overall loss function less than a loss function threshold;

[0038] Cycle counting module: used to count the number of training times and determine whether the number of training times reaches the predetermined number of training times.

[0039] A computer device includes a memory and a processor, wherein the memory stores a computer program and the processor implements the steps of the above method when executing the computer program.

[0040] A computer-readable storage medium stores a computer program, which implements the steps of the above method when executed by a processor.

[0041] In summary, the present invention has the following beneficial effects: This application randomly extracts a set of old defect samples and simultaneously inputs the old samples into the new neural network and the old neural network, thereby generating the corresponding feature vectors of the output of each layer, and calibrates the differences of the neural networks by calculating the distance metric function of the feature vectors output by each layer. Furthermore, through the constraints of the loss function, the neural network can relearn the features of the new defects without affecting the accuracy of the original feature extraction capability. Compared with traditional training methods, the training method provided by this application is faster and does not affect the original feature extraction accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 It is a schematic diagram of the process of the present invention;

[0043] Figure 2 Schematic diagram of the process of step S1 of the present invention;

[0044] Figure 3 This is a structural diagram of a rapid training system for a grey cloth defect model of the present invention.

[0045] Figure 4 2 is a diagram showing the internal structure of a computer device in an embodiment of the present invention.

[0046] In the figure: 1. Image acquisition module; 2. Image processing module; 3. Image extraction module; 4. Feature vector acquisition module; 5. Neural network training module; 6. Feature vector comparison module; 7. Loss function calculation module; 8. Cycle counting module. DETAILED DESCRIPTION

[0047] To make the objectives, features, and advantages of the present invention more readily apparent, the following detailed description of the present invention is provided with reference to the accompanying drawings. The accompanying drawings illustrate several embodiments of the present invention. However, the present invention may be implemented in many different forms and is not limited to the embodiments described herein.

[0048] In the present invention, unless otherwise expressly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or an indirect connection through an intermediate medium, or it can be a communication between the two components. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to the specific circumstances. The terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of such features.

[0049] In the present invention, unless otherwise expressly specified and limited, a first feature being "above" or "below" a second feature may include the first and second features being in direct contact, or may include the first and second features being in contact not directly but through another feature between them. Moreover, a first feature being "above," "above," and "above" a second feature includes the first feature being directly above and obliquely above the second feature, or simply indicates that the first feature is higher in level than the second feature. A first feature being "below," "below," and "below" a second feature includes the first feature being directly below and obliquely below the second feature, or simply indicates that the first feature is lower in level than the second feature. The terms "vertical," "horizontal," "left," "right," "above," "below," and similar expressions are for illustrative purposes only and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore should not be understood as limiting the present invention.

[0050] The present invention is described in detail below with reference to the accompanying drawings and embodiments.

[0051] The present invention provides a method for quickly training a grey cloth defect model. Figure 1 As shown, the following steps are included:

[0052] S1. Obtain several first sample images containing untrained defects, preprocess the several first sample images, and generate several corresponding second sample images; specifically, the preprocessing, on the one hand, adjusts the resolution of the image to reduce the burden of the deep learning neural network model on the device, and on the other hand, performs grayscale processing and brightness adjustment processing on the image to make the image more prominent in terms of defect characteristics.

[0053] S2. Obtain a pre-trained first deep learning neural network model, a second deep learning neural network model, and a corresponding training sample set, and randomly select third sample images from the training sample set, the number of which is equal to the number of second sample images; wherein the first deep learning neural network model and the second deep learning neural network model are the same;

[0054] S3. Input the plurality of third sample images into the first deep learning neural network model, and obtain a first eigenvector output by the backbone network layer, a second eigenvector output by the hybrid network layer, and a third eigenvector output by the prediction network layer of the first deep learning neural network model;

[0055] S4. Inputting the plurality of second sample images into the second deep learning neural network model for training to generate corresponding classification loss function and regression loss function;

[0056] S5. Constraining the second deep learning neural network model according to the classification loss function and the regression loss function to generate a corresponding third deep learning neural network model. Specifically, when the deep learning neural network model learns a new defect, since the deep learning neural network model needs to be constrained according to the loss function, this will cause significant changes to the neural network, thereby affecting the detection accuracy of the deep learning neural network model for the originally trained defects.

[0057] S6. Input the plurality of third sample images into the third deep learning neural network model, and obtain the fourth eigenvector output by the backbone network layer, the fifth eigenvector output by the hybrid network layer, and the sixth eigenvector output by the prediction network layer of the third deep learning neural network model;

[0058] S7. Calculate a first distance metric function between the first eigenvector and the fourth eigenvector, a second distance metric function between the second eigenvector and the fifth eigenvector, and a third distance metric function between the third eigenvector and the sixth eigenvector, respectively;

[0059] Specifically, the distance metric function is used to measure the changes in the deep learning neural network model after training for new defects, and how big the difference is from the initial deep learning neural network model. This step is to reduce the changes in the feature extraction neural network by comparing the differences in feature extraction between the backbone network layer, hybrid network layer and prediction network layer between the two deep learning neural network models, maintain the invariance of the network, so that the feature extraction neural network can detect new defects while maintaining the accuracy of detecting old defects.

[0060] S8. Generate a corresponding overall loss function based on the weighted sum of the weights of the classification loss function, the regression loss function, the first distance metric function, the second distance metric function, and the third distance metric function, and make the overall loss function less than the loss function threshold; to complete one training session, and record the corresponding number of training sessions;

[0061] Specifically, the weights and pre-set values ​​are affected by the constraints of the classification loss function and the regression loss function on the neural network. Therefore, by changing the values ​​of the classification loss function and the regression loss function, the sizes of the three metric functions can be affected, thereby affecting the value of the overall loss function. Specifically, the loss function threshold is set to 0.1 in this embodiment. That is, when the overall loss function is below 0.1, it can be considered that the recognition accuracy of the newly trained neural network model is not much different from that of the original model.

[0062] S9. Determine whether the number of training times reaches the predetermined number of training times. If so, terminate the training; if not, use the third deep learning neural network model as the new second deep learning neural network model, and re-extract defect pictures equal to the number of second sample pictures from the training sample set as new third sample pictures, and return to step S3.

[0063] Specifically, the present application is to constrain the newly trained neural network model so that the feature extraction of the newly trained neural network model is not much different from that of the initial neural network model. In this way, it is necessary to perform cyclic training again and again under the constraint of the overall loss function. In the step S9, the second deep learning neural network model is used as the new first deep learning neural network model, that is, the second sample image is input into the second neural network model after the constraint for training, and the corresponding third neural network model is generated, and then the subsequent steps are performed in sequence; then, the defect images equal to the number of the second sample images are re-extracted from the training sample set and input into the trained third neural network to generate a fourth neural network, and so on. In practical applications, in order to improve the recognition accuracy of the deep learning neural network model for new defects and improve the defect recognition degree of the new deep learning neural network model, the above-mentioned cyclic steps can be continued. In summary, when the above-mentioned cyclic steps are repeated more than 100 times, the overall loss function can be made less than the loss function threshold. In the actual training process, the above-mentioned training process is usually repeated 300 times to ensure that the trained deep learning neural network model can accurately identify new defects without having a significant impact on the original defect detection accuracy. At the same time, compared with the traditional training method, the new defect photos are mixed into the original training sample set for retraining. The training method of this application can increase the training speed by more than 50 times, while ensuring that the recognition accuracy will not be reduced.

[0064] Furthermore, if Figure 2 As shown, step S1 includes the following steps:

[0065] S11, resizing the first sample images using an image pyramid or an openCV resize function, and generating corresponding first sample cropped images;

[0066] S12, performing grayscale processing on the plurality of first sample cropped images respectively, to generate a plurality of first sample grayscale images accordingly;

[0067] S13: Perform brightness adjustment on the first sample grayscale images respectively, and generate corresponding second sample images.

[0068] Furthermore, the step S13 includes performing histogram equalization on the plurality of first sample grayscale images respectively to generate a plurality of second sample images accordingly.

[0069] Furthermore, the regression loss function uses the GloU loss function, and the expression of the GloU loss function is:

[0070]

[0071] Where A is the bounding box of the actual location of the untrained defect, B is the bounding box predicted by the neural network, and C is the closure surrounding A and B. The closure is the smallest rectangular box that can enclose the bounding boxes A and B (when both the bounding boxes A and B are rectangular boxes). In this way, the gap between the predicted value and the actual value can be judged and corresponding constraints can be imposed to improve the accuracy of the prediction.

[0072] Furthermore, the classification loss function adopts the Focal Loss loss function, and the expression of the focal loss function is:

[0073] FL(p t )=-(1-p t ) γ log(p t )

[0074]

[0075] Where p is the probability of the label predicted by the first deep learning neural network model, p t is the mapping function about p, γ is the adjustment factor, and y is the positive and negative samples.

[0076] Furthermore, the first distance metric function, the second distance metric function, and the third distance metric function all use a ranking loss function; the rank loss function expression is:

[0077] L(x0,x1,y)=y||f(x0)-f(x1)||+(1-y)max(0,||f(x0)-f(x1)||)

[0078] In the formula, x0 and x1 represent the representation of the two eigenvectors by the sample, respectively, and y is a binary number. When the two input eigenvectors are positive samples, y is 1, and when the two input eigenvectors are negative samples, y is 0. This expression is to input the same image into different neural networks, and then compare the differences between the eigenvectors generated by the middle layers of the two neural networks to determine whether there is a difference between the two neural network middle layers.

[0079] Furthermore, the loss function threshold is 0.1, that is, after weighted summation, when the overall loss function is 0.1, it can be considered that the trained deep learning neural network model is not much different from the original neural network.

[0080] In summary, this application is mainly divided into three steps: first, selecting training samples with the same number as the new defect training samples from the original training sample set;

[0081] Second, the new defect images are input into the deep learning neural network model for training so that the deep learning neural network model can recognize the new defects, but this will also affect the original recognition ability of the neural network;

[0082] Third, in order to determine how big a change the new neural network has produced, it is necessary to input the training samples taken from the original training set into the original neural network and the new neural network respectively, and then calculate the difference between the feature vector output by the backbone network layer, the feature vector output by the hybrid network layer, and the feature vector output by the prediction network layer.

[0083] According to the above method, an overall training loss function can be generated. Since the changes to the deep learning neural network model are based on the constraints of the classification loss function and the regression loss function, the vector differences between the corresponding layers can be adjusted by modifying the classification loss function and the regression loss function to keep the overall loss function at a low level, that is, the overall loss function is not higher than the loss function threshold. In this way, the neural network can identify new defects without reducing the accuracy of the original defect recognition. At the same time, compared with traditional training methods, the training method provided in this application can maintain considerable accuracy when the training speed is increased by 50 times, and the accuracy is slightly reduced when the training speed is increased by 100 times, but it can still meet the accuracy requirements for the detection of surface defects of grey cloth.

[0084] like Figure 3 As shown, the present invention also provides a rapid training system for a grey cloth defect model, comprising:

[0085] An image acquisition module, configured to acquire a plurality of first sample images containing untrained defects;

[0086] An image processing module, configured to pre-process the plurality of first sample images to generate a plurality of second sample images accordingly;

[0087] Image extraction module: used for randomly selecting third sample images from the training sample set, the number of which is equal to that of the second sample images;

[0088] Feature vector acquisition module; used to obtain the three feature vectors output by the backbone network layer, hybrid network layer, and prediction network layer of the deep learning neural network model;

[0089] A neural network training module is configured to input the plurality of second sample images into the second deep learning neural network model for training, generate a corresponding classification loss function and a regression loss function, and constrain the second deep learning neural network model according to the classification loss function and the regression loss function to generate a corresponding third deep learning neural network model;

[0090] A feature vector comparison module is configured to respectively calculate a first distance metric function between the first feature vector and the fourth feature vector, a second distance metric function between the second feature vector and the fifth feature vector, and a third distance metric function between the third feature vector and the sixth feature vector;

[0091] A loss function calculation module is configured to generate an overall loss function based on the weighted sum of the classification loss function, the regression loss function, the first distance metric function, the second distance metric function, and the third distance metric function, and to make the overall loss function less than a loss function threshold;

[0092] Cycle counting module: used to count the number of training times and determine whether the number of training times reaches the predetermined number of training times.

[0093] The specific limitations of the rapid training system for grey fabric defect models can be found in the limitations of the rapid training method for grey fabric defect models described above and will not be further elaborated here. Each module in the rapid training system for grey fabric defect models described above can be implemented in whole or in part via software, hardware, or a combination thereof. Each of the modules described above can be embedded in or independent of a processor in a computer device in hardware form, or stored in a memory in a computer device in software form, so that the processor can call and execute the corresponding operations of each module.

[0094] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown, the computer device includes a processor, memory, a network interface, and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operating system and computer program in the non-volatile storage medium. When executed by the processor, the computer program implements a method for rapidly training a grey fabric defect model.

[0095] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0096] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0097] S1. Obtain a number of first sample images containing untrained defects, preprocess the first sample images, and generate a number of corresponding second sample images;

[0098] S2. Obtain a pre-trained first deep learning neural network model, a second deep learning neural network model, and a corresponding training sample set, and randomly select third sample images from the training sample set, the number of which is equal to the number of second sample images; wherein the first deep learning neural network model and the second deep learning neural network model are the same;

[0099] S3. Input the plurality of third sample images into the first deep learning neural network model, and obtain a first eigenvector output by the backbone network layer, a second eigenvector output by the hybrid network layer, and a third eigenvector output by the prediction network layer of the first deep learning neural network model;

[0100] S4. Inputting the plurality of second sample images into the second deep learning neural network model for training to generate corresponding classification loss function and regression loss function;

[0101] S5. Constrain the second deep learning neural network model according to the classification loss function and the regression loss function to generate a corresponding third deep learning neural network model;

[0102] S6. Input the plurality of third sample images into the third deep learning neural network model, and obtain the fourth eigenvector output by the backbone network layer, the fifth eigenvector output by the hybrid network layer, and the sixth eigenvector output by the prediction network layer of the third deep learning neural network model;

[0103] S7. Calculate a first distance metric function between the first eigenvector and the fourth eigenvector, a second distance metric function between the second eigenvector and the fifth eigenvector, and a third distance metric function between the third eigenvector and the sixth eigenvector, respectively;

[0104] S8. Generate a corresponding overall loss function based on the weighted sum of the weights of the classification loss function, the regression loss function, the first distance metric function, the second distance metric function, and the third distance metric function, and make the overall loss function less than the loss function threshold; to complete one training session, and record the corresponding number of training sessions;

[0105] S9. Determine whether the number of training times reaches the predetermined number of training times. If so, terminate the training; if not, use the third deep learning neural network model as the new second deep learning neural network model, and re-extract defect pictures equal to the number of second sample pictures from the training sample set as new third sample pictures, and return to step S3.

[0106] In one embodiment, step S1 includes the following steps:

[0107] S11, resizing the first sample images using an image pyramid or an openCV resize function, and generating corresponding first sample cropped images;

[0108] S12, performing grayscale processing on the plurality of first sample cropped images respectively, to generate a plurality of first sample grayscale images accordingly;

[0109] S13: Perform brightness adjustment on the first sample grayscale images respectively, and generate corresponding second sample images.

[0110] In one embodiment, the step S13 includes performing histogram equalization on each of the first sample grayscale images to generate corresponding second sample images.

[0111] In one embodiment, the regression loss function uses the GloU loss function, and the GloU loss function expression is:

[0112]

[0113] Where A is the actual location bounding box of the untrained defect, B is the bounding box predicted by the neural network, and C is the closure surrounding A and B.

[0114] In one embodiment, the classification loss function adopts the Focal Loss loss function, and the focal loss function expression is:

[0115] FL(p t )=-(1-p t ) γ log(p t )

[0116]

[0117] Where p is the probability of the label predicted by the first deep learning neural network model, γ is the adjustment factor, and y is the positive and negative samples.

[0118] In one embodiment, the first distance metric function, the second distance metric function, and the third distance metric function all use a ranking loss function; the rank loss function expression is:

[0119] L(x0,x1,y)=y||f(x0)-f(x1)||+(1-y)max(0,||f(x0)-f(x1)||)

[0120] Where x0 and x1 represent the representation of the two eigenvectors by the sample, respectively. y is a binary number. When the two eigenvectors input are positive samples, y is 1. When the two eigenvectors input are negative samples, y is 0.

[0121] In one embodiment, the loss function threshold is 0.1.

[0122] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0123] The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0124] In summary, this application randomly extracts old defect sample sets and inputs the old samples into the new neural network and the old neural network at the same time, generates the corresponding feature vectors of the output of each layer, and calibrates the differences of the neural networks by calculating the distance measurement function of the feature vectors output by each layer. And through the constraints of the loss function, the neural network will not affect the accuracy of the original feature extraction ability while relearning the characteristics of the new defects. Compared with traditional training methods, the training method provided by this application is faster and does not affect the original feature extraction accuracy.

[0125] The above description is merely a preferred embodiment of the present invention. The scope of protection of the present invention is not limited to the above embodiment. All technical solutions based on the concept of the present invention are within the scope of protection of the present invention. It should be noted that for those skilled in the art, various improvements and modifications that do not depart from the principles of the present invention should also be considered within the scope of protection of the present invention.

Claims

1. A rapid training method for a grey cloth defect model, characterized in that: The following steps are involved: S1. Obtain a number of first sample images containing untrained defects, preprocess the first sample images, and generate a number of corresponding second sample images; S2. Obtain a pre-trained first deep learning neural network model, a second deep learning neural network model, and a corresponding training sample set, and randomly select third sample images from the training sample set, the number of which is equal to the number of second sample images; wherein the first deep learning neural network model and the second deep learning neural network model are the same; S3. Input the plurality of third sample images into the first deep learning neural network model, and obtain a first eigenvector output by the backbone network layer, a second eigenvector output by the hybrid network layer, and a third eigenvector output by the prediction network layer of the first deep learning neural network model; S4. Inputting the plurality of second sample images into the second deep learning neural network model for training to generate corresponding classification loss function and regression loss function; S5. Constrain the second deep learning neural network model according to the classification loss function and the regression loss function to generate a corresponding third deep learning neural network model; S6. Input the plurality of third sample images into the third deep learning neural network model, and obtain the fourth eigenvector output by the backbone network layer, the fifth eigenvector output by the hybrid network layer, and the sixth eigenvector output by the prediction network layer of the third deep learning neural network model; S7. Calculate a first distance metric function between the first eigenvector and the fourth eigenvector, a second distance metric function between the second eigenvector and the fifth eigenvector, and a third distance metric function between the third eigenvector and the sixth eigenvector, respectively; S8. Generate a corresponding overall loss function based on the weighted sum of the classification loss function, the regression loss function, the first distance metric function, the second distance metric function, and the third distance metric function, and make the overall loss function less than the loss function threshold; To complete a training session and record the corresponding number of training sessions; S9. Determine whether the number of training times reaches the predetermined number of training times. If so, terminate the training; if not, use the third deep learning neural network model as the new second deep learning neural network model, and re-extract defect pictures equal to the number of second sample pictures from the training sample set as new third sample pictures, and return to step S3.

2. The rapid training method for a grey cloth defect model according to claim 1, characterized in that: The step S1 comprises the following steps: S11, resizing the first sample images using an image pyramid or an openCV resize function, and generating corresponding first sample cropped images; S12, performing grayscale processing on the plurality of first sample cropped images respectively, to generate a plurality of first sample grayscale images accordingly; S13: Perform brightness adjustment on the first sample grayscale images respectively, and generate corresponding second sample images.

3. The rapid training method for a grey cloth defect model according to claim 2, characterized in that: In step S13, This includes performing histogram equalization on each of the first sample grayscale images to generate corresponding second sample images.

4. The rapid training method for a grey cloth defect model according to claim 1, characterized in that: The regression loss function uses the GIoU loss function, and the GIoU loss function expression is: ; Where A is the actual location bounding box of the untrained defect, B is the bounding box predicted by the neural network, and C is the closure surrounding A and B.

5. The rapid training method for a grey cloth defect model according to claim 1, characterized in that: The classification loss function adopts the Focal Loss loss function, and the expression of the Focal Loss loss function is: ; Where, p is the probability of the label predicted by the first deep learning neural network model, γ is the adjustment factor, and y is the positive and negative samples.

6. The rapid training method for a grey cloth defect model according to claim 1, characterized in that: The first distance metric function, the second distance metric function, and the third distance metric function all use the ranking loss function; the ranking loss function expression is: ; Where x0 and x1 represent the representation of the two eigenvectors by the sample, respectively, and y is a binary number. When the two eigenvectors input are positive samples, y is 1, and when the two eigenvectors input are negative samples, y is 0.

7. The rapid training method for a grey cloth defect model according to claim 1, characterized in that: The loss function threshold is 0.

1.

8. A rapid training system for grey cloth defect model, characterized in that: include: An image acquisition module, configured to acquire a plurality of first sample images containing untrained defects; An image processing module, configured to pre-process the plurality of first sample images to generate a plurality of second sample images accordingly; Image extraction module: used to obtain the pre-trained first deep learning neural network model, the second deep learning neural network model and the corresponding training sample set, and randomly select third sample images equal to the number of second sample images from the training sample set; A feature vector acquisition module is used to obtain three feature vectors output by the backbone network layer, hybrid network layer, and prediction network layer of the deep learning neural network model; the three feature vectors are the first feature vector output by the backbone network layer, the second feature vector output by the hybrid network layer, and the third feature vector output by the prediction network layer; A neural network training module is configured to input the plurality of second sample images into the second deep learning neural network model for training, generate a corresponding classification loss function and a regression loss function, and constrain the second deep learning neural network model according to the classification loss function and the regression loss function to generate a corresponding third deep learning neural network model; A feature vector comparison module is configured to respectively calculate a first distance metric function between the first feature vector and the fourth feature vector, a second distance metric function between the second feature vector and the fifth feature vector, and a third distance metric function between the third feature vector and the sixth feature vector; A loss function calculation module is configured to generate an overall loss function based on the weighted sum of the classification loss function, the regression loss function, the first distance metric function, the second distance metric function, and the third distance metric function, and to make the overall loss function less than a loss function threshold; Cycle counting module: used to count the number of training times and determine whether the number of training times reaches the predetermined number of training times.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

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

Citation Information

Patent Citations

  • Uncontrolled face detection method and system based on convolutional neural network

    CN112926506A

  • Neural network training method and device, equipment and storage medium

    CN114372560A