Corrugated paper defect detection method based on transfer learning and scene adaptive segmentation
By introducing the methods of transfer learning and scene adaptive segmentation, and utilizing the pre-trained SAM model and multi-scale feature fusion, the problems of difficulty in detecting small-scale defects and background noise interference in corrugated paper defect detection are solved, achieving efficient and accurate corrugated paper defect detection.
Patent Information
- Application Number
- CN202510223183.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-27
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2045-02-27
AI Technical Summary
Existing corrugated paper defect detection methods based on convolutional neural networks have poor performance in small-scale defect detection, are easily interfered by background noise, require a large amount of labeled data, and are difficult to obtain.
A method based on transfer learning and scene adaptive segmentation is adopted, and the pre-trained Segment Anything Model (SAM) model is used for adaptation. Combined with multi-scale feature fusion and attention mechanism, transfer learning is used to reduce the demand for labeled data and optimize the detection model.
It improves the accuracy and robustness of corrugated paper defect detection, reduces the demand for data collection and computing resources, and meets the real-time detection needs of industrial production lines.
Smart Images

Figure CN120339162B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of image processing, and particularly relates to a corrugated paper defect detection method based on transfer learning and scene adaptive segmentation. BACKGROUND
[0002] In the production and packaging process of corrugated paper, various defects such as scratches, holes and stains may occur on the surface, which not only affects the appearance of the corrugated paper, but also may cause damage to the packaged products. Traditional corrugated paper defect detection methods rely on manual inspection, which is not only inefficient, but also easily affected by human factors. With the development of computer vision and deep learning technology, it is possible to use automated detection technology to detect defects on the surface of corrugated paper. However, the detection of corrugated paper defects still faces many challenges, including small defect size, diverse types and high similarity to the background. Existing convolutional neural network (CNN) based object detection methods have made significant progress in image recognition and defect detection, but there are still certain limitations in corrugated paper defect detection. For example, traditional CNN models usually require a large amount of labeled data for training, while the acquisition of corrugated paper defect data is difficult. In addition, traditional CNN models perform poorly in detecting small-scale defects and are easily disturbed by background noise. SUMMARY
[0003] The main purpose of the present application is to overcome the shortcomings and deficiencies of the prior art, and to provide a corrugated paper defect detection method based on transfer learning and scene adaptive segmentation.
[0004] In order to achieve the above purpose, the technical scheme adopted by the present application is as follows:
[0005] In a first aspect, the present application provides a corrugated paper defect detection method based on transfer learning and scene adaptive segmentation, comprising the following steps:
[0006] Collecting corrugated paper surface image data and pre-processing to construct a data set;
[0007] Selecting a pre-trained scene adaptive segmentation deep learning model and adapting it through transfer learning to construct a corrugated paper defect detection model;
[0008] Training and optimizing the corrugated paper defect detection model using the data set;
[0009] Generating an explanation for each prediction of the corrugated paper defect detection model and providing it to the user;
[0010] Evaluating and iteratively optimizing the corrugated paper defect detection model.
[0011] As a preferred technical scheme, the image data collected from the surface of the corrugated paper is specifically:
[0012] Collecting image data of corrugated paper surfaces of normal, different defect types and different background noise scenes from a corrugated paper production line under standardized lighting conditions, and labeling the collected image data according to defect types;
[0013] The preprocessing includes graying, filtering denoising, data enhancement and normalization.
[0014] As a preferred technical solution, the model is adapted by transfer learning to construct a corrugated paper defect detection model, specifically:
[0015] Part or all layers of the pre-trained deep learning model are frozen, that is, the parameters of these layers are not updated during training, specifically:
[0016] Let L be the total number of layers of the model, and n be the number of frozen layers, then:
[0017] W i (f) =W i (p) ,for~i=1,2,…,n;
[0018] Where, W i (f) represents the weight of the i-th layer in the frozen state, W i (p) represents the weight in the pre-training state;
[0019] One or more custom layers are added at the end of the model, the custom layers include fully connected layers, convolutional layers or classification layers, the parameters of the custom layers are updated during training, and the weight W (c) =trainable;
[0020] Define the loss function as follows:
[0021]
[0022] Where, is the cross-entropy loss function, y is the distribution of the true label, y i is the prediction of the i-th label, is the distribution predicted by the model;
[0023] Fine-tune the model, specifically: during transfer learning, not all pre-trained model layers are unfrozen at once for weight update, but the weight update ratio β of specific layers is gradually increased according to the training progress or time, then:
[0024] W i (t) =W i(f) + β · ΔW i (t) ;
[0025] wherein, W i (t) represents the weight of the i-th layer in the fine-tuning process, W i (f) is the initial pre-training weight, β is the weight update ratio adjusted over time or training progress, ΔW i (t) represents the update amount of the weight.
[0026] As a preferred technical solution, the corrugated paper defect detection model is trained and optimized using a data set, specifically:
[0027] The data set is divided into a training set, a validation set and a test set, wherein the training set is used for training the corrugated paper defect detection model, the validation set is used for fine-tuning the corrugated paper defect detection model and preventing overfitting, and the test set is used to evaluate the performance of the corrugated paper defect detection model;
[0028] A binary cross-entropy loss function is used, as follows:
[0029]
[0030] wherein, L BCE is the binary cross-entropy loss function, N is the number of samples in a batch, y i is the true label of the i-th sample, is the probability predicted by the corrugated paper defect detection model;
[0031] An Adam or SGD optimizer is used to adjust the model weights;
[0032] The hyperparameters of the corrugated paper defect detection model are adjusted on the validation set, including the learning rate, batch size and training round number;
[0033] The performance of the corrugated paper defect detection model is evaluated on the validation set using accuracy, recall and F1 score indicators, and the corrugated paper defect detection model is adjusted and optimized according to the evaluation results;
[0034] When the performance of the corrugated paper defect detection model on the validation set improves at a rate less than a set threshold in consecutive multiple training rounds, the training is stopped.
[0035] As a preferred technical solution, an explanation is generated for each prediction of the corrugated paper defect detection model and provided to the user, specifically:
[0036] Using the LIME algorithm, the corrugated paper defect detection model predicts the surrounding perturbed input data and learns the local model to explain the prediction, as follows, for each test sample:
[0037] mina∑ i∈S L(a,x′ i ,y i )+Ω(a);
[0038] where L(a,x′ i ,y i ) is the loss function between the local model and the SAM model prediction, a is the parameter of the local model, x′ i is the input sample in the perturbed data set, y i is the true label or target value corresponding to the input sample x′ i , S is the perturbed data set, and Ω is the regularization term for controlling the model complexity;
[0039] The LIME algorithm generates an explanation instance that highlights the key features in the original corrugated paper surface image data;
[0040] The generated explanation is integrated into the user interface;
[0041] The corrugated paper defect detection model is further trained and optimized using user feedback on the prediction and explanation of the corrugated paper defect detection model output.
[0042] As a preferred technical solution, the LIME algorithm generates an explanation instance that highlights the key features in the original corrugated paper surface image data using the gradient-weighted class activation mapping method, specifically:
[0043] Calculate the gradient of the target class y c with respect to the feature map A k of the model convolution layer, that is,
[0044] Perform global average pooling on the gradient to obtain the weight of each feature map
[0045]
[0046] where Z is the spatial dimension of the feature map;
[0047] Apply the weight to the feature map to generate a heat map indicating the region of interest of the model:
[0048]
[0049] As a preferred technical solution, the corrugated paper defect detection model is evaluated and iteratively optimized, specifically:
[0050] The cross-validation method is used to test the stability and generalization ability of the model. After each training cycle, the model is tested on the validation set, the indicators are calculated, and the parameters are adjusted according to the performance of the validation set. When the model reaches the best performance on the validation set, the test set is finally used to evaluate the model. The test set is not involved in training or validation, and is used to measure the real performance and generalization ability of the model.
[0051] The following iterative optimization strategies are used in the evaluation process:
[0052] Hyperparameter optimization: The hyperparameters of the model are optimized through grid search and random search;
[0053] Model pruning and distillation: Model pruning and knowledge distillation techniques are used to reduce the computational complexity of model inference. Through pruning technology, redundant neurons in the model are removed to reduce computational complexity. Through knowledge distillation, the knowledge of the model is transferred to a lightweight model, ensuring the inference speed while maintaining the detection accuracy.
[0054] Learning rate scheduling: During the training process of the model, the learning rate decay strategy is used. In the early stage of training, a larger learning rate is used to accelerate convergence. In the later stage of training, the learning rate is gradually reduced to avoid the model falling into local optimum.
[0055] Regularization techniques: Regularization terms are introduced in the training process to prevent overfitting of the model, including L2 regularization and Dropout. L2 regularization reduces model complexity by adding a weight term to the loss function. Dropout enhances the generalization ability of the model by randomly discarding neurons.
[0056] In a second aspect, the present application provides a corrugated paper defect detection system based on transfer learning and scene adaptive segmentation, which is applied to the corrugated paper defect detection method based on transfer learning and scene adaptive segmentation, and includes a data acquisition module, a model construction module, a model training module, a model interpretation module and an evaluation optimization module.
[0057] The data acquisition module is used to acquire corrugated paper surface image data and perform preprocessing to construct a data set.
[0058] The model construction module is used to select a pre-trained scene adaptive segmentation deep learning model, adapt it through transfer learning, and construct a corrugated paper defect detection model.
[0059] The model training module is used to train and optimize the corrugated paper defect detection model using the data set.
[0060] The model explanation module is configured to generate an explanation for each prediction of the corrugated paper defect detection model and provide the explanation to a user.
[0061] The evaluation optimization module is configured to evaluate and iteratively optimize the corrugated paper defect detection model.
[0062] In a third aspect, the present application provides an electronic device, which comprises:
[0063] at least one processor; and
[0064] a memory in communication with the at least one processor; wherein
[0065] The memory stores computer program instructions executable by the at least one processor, and the computer program instructions are executed by the at least one processor to enable the at least one processor to execute the corrugated paper defect detection method based on transfer learning and scene adaptive segmentation.
[0066] In a fourth aspect, the present application provides a computer readable storage medium storing a program, and the program is executed by a processor to implement the corrugated paper defect detection method based on transfer learning and scene adaptive segmentation.
[0067] Compared with the prior art, the present application has the following advantages and beneficial effects:
[0068] (1) The present application reduces the demand for labeled data by introducing a pre-trained adaptive cutting model (SAM), reduces the difficulty of data collection and processing, has the characteristics of less occupation of computing resources and fast detection speed, and meets the real-time detection needs of industrial production lines.
[0069] (2) The present application uses transfer learning technology to enable the model to quickly adapt to the corrugated paper defect detection task, and improves the accuracy and robustness of detection.
[0070] (3) The present application introduces multi-scale feature fusion and attention mechanism, enhances the detection ability of the model to small scale defects, and suppresses the interference of background noise. BRIEF DESCRIPTION OF DRAWINGS
[0071] Figure 1 is a flowchart of a corrugated paper defect detection method based on transfer learning and scene adaptive segmentation according to an embodiment of the present application;
[0072] Figure 2 is a flowchart of data preprocessing and enhancement according to an embodiment of the present application;
[0073] Figure 3 is a corrugated paper defect detection flowchart of a corrugated paper defect detection model according to an embodiment of the present application;
[0074] Figure 4 is a training and optimization flowchart of a corrugated paper defect detection model in the embodiment of the present application;
[0075] Figure 5 is a verification and evaluation flowchart of a corrugated paper defect detection model in the embodiment of the present application;
[0076] Figure 6 is a structural schematic diagram of a corrugated paper defect detection system based on transfer learning and scene adaptive segmentation in the embodiment of the present application;
[0077] Figure 7 is a structural schematic diagram of an electronic device in the embodiment of the present application. DETAILED DESCRIPTION
[0078] In order to enable persons skilled in the art to better understand the present application scheme, the technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by persons skilled in the art without creative labor are within the scope of protection of the present application.
[0079] EMBODIMENT
[0080] As shown in the figure, the present embodiment provides a corrugated paper defect detection method based on transfer learning and scene adaptive segmentation, comprising the following steps: Figure 1
[0081] S1, corrugated paper surface image data acquisition and preprocessing.
[0082] In the corrugated paper defect detection method, data preprocessing and enhancement are crucial steps, which directly affect the effect of model training and the final defect detection performance. The data preprocessing and enhancement process of the present embodiment is as follows:
[0083] Data collection: first, a large number of corrugated paper sample image data are collected from the production line. The data are collected by an industrial camera under standardized lighting conditions, covering images of multiple defect types, at least 5,000 images for each defect category, and at least 10,000 normal corrugated paper images. The collected images are subjected to preprocessing operations such as grayscale, denoising and size normalization, and data enhancement techniques (such as rotation, scaling, cropping, color transformation, etc.) are used to generate a diversified dataset to enhance the generalization ability of the model and its robustness in different production scenarios. These images should cover various types of defects, including but not limited to wrinkles, damage, foreign matter, etc.
[0084] Image preprocessing: The collected images are preprocessed, including grayscale, filter denoising and size normalization.
[0085] Specifically, the color image is converted to a grayscale image to reduce the computational complexity, which is expressed as:
[0086] I gray = 0.2989 * I red + 0.5870 * I green + 0.1140 * I blue ;
[0087] Then, standardization processing is performed, including adjusting image size, normalizing pixel values, etc. The image size is uniformly adjusted to H x W pixels to meet the model input requirements. The normalization processing formula is as follows:
[0088]
[0089] Data augmentation: In order to improve the generalization ability of the model and the adaptability to different defect types, the data augmentation technology is adopted in this embodiment. Common data augmentation methods include rotation, scaling, cropping, color transformation, etc. Through these methods, more variants can be generated from limited training samples, increasing the sample diversity of model training.
[0090] In a preferred embodiment, the following enhancement strategies are adopted:
[0091] Rotation: Randomly rotate the image ± 15°.
[0092] Scaling: Randomly scale the image to 90% to 110% of the original size.
[0093] Cropping: Randomly crop a region of H' x W' pixels from the image, where H' and W' are the height and width after cropping, respectively.
[0094] Color transformation: Randomly adjust the brightness, contrast and saturation of the image.
[0095] S2, selection and adaptation of transfer learning model.
[0096] To effectively detect the surface defects of corrugated paper, the embodiment selects a deep learning model based on transfer learning. Transfer learning can significantly reduce the demand for training data and improve the performance of the model on new tasks by transferring the knowledge of a pre-trained model to a new task. Specifically, the embodiment uses the Segment Anything Model (SAM) as the base model and optimizes the corrugated paper defect detection by combining transfer learning technology. The SAM model is a large-scale visual base model that can adapt to different image tasks. Its pre-trained weights contain rich visual features, which can provide strong support for subsequent corrugated paper surface defect detection.
[0097] S2.1, Model selection.
[0098] When selecting the model, the following transfer learning strategy is adopted:
[0099] Selection of pre-trained model: SAM model is adopted, which is based on Vision Transformer (ViT) architecture and has strong image understanding and segmentation capabilities.
[0100] Adaptability and generalization ability: Due to the small size of the corrugated paper defect dataset and the inclusion of different types of defects (such as scratches, holes, etc.), traditional convolutional neural network (CNN) models are prone to overfitting. Therefore, the SAM model can quickly adapt to small sample data and maintain good generalization performance under different backgrounds and defect types by introducing transfer learning strategies.
[0101] S2.2, Model adaptation
[0102] To adapt to the detection task of corrugated paper defects, the embodiment fine-tunes the SAM model to better meet the real-time detection needs of the industrial production line. The specific process is as follows:
[0103] (1) Fine-tuning of pre-trained model: The embodiment uses the image dataset of corrugated paper defects to fine-tune the image encoder and mask decoder of the SAM model. The image encoder is used to extract features from the input image, while the mask decoder generates accurate defect segmentation masks based on the input features.
[0104] (2) Multi-scale feature fusion: Since corrugated paper defects are often small in size and highly similar to the background, the embodiment introduces multi-scale feature fusion technology. Through the fusion of features of different scales, the model can more accurately identify small defects and reduce the interference of background noise.
[0105] (3) The introduction of attention mechanism: In order to further improve the detection ability of the model to small defects, the embodiment introduces an attention mechanism. The attention mechanism can help the model focus on the defect area in a complex background, and enhance the precision and robustness of detection.
[0106] S2.3, mathematical model and formula
[0107] In order to optimize the model, the embodiment adopts a hybrid loss function which combines binary cross-entropy loss (BCE) and Dice loss function. The mathematical expression is as follows:
[0108] L=L BCE +βL Dice ;
[0109] Wherein, L BCE is the binary cross-entropy loss, which is used to measure the classification accuracy of each pixel:
[0110]
[0111] And L Dice is the Dice loss function, which is used to measure the overlap between the predicted result and the real mask:
[0112]
[0113] Wherein, y n and represent the true value and the predicted value of the nth pixel respectively, N is the total number of pixels, and β is a balance coefficient for adjusting the weight of binary cross-entropy and Dice loss
[0114] Through the above transfer learning model selection and adaptation, the method of the present application can realize high-precision detection of corrugated paper surface defects and meet the needs of industrial real-time detection.
[0115] S3, training and optimization of corrugated paper defect detection model.
[0116] The corrugated paper defect detection method of the present application adopts a deep learning model based on transfer learning. In order to ensure that the model can obtain the best performance in the corrugated paper defect detection task, the training and optimization process is crucial. The following are the specific implementation steps and details:
[0117] (1) Model training process
[0118] During model training, this example first fine-tunes the pre-trained SegmentAnything Model (SAM) using corrugated paper defect images. The fine-tuning process primarily adjusts the model's weights to adapt it to the specific defect detection task. During this process, this example introduces the following key steps:
[0119] 1. Data partitioning: The corrugated paper defect dataset is divided into 80% training set, 10% validation set, and 10% test set. To ensure the robustness of the training, this example uses five-fold cross-validation to evaluate the performance of the model.
[0120] 2. Data Augmentation: To improve the model's generalization capabilities, this example uses a variety of data augmentation techniques, including random cropping, horizontal flipping, and color jittering. These operations help simulate the appearance changes of corrugated paper under different production conditions and enhance the model's robustness to defects in complex backgrounds.
[0121] 3. Use of Pretrained Weights: This example retains the weights of the SAM model, which were pretrained using a large amount of natural image data, particularly the weights of the image encoder. These pretrained weights enable the model to quickly learn the characteristics of corrugated paper defects, thereby shortening training time and improving the model's initial performance.
[0122] (2) Optimization algorithm
[0123] During the training process, this embodiment uses the Adam optimizer to accelerate the convergence of the model. Adam is an adaptive learning rate optimization algorithm based on first-order momentum and second-order momentum estimation. It can automatically adjust the learning rate to adapt to the update requirements of different parameters. Its update formula is as follows:
[0124] m t =β1m t-1 +(1-β1)g t ;
[0125]
[0126] Among them, g t is the gradient, m t and v t They represent the first-order and second-order momentum of the gradient, β1 and β2 are momentum decay coefficients, α is the learning rate, and ∈ is a very small number used to prevent division by zero errors.
[0127] By using the Adam optimizer, the model can converge at a faster speed and maintain high accuracy in the corrugated paper defect detection task.
[0128] (3) Learning rate setting
[0129] To further enhance the performance of the model, this embodiment adopts a learning rate decay strategy during training. Specifically, as the training round increases, the learning rate of the model gradually decreases, avoiding the overfitting phenomenon of the model in the later training. The update strategy of the learning rate is as follows:
[0130]
[0131] where αt represents the learning rate of the tth round, α0 is the initial learning rate, k is the decay coefficient, and t is the current training round.
[0132] (4) Model verification and evaluation
[0133] Model verification and evaluation is an important step to ensure its good performance in practical applications. After each training cycle, this embodiment uses the validation set to evaluate the performance of the model, and analyzes the precision, recall and F1 score of the model through cross-validation and confusion matrix. In particular, this embodiment uses Intersection over Union (IoU) as the main evaluation index, and its calculation formula is as follows:
[0134]
[0135] Through the above model training and optimization strategies, this embodiment can ensure the high precision, robustness and real-time performance of the model in the corrugated paper defect detection task, meeting the needs of industrial production lines.
[0136] S4, integrate the explainability module to perform defect detection.
[0137] In industrial applications, especially in tasks such as corrugated paper defect detection, the explainability of the model is crucial. A high-performance model not only needs to perform excellently in accuracy, but also needs to allow users to understand its decision-making process. Therefore, this embodiment integrates an explainability module into the corrugated paper defect detection model to improve the transparency of the model and help users understand the basis for the model's decision-making. This module is mainly implemented through technologies such as LIME (Local Interpretable Model-agnostic Explanations) and Grad-CAM.
[0138] S4.1, LIME (Local Interpretable Model-agnostic Explanations);
[0139] LIME is a general-purpose model-agnostic explanation method that can provide local explanations for any black-box model. By generating local perturbations of the model input, LIME analyzes the effect of these perturbations on the model output, thereby determining which features contribute most to the model's decision. In the present invention, LIME is used to explain the model's prediction results in the corrugated paper defect detection task, helping the operation and maintenance personnel understand why the model labeled a certain region as a defect.
[0140] The main steps of the LIME explanation process are as follows:
[0141] S4.1.1, perturbation generation: First, the present embodiment randomly generates multiple perturbation samples in the corrugated paper defect image. Each perturbation sample is a local modification of the original input image, which can be achieved by covering certain regions or changing local pixel values.
[0142] S4.1.2, local linear model training: Next, for each perturbation sample, the model is used to make a prediction and record the result. Then, LIME trains a simple linear model based on these perturbation samples to simulate the behavior of the original model.
[0143] S4.1.3, feature importance calculation: By analyzing the coefficients of the local linear model, LIME generates a set of feature importance values, which represent the image regions that the model pays most attention to in the prediction process.
[0144] Mathematically, the goal of LIME is to find a local explanation model g(x) that approximates the original complex model f(x) through the following optimization problem:
[0145]
[0146] where: is the difference between the model f and the local explanation model g, π x is the weight function, which represents the similarity between the perturbation sample and the original input sample, and Ω(g) is the complexity constraint on the explanation model, ensuring that the explanation model is simple enough.
[0147] S4.2, Grad-CAM (Gradient-weighted Class Activation Mapping).
[0148] To further improve the model's explainability, the present embodiment adopts the Grad-CAM technique. Grad-CAM is a visualization method that generates a heat map by calculating the gradient of a certain class with respect to the convolutional layer feature map, showing the image regions that the model pays most attention to when making a certain classification decision.
[0149] The main steps of Grad-CAM are as follows:
[0150] S4.2.1, Gradient calculation: First, the target class y is calculated by backpropagation c the gradient of the model's convolutional layer feature map A k , that is, These gradients reflect the importance of each feature map to the target class.
[0151] S4.2.2, weight calculation: Then, these gradients are globally averaged and pooled to obtain the weight of each feature map
[0152] where Z is the spatial dimension of the feature map.
[0153] S4.2.3, generate heat map: Finally, apply these weights to the feature map to generate a heat map represent the area of interest of the model:
[0154]
[0155] This heat map can visually show the area that the model pays most attention to when detecting corrugated paper defects, helping users understand the working principle of the model.
[0156] S4.3, model transparency and decision basis.
[0157] By integrating LIME and Grad-CAM technology, the corrugated paper defect detection model in this invention not only provides accurate defect detection results, but also generates explanatory reports for each decision, showing which areas in the image are the key factors that lead to the defect judgment. These explanatory reports can help operations personnel better understand the behavior of the model, reduce unnecessary manual inspection, and improve the efficiency of the entire production process.
[0158] In addition, the integrated explainability module can be integrated with the quality management system of the production line, so that users can timely find errors and abnormalities that may occur in the detection process, thereby more effectively optimizing the corrugated paper production process.
[0159] S4.4, computing resources and real-time performance.
[0160] The method of the invention not only considers the accuracy and transparency of the model, but also optimizes the use of computing resources. By using lightweight Grad-CAM implementation in the inference process, the explainability module can generate explanation reports without significantly increasing the computing cost, ensuring that the corrugated paper defect detection can be performed in real time, meeting the needs of industrial production lines.
[0161] S5, evaluation and iterative optimization of defect detection model.
[0162] The evaluation and optimization of the model are key steps to ensure the stability of the corrugated paper defect detection system in industrial production. The method of the present invention ensures the robustness, accuracy, and response speed of the model in actual application scenarios through a multi-stage evaluation strategy and continuous iterative optimization.
[0163] (1) Model verification and testing
[0164] During the model evaluation process, the present embodiment uses cross-validation to test the stability and generalization ability of the model.
[0165] The specific steps are as follows:
[0166] Data set division: The data set is divided into training set, validation set and test set, which are used for model training, parameter tuning and final performance evaluation. The present embodiment uses five-fold cross-validation to ensure the stability of the model under different data division.
[0167] Validation set evaluation: After each training cycle, the model will be tested on the validation set, calculate various indicators, and adjust the parameters (such as learning rate adjustment, regularization strategy optimization, etc.) according to the performance of the validation set.
[0168] Test set evaluation: When the model reaches the best performance on the validation set, the test set is finally used to evaluate the model. The test set does not participate in training or validation, and is used to measure the real performance and generalization ability of the model.
[0169] (2) Iterative optimization strategy
[0170] In order to further improve the performance of the model, the present embodiment uses the following iterative optimization strategy in the evaluation process:
[0171] Hyperparameter optimization: Through grid search and random search, the hyperparameters of the model (such as learning rate, regularization coefficient, batch size, etc.) are optimized. The present embodiment conducts multiple experiments on the validation set to find the optimal combination of hyperparameters.
[0172] Model pruning and distillation: In order to reduce the computational complexity of the model during inference, the present embodiment uses model pruning and knowledge distillation technology. Through pruning technology, the present embodiment removes redundant neurons in the model, thereby reducing computational complexity. Through knowledge distillation, the present embodiment transfers the knowledge of large models to lightweight models, ensuring the inference speed while maintaining detection accuracy.
[0173] Learning rate scheduling: During the model training process, the present embodiment uses learning rate decay strategy. In the early stage of training, a larger learning rate is used to accelerate convergence; in the later stage of training, the learning rate is gradually reduced to avoid the model falling into local optimum.
[0174] Regularization techniques: To prevent overfitting, the embodiment introduces regularization terms during training, including L2 regularization and Dropout. L2 regularization reduces model complexity by adding a weight term to the loss function; Dropout enhances the model's generalization ability by randomly dropping neurons.
[0175] (3) Error analysis and continuous improvement
[0176] After each model evaluation, the embodiment analyzes the model's error classification results in detail. By analyzing the reasons for error classification, the embodiment can identify the model's weaknesses and make targeted improvements. Specifically, error analysis mainly includes the following aspects:
[0177] Class imbalance: If some types of defects have fewer samples in the dataset, the model is prone to misclassification. To this end, the embodiment introduces a class balance sampling strategy and increases the number of samples in the minority class through data augmentation techniques.
[0178] Background noise: In some complex production environments, the background noise of corrugated paper is large, which may interfere with the model's detection results. The embodiment uses background suppression techniques to increase background and noise samples to train the model, enabling it to distinguish between defects and background noise.
[0179] Small-scale defect detection: Since corrugated paper defects are sometimes very small, the model may perform poorly in detecting these small-scale defects. To this end, the embodiment introduces a multi-scale feature fusion mechanism to enhance the model's ability to detect defects of different scales.
[0180] (4) Performance testing in industrial production
[0181] To verify the effectiveness of the method in actual production environments, the embodiment tests the model on an actual corrugated paper production line. By collecting images of corrugated paper at different production stages, it simulates various environmental changes (such as light changes, background complexity, etc.) during production to test the model's robustness and real-time performance.
[0182] Through the above model evaluation and iterative optimization strategies, the method can achieve high precision, low false positive rate, and fast reasoning in the task of corrugated paper defect detection, and meet the actual needs of industrial production lines.
[0183] It should be noted that for the foregoing method embodiments, in order to simplify the description, they are all described as a series of action combinations, but those skilled in the art should know that the present application is not limited by the order of the described actions, because according to the present application, certain steps can be performed in other orders or simultaneously.
[0184] Based on the same idea as the corrugated paper defect detection method based on transfer learning and scene adaptive segmentation in the above embodiment, the application also provides a corrugated paper defect detection system based on transfer learning and scene adaptive segmentation, which can be used to execute the corrugated paper defect detection method based on transfer learning and scene adaptive segmentation described above. For the convenience of description, in the structural schematic diagram of the corrugated paper defect detection system based on transfer learning and scene adaptive segmentation embodiment, only the parts related to the embodiments of the application are shown, and those skilled in the art can understand that the illustrated structure does not constitute a limitation on the device, which can include more or fewer components than the illustrated, or combine certain components, or different component arrangements.
[0185] As Figure 6 shown, in another embodiment of the present application, a corrugated paper defect detection system 100 based on transfer learning and scene adaptive segmentation is provided, which includes a data acquisition module 101, a model construction module 102, a model training module 103, a model interpretation module 104 and an evaluation optimization module 105.
[0186] The data acquisition module 101 is used to acquire and preprocess the corrugated paper surface image data and construct a data set.
[0187] The model construction module 102 is used to select a pre-trained scene adaptive segmentation deep learning model, adapt it through transfer learning, and construct a corrugated paper defect detection model.
[0188] The model training module 103 is used to train and optimize the corrugated paper defect detection model using the data set.
[0189] The model interpretation module 104 is used to generate an explanation for each prediction of the corrugated paper defect detection model and provide it to the user.
[0190] The evaluation optimization module 105 is used to evaluate and iteratively optimize the corrugated paper defect detection model.
[0191] It should be noted that the system provided in the above embodiments is only exemplified by the division of the above functional modules, and in actual application, the above functions can be completed by different functional modules according to needs, i.e. the internal structure is divided into different functional modules to complete all or part of the functions described above. The system is a corrugated paper defect detection method based on transfer learning and scene adaptive segmentation applied to the above embodiments.
[0192] It should be noted that the corrugated paper defect detection system based on the migration learning and scene adaptive segmentation of the present application corresponds to the corrugated paper defect detection method based on the migration learning and scene adaptive segmentation of the present application, the technical features and advantages described in the above embodiment of the corrugated paper defect detection method based on the migration learning and scene adaptive segmentation are applicable to the embodiment of the corrugated paper defect detection based on the migration learning and scene adaptive segmentation, and the specific content can be referred to the description in the method embodiment of the present application, which will not be described here again, and hereby declared.
[0193] In addition, in the embodiment of the corrugated paper defect detection system based on the migration learning and scene adaptive segmentation of the above embodiment, the logical division of each program module is only illustrative, and in actual application, the above function allocation can be completed by different program modules according to needs, for example, the configuration requirements of the corresponding hardware or the convenience of software implementation, that is, the internal structure of the corrugated paper defect detection system based on the migration learning and scene adaptive segmentation is divided into different program modules to complete all or part of the functions described above.
[0194] Please refer to Figure 7 In one embodiment, an electronic device implementing the corrugated paper defect detection method based on the migration learning and scene adaptive segmentation is provided, and the electronic device 200 can include a first processor 201, a first memory 202 and a bus, and can further include a computer program stored in the first memory 202 and executable on the first processor 201, such as a corrugated paper defect detection program 203 based on the migration learning and scene adaptive segmentation.
[0195] The first memory 202 includes at least one type of readable storage medium, including flash memory, mobile hard disk, multimedia card, card-type memory (such as SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. The first memory 202 can be an internal storage unit of the electronic device 200 in some embodiments, such as the mobile hard disk of the electronic device 200. The first memory 202 can also be an external storage device of the electronic device 200 in other embodiments, such as the plug-in mobile hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. equipped on the electronic device 200. Further, the first memory 202 can include both the internal storage unit and the external storage device of the electronic device 200. The first memory 202 can be used not only to store application software and various data installed on the electronic device 200, such as the code of the corrugated paper defect detection program 203 based on the migration learning and scene adaptive segmentation, but also to temporarily store data that has been output or will be output.
[0196] The first processor 201 may, in some embodiments, be composed of integrated circuits, for example, may be composed of a single packaged integrated circuit, or may be composed of multiple packaged integrated circuits of the same function or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips, etc. The first processor 201 is the control unit of the electronic device, which connects various components of the entire electronic device through various interfaces and lines, and executes various functions and processes data of the electronic device 200 by running or executing programs or modules stored in the first memory 202 and calling data stored in the first memory 202.
[0197] Figure 7 Only the electronic device with components is shown, and those skilled in the art can understand that, Figure 3 The structure shown does not constitute a limitation on the electronic device 200, and can include fewer or more components than shown, or combine certain components, or different component arrangements.
[0198] The corrugated paper defect detection program 203 based on transfer learning and scene adaptive segmentation stored in the first memory 202 in the electronic device 200 is a combination of multiple instructions, which, when running in the first processor 201, can achieve:
[0199] Collecting corrugated paper surface image data and preprocessing to construct a data set;
[0200] Selecting a pre-trained scene adaptive segmentation deep learning model, adapting through transfer learning, and constructing a corrugated paper defect detection model;
[0201] Training and optimizing the corrugated paper defect detection model using the data set;
[0202] Generating an explanation for each prediction of the corrugated paper defect detection model and providing it to the user;
[0203] Evaluating and iteratively optimizing the corrugated paper defect detection model.
[0204] Further, the modules / units of the electronic device 200, if implemented in the form of software function units and sold or used as independent products, can be stored in a non-volatile computer readable storage medium. The computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM).
[0205] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The program can be stored in a non-volatile computer readable storage medium, and when the program is executed, the processes of the above-mentioned embodiment methods can be included. Any reference to memory, storage, database or other medium used in the embodiments provided in the present 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. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), 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), etc.
[0206] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist, it should be considered as the scope of the present application.
[0207] The above embodiments are the preferred embodiments of the present application, but the embodiments of the present application are not limited by the above embodiments, and any changes, modifications, substitutions, combinations and simplifications made without departing from the spirit and principles of the present application shall be equivalent replacement methods and shall be within the scope of protection of the present application.
Claims
1. A corrugated paper defect detection method based on transfer learning and scene adaptive segmentation, characterized in that: The steps include: Collect and preprocess the image data of the corrugated paper surface to construct a data set; A pre-trained scene-adaptive segmentation deep learning model was selected and adapted through transfer learning to build a corrugated paper defect detection model. Use the dataset to train and optimize the corrugated paper defect detection model; Generate explanations for each prediction of the corrugated cardboard defect detection model and provide them to the user; Evaluate and iteratively optimize the corrugated paper defect detection model; The collecting of image data of the corrugated paper surface is specifically as follows: Collect image data of normal corrugated paper surfaces, different defect types, and different background noise scenes from a corrugated paper production line under standardized lighting conditions, and annotate the collected image data according to defect type; The preprocessing includes grayscale, filtering and denoising, data enhancement and normalization; The adaptation through transfer learning is used to build a corrugated paper defect detection model, specifically: Freeze some or all layers of the pre-trained deep learning model, that is, do not update the parameters of these layers during training. Specifically: Let L be the total number of layers of the model and n be the number of frozen layers, then: ; in, represents the weight of the i-th layer in the frozen state, Represents the weight in the pre-training state; Add one or more custom layers at the end of the model, including fully connected layers, convolutional layers, or classification layers. The parameters of the custom layers are updated during the training process, and the weights of the custom layers are updated. ; Define the loss function as follows: ; in, is the cross entropy loss function, y is the distribution of true labels, represents the prediction of the i-th label, is the distribution predicted by the model; Fine-tuning the model: In the process of transfer learning, instead of unfreezing all the layers of the pre-trained model at once to update the weights, the weight update ratio β of a specific layer is gradually increased according to the training progress or time. ; in, Indicates the i The weights of the layers during fine-tuning, is the initial pre-training weight, β is the weight update ratio adjusted over time or training progress, Indicates the update amount of the weight; The method of using the data set to train and optimize the corrugated paper defect detection model is as follows: Dividing the dataset into a training set, a validation set, and a test set, wherein the training set is used for training the corrugated paper defect detection model, the validation set is used for tuning the corrugated paper defect detection model and preventing overfitting, and the test set is used for evaluating the performance of the corrugated paper defect detection model; The binary cross entropy loss function is used as follows: ; in, is the binary cross entropy loss function, N is the number of samples in the batch, It is i The true labels of samples, is the probability predicted by the corrugated paper defect detection model; Use Adam or SGD optimizer to adjust model weights; Adjusting the hyperparameters of the corrugated paper defect detection model on the validation set, including the learning rate, batch size, and number of training rounds; Use the accuracy, recall, and F1 score metrics on the validation set to evaluate the performance of the corrugated paper defect detection model, and adjust and optimize the model based on the evaluation results. When the performance improvement rate of the corrugated paper defect detection model on the validation set in multiple consecutive training rounds is less than the set threshold, training is stopped; The explanation for each prediction of the corrugated paper defect detection model is generated and provided to the user, specifically: Using the LIME algorithm, we perturb the input data around the corrugated paper defect detection model prediction and learn a local model to explain the prediction, as shown below for each test sample: ; in, is the loss function between the local model and the SAM model prediction, a are the parameters of the local model, is the input sample in the perturbation dataset, corresponds to the input sample The true label or target value, S is the perturbation dataset, Ω is the regularization term used to control the complexity of the model; The explanation examples generated by the LIME algorithm are used to highlight key features on the original corrugated paper surface image data; Integrate the generated explanations into the user interface; Leverage user feedback on predictions and interpretations of the corrugated paper defect detection model output to further train and optimize the corrugated paper defect detection model; The gradient-weighted class activation mapping method is used to generate explanation examples using the LIME algorithm to highlight key features in the original corrugated paper surface image data, specifically: Calculate the target category through backpropagation Relative to the model convolutional layer feature map The gradient of ; Perform global average pooling on the gradient to obtain the weight of each feature map : ; in, Z is the spatial dimension of the feature map; Apply the weights to the feature map to generate a heat map , indicating the area of interest of the model: 。 2. The method for detecting corrugated paper defects based on transfer learning and scene adaptive segmentation according to claim 1, characterized in that: The evaluation and iterative optimization of the corrugated paper defect detection model are specifically as follows: Cross-validation is used to test the stability and generalization ability of the model. After each training cycle, the model is tested on the validation set, various indicators are calculated, and parameters are adjusted based on the performance of the validation set. When the model achieves optimal performance on the validation set, the test set is used to evaluate the model. The test set is not used in training or validation and is used to measure the actual performance and generalization ability of the model. The following iterative optimization strategies were used during the evaluation process: Hyperparameter optimization: Optimize the model's hyperparameters through grid search and random search; Model pruning and distillation: Model pruning and knowledge distillation techniques are used to reduce the computational complexity during model inference. Pruning removes redundant neurons in the model to reduce computational complexity. Knowledge distillation transfers the knowledge of the model to a lightweight model, ensuring inference speed while maintaining detection accuracy. Learning rate scheduling: During model training, a learning rate decay strategy is adopted. In the early stages of training, a larger learning rate is used to accelerate convergence; in the later stages of training, the learning rate is gradually reduced to prevent the model from falling into a local optimum. Regularization technology: Regularization terms are introduced during the training process to prevent model overfitting, including L2 regularization and Dropout. L2 regularization reduces model complexity by increasing the weight term of the loss function; Dropout enhances the generalization ability of the model by randomly discarding neurons.
3. Corrugated paper defect detection system based on transfer learning and scene adaptive segmentation, characterized by: A corrugated paper defect detection method based on transfer learning and scene adaptive segmentation applied to any one of claims 1-2, comprising a data acquisition module, a model construction module, a model training module, a model interpretation module, and an evaluation and optimization module; The data acquisition module is used to collect and pre-process the image data of the corrugated paper surface to construct a data set; The model building module is used to select a pre-trained scene adaptive segmentation deep learning model, adapt it through transfer learning, and build a corrugated paper defect detection model; The model training module is used to train and optimize the corrugated paper defect detection model using the data set; The model explanation module is used to generate an explanation for each prediction of the corrugated paper defect detection model and provide it to the user; The evaluation and optimization module is used to evaluate and iteratively optimize the corrugated paper defect detection model.
4. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores computer program instructions that can be executed by the at least one processor, and the computer program instructions are executed by the at least one processor so that the at least one processor can execute the corrugated paper defect detection method based on transfer learning and scene adaptive segmentation as described in any one of claims 1-2.
5. A computer-readable storage medium storing a program, characterized in that: When the program is executed by a processor, the corrugated paper defect detection method based on transfer learning and scene adaptive segmentation described in any one of claims 1-2 is implemented.
Citation Information
Patent Citations
Metal plate surface defect detection method
CN115587998A
Corrugated carton defect detection acceleration method, system and equipment based on parallel computing and storage medium
CN115810005A