Corrugated paper defect detection method based on transfer learning and scene adaptive segmentation
Through transfer learning and scene adaptive segmentation methods, the pre-trained model and multi-scale feature fusion are used to solve the problem of large and small defect detection in corrugated defect detection, and efficient, accurate and real-time defect detection is achieved, and the interpretability of the model is provided.
Patent Information
- Application Number
- CN202510223183.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-27
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2045-02-27
AI Technical Summary
The existing corrugated paper defect detection method based on convolutional neural networks requires a large amount of labeled data, and has poor performance when detecting small-scale defects, which is prone to background noise interference, making it difficult to meet the real-time detection requirements of industrial production lines.
Using transfer learning and scene adaptive segmentation methods, pre-trained deep learning models such as Segment Anything Model (SAM), combined with multi-scale feature fusion and attention mechanism, adapting corrugated defect detection models through transfer learning, and introducing interpretability modules such as LIME and Grad-CAM to optimize model performance and transparency.
It reduces the need for labeled data, improves the accuracy and robustness of detection, enhances the detection ability of small-scale defects, reduces the use of computing resources, meets the real-time detection needs of industrial production lines, and provides interpretability of model decisions.
Smart Images

Figure CN120339162A_ABST
Abstract
Description
Technical Field
[0001] The present invention 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 Art
[0002] During the production and packaging process of corrugated paper, various defects may appear on the surface, such as scratches, holes, stains, etc. These defects not only affect the appearance of corrugated paper but may also cause damage to the packaged products. Traditional corrugated paper defect detection methods mostly 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 technologies, it has become possible to detect corrugated paper surface defects using automated detection technologies. However, corrugated paper defect detection still faces multiple challenges, including small defect sizes, diverse types, and high similarity to the background. Existing object detection methods based on convolutional neural networks (CNNs) have made significant progress in the fields of 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, and it is difficult to obtain corrugated paper defect data. In addition, traditional CNN models perform poorly in detecting small-scale defects and are easily interfered by background noise. Summary of the Invention
[0003] The main purpose of the present invention is to overcome the disadvantages and deficiencies of the prior art, and provide a corrugated paper defect detection method based on transfer learning and scene adaptive segmentation.
[0004] To achieve the above object, the present invention adopts the following technical solutions:
[0005] In a first aspect, the present invention provides a corrugated paper defect detection method based on transfer learning and scene adaptive segmentation, including the following steps:
[0006] Collect surface image data of corrugated paper and perform preprocessing to construct a data set;
[0007] Select a pre-trained deep learning model for scene adaptive segmentation, and adapt it through transfer learning to construct a corrugated paper defect detection model;
[0008] Use the data set to train and optimize the corrugated paper defect detection model;
[0009] Generate an explanation for each prediction of the corrugated paper defect detection model and provide it to the user;
[0010] Evaluate and iteratively optimize the corrugated paper defect detection model.
[0011] As a preferred technical solution, the collection of the image data on the surface of the corrugated paper is specifically:
[0012] Collect image data of the corrugated paper surface under normal, different defect types and different background noise scenarios from the corrugated paper production line under standardized lighting conditions, and label the collected image data according to the defect types;
[0013] The preprocessing includes grayscale conversion, filtering and denoising, data augmentation, and normalization.
[0014] As a preferred technical solution, the adaptation is performed through transfer learning to construct a corrugated paper defect detection model, specifically:
[0015] 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:
[0016] Let L be the total number of layers of the model and n be the number of frozen layers, then there is:
[0017] W i (f) =W i (p) , for ~i = 1, 2,..., n;
[0018] Among them, W i (f) represents the weight of the i-th layer in the frozen state, and W i (p) represents the weight in the pre-trained state;
[0019] Add one or more custom layers 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, specifically as follows:
[0021]
[0022] Among them, is the cross-entropy loss function, y is the distribution of the true labels, and y i represents the prediction of the i-th label, is the distribution predicted by the model;
[0023] Fine-tune the model, specifically: During the transfer learning process, not all layers of the pre-trained model are unfrozen for weight update at once, but the weight update ratio β of specific layers is gradually increased according to the training progress or time. Then there is:
[0024] W i (t) =W i(f) +β·ΔW i (t) ;
[0025] Wherein, W i (t) represents the weight of the i-th layer during the fine-tuning process, and W i (f) is the initial pre-trained weight, β is the weight update ratio adjusted with time or training progress, and ΔW i (t) represents the weight update amount.
[0026] As a preferred technical solution, the method for training and optimizing the corrugated paper defect detection model by using the data set is specifically as follows:
[0027] Divide the data set into a training set, a validation set, and a test set. Among them, 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;
[0028] Adopt the binary cross-entropy loss function, as shown in the following formula:
[0029]
[0030] Wherein, L BCE is the binary cross-entropy loss function, N is the number of samples in the batch, y i is the true label of the i-th sample, is the probability predicted by the corrugated paper defect detection model;
[0031] Adopt an Adam or SGD optimizer to adjust the model weights;
[0032] Adjust the hyperparameters of the corrugated paper defect detection model on the validation set. The hyperparameters include the learning rate, batch size, and number of training epochs;
[0033] Evaluate the performance of the corrugated paper defect detection model on the validation set using accuracy, recall, and F1-score metrics, and adjust and optimize the corrugated paper defect detection model according to the evaluation results;
[0034] When the improvement rate of the performance of the corrugated paper defect detection model on the validation set is less than the set threshold in consecutive multiple training epochs, stop training.
[0035] As a preferred technical solution, generate an explanation for each prediction of the corrugated paper defect detection model and provide it to the user, specifically as follows:
[0036] Using the LIME algorithm, around the prediction of the corrugated paper defect detection model, the input data is perturbed and the local model is learned to explain the prediction. As shown in the following formula, 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 perturbation dataset, y i is the true label or target value corresponding to the input sample x′ i , S is the perturbation dataset, and Ω is the regularization term used to control the model complexity;
[0039] Highlight the key features of the interpretation instances generated by the LIME algorithm in the original corrugated paper surface image data;
[0040] Integrate the generated interpretation into the user interface;
[0041] Use the feedback from the user on the prediction and interpretation of the output of the corrugated paper defect detection model to further train and optimize the corrugated paper defect detection model.
[0042] As a preferred technical solution, use the gradient-weighted class activation mapping method to highlight the key features of the interpretation instances generated by the LIME algorithm in the original corrugated paper surface image data. Specifically:
[0043] Calculate the gradient of the target class y c with respect to the feature map A k of the model convolutional layer through backpropagation, 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 representing the area of interest of the model:
[0048]
[0049] As a preferred technical solution, the evaluation and iterative optimization of the corrugated paper defect detection model are specifically as follows:
[0050] The cross-validation method is adopted to test the stability and generalization ability of the model. After each training cycle, the model will be tested on the validation set, various metrics will be calculated, and parameter adjustment will be performed according to the performance on the validation set; when the model reaches the best performance on the validation set, the test set will finally be used to evaluate the model; the test set is not involved in training or validation and is used to measure the true performance and generalization ability of the model;
[0051] The following iterative optimization strategies are adopted during the evaluation process:
[0052] Hyperparameter optimization: The hyperparameters of the model are optimized through two methods: grid search and random search;
[0053] Model pruning and distillation: Model pruning and knowledge distillation techniques are adopted to reduce the computational amount during model inference; through the pruning technique, redundant neurons in the model are removed to reduce the computational complexity; through knowledge distillation, the knowledge of the large model is transferred to the lightweight model to ensure the inference speed while maintaining the detection accuracy;
[0054] Learning rate scheduling: During the model training process, a learning rate decay strategy is adopted. In the early stage of training, a larger learning rate is adopted 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 during training to prevent the model from overfitting, including L2 regularization and Dropout; L2 regularization reduces the 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 the second aspect, the present invention 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 and optimization module;
[0057] The data acquisition module is used to collect the surface image data of the corrugated paper and perform preprocessing to construct a data set;
[0058] The model construction module is used to select a pre-trained deep learning model for scene adaptive segmentation and adapt it through transfer learning to construct a corrugated paper defect detection model;
[0059] The model training module is used to train and optimize the corrugated paper defect detection model by using the data set;
[0060] The model interpretation module is used to generate interpretations for each prediction of the corrugated paper defect detection model and provide them to the user;
[0061] The evaluation and optimization module is used to evaluate and iteratively optimize the corrugated paper defect detection model.
[0062] In a third aspect, the present invention provides an electronic device, which includes:
[0063] At least one processor; and,
[0064] A memory communicatively connected to 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 so that the at least one processor can execute the corrugated paper defect detection method based on transfer learning and scene adaptive segmentation.
[0066] In a fourth aspect, the present invention provides a computer-readable storage medium storing a program, which when executed by a processor, implements the corrugated paper defect detection method based on transfer learning and scene adaptive segmentation.
[0067] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0068] (1) By introducing a pre-trained adaptive cutting model (SAM), the present invention reduces the need for labeled data, reduces the difficulty of data collection and processing, has the characteristics of less computing resource occupation and fast detection speed, and meets the real-time detection requirements of industrial production lines.
[0069] (2) Through transfer learning technology, the present invention enables the model to quickly adapt to the corrugated paper defect detection task, improving the accuracy and robustness of detection.
[0070] (3) The present invention introduces multi-scale feature fusion and attention mechanism, enhancing the model's detection ability for small-scale defects and suppressing the interference of background noise. Description of the 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 invention;
[0072] Figure 2 is a flowchart of data preprocessing and enhancement in an embodiment of the present invention;
[0073] Figure 3 is a flowchart of corrugated paper defect detection of a corrugated paper defect detection model in an embodiment of the present invention;
[0074] Figure 4 It is a flowchart for training and optimizing the corrugated paper defect detection model in the embodiments of the present invention;
[0075] Figure 5 It is a flowchart for validating and evaluating the corrugated paper defect detection model in the embodiments of the present invention;
[0076] Figure 6 It is a schematic structural diagram of a corrugated paper defect detection system based on transfer learning and scene adaptive segmentation in the embodiments of the present invention;
[0077] Figure 7 It is a schematic structural diagram of an electronic device in the embodiments of the present invention. Detailed implementation manners
[0078] In order to enable those skilled in the art of the present technology to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present application.
[0079] Embodiment
[0080] As Figure 1 shown, this embodiment provides a corrugated paper defect detection method based on transfer learning and scene adaptive segmentation, including the following steps:
[0081] S1. Acquisition and preprocessing of corrugated paper surface image data.
[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 in this 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 various defect types. At least 5,000 images are collected for each defect category, and at least 10,000 normal corrugated paper images are collected. The collected images are subjected to preprocessing operations such as grayscale conversion, denoising, and size normalization, and data enhancement techniques (such as rotation, scaling, cropping, color transformation, etc.) are used to generate a diverse 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, breaks, foreign objects, etc.
[0084] Image preprocessing: Preprocess the collected images, including grayscale conversion, filtering for noise reduction, and size normalization.
[0085] Specifically, convert the color image to a grayscale image to reduce computational complexity, which is expressed by the formula:
[0086] I gray = 0.2989×I red + 0.5870×I green + 0.1140×I blue ;
[0087] Then perform normalization processing, including resizing the image, normalizing pixel values, etc. The image size is uniformly adjusted to H×W pixels to meet the input requirements of the model. The normalization processing formula is as follows:
[0088]
[0089] Data augmentation: To improve the generalization ability of the model and its adaptability to different defect types, this embodiment adopts data augmentation technology. 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 implementation manner, the following augmentation strategy is adopted:
[0091] Rotation: Randomly rotate the image by ±15°.
[0092] Scaling: Randomly scale the image to 90% to 110% of the original size.
[0093] Cropping: Randomly crop an area of H′×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 the transfer learning model.
[0096] To effectively detect surface defects of corrugated paper, a deep learning model based on transfer learning is selected in this embodiment. Transfer learning can significantly reduce the need for training data and improve the performance of the model on new tasks by transferring the knowledge of pre-trained models to new tasks. Specifically, in this embodiment, the Segment Anything Model (SAM) is adopted as the base model, and transfer learning technology is combined to optimize the corrugated paper defect detection. The SAM model is a large-scale visual foundation model that can adapt to different image tasks. Its pre-trained weights contain rich visual features, which can provide strong support for subsequent surface defect detection of corrugated paper.
[0097] S2.1. Model selection.
[0098] When selecting the model, the following transfer learning strategy is adopted:
[0099] Selection of pre-trained model: The SAM model is adopted. It is based on the Vision Transformer (ViT) architecture and has strong image understanding and segmentation capabilities.
[0100] Adaptability and generalization ability: Since the corrugated paper defect dataset is small and contains different types of defects (such as scratches, holes, etc.), traditional convolutional neural network (CNN) models are prone to overfitting. Therefore, by introducing a transfer learning strategy, the SAM model can quickly adapt to small-sample data and still maintain good generalization performance under different backgrounds and defect types.
[0101] S2.2. Model adaptation
[0102] To adapt to the detection task of corrugated paper defects, this embodiment fine-tunes the SAM model to make it more suitable for the real-time detection requirements on industrial production lines. The specific process is as follows:
[0103] (1) Fine-tuning of the pre-trained model: In this embodiment, an image dataset of corrugated paper defects is used 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, this embodiment introduces multi-scale feature fusion technology. By fusing features at different scales, the model can more accurately identify small defects and reduce the interference of background noise.
[0105] (3) Introduction of the attention mechanism: To further improve the model's ability to detect small defects, this embodiment introduces an attention mechanism. The attention mechanism can help the model focus on the defect area in a complex background, enhancing the detection accuracy and robustness.
[0106] S2.3, Mathematical models and formulas
[0107] To optimize the model, this embodiment uses a hybrid loss function that combines the Binary Cross-Entropy (BCE) and the Dice loss function. Its mathematical expression is:
[0108] L = L BCE + βL Dice ;
[0109] where L BCE is the binary cross-entropy loss, which is used to measure the classification accuracy of each pixel:
[0110]
[0111] while L Dice is the Dice loss function, which is used to measure the overlap between the prediction result and the true mask:
[0112]
[0113] where y n and respectively represent the true value and the predicted value of the nth pixel, N is the total number of pixels, and β is a balancing coefficient used to adjust the weights of the binary cross-entropy and the Dice loss
[0114] Through the above selection and adaptation of the transfer learning model, the method of the present invention can achieve high-precision detection of the surface defects of corrugated paper and meet the requirements of industrial real-time detection.
[0115] S3. Training and optimization of the corrugated paper defect detection model.
[0116] The corrugated paper defect detection method of the present invention uses a deep learning model based on transfer learning. 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 the model training process, in this embodiment, the pre-trained SegmentAnything Model (SAM) is first fine-tuned using corrugated paper defect images. The fine-tuning process mainly adjusts the weights of the model to make it adapt to specific defect detection tasks. During this process, the following key steps are introduced in this embodiment:
[0119] 1. Data partitioning: The corrugated paper defect dataset is partitioned according to the ratio of 80% training set, 10% validation set, and 10% test set. To ensure the robustness of training, this embodiment uses five-fold cross-validation to evaluate the performance of the model.
[0120] 2. Data augmentation: To increase the generalization ability of the model, this embodiment adopts a variety of data augmentation techniques, including random cropping, horizontal flipping, color jittering, etc. These operations help to simulate the appearance changes of corrugated paper under different production conditions and enhance the robustness of the model to defects in complex backgrounds.
[0121] 3. Use of pre-trained weights: This embodiment retains the weights pre-trained by a large amount of natural image data in the SAM model, especially the weights of the image encoder. Through these pre-trained weights, the model can quickly learn the features of corrugated paper defects, thereby shortening the training time and improving the initial performance of the model.
[0122] (2) Optimization algorithm
[0123] During the training process, this embodiment uses the Adam optimizer to accelerate the convergence speed of the model. Adam is an adaptive learning rate optimization algorithm based on the estimation of first-order momentum and second-order momentum, which 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] where g t is the gradient, m t and v t represent the first-order and second-order momentum of the gradient respectively, β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 relatively fast speed in the corrugated paper defect detection task and maintain a high accuracy.
[0128] (3) Learning rate setting
[0129] To further improve the performance of the model, a learning rate decay strategy is adopted during the training process in this embodiment. Specifically, as the number of training rounds increases, the learning rate of the model gradually decreases, avoiding the phenomenon of overfitting in the later stage of training. The update strategy of the learning rate is as follows:
[0130]
[0131] Among them, αt represents the learning rate of the t-th round, α0 is the initial learning rate, k is the decay coefficient, and t is the current number of training rounds.
[0132] (4) Model Validation and Evaluation
[0133] The validation and evaluation of the model are important steps 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 adopts the 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 requirements of industrial production lines.
[0136] S4. Integrate an interpretability module for defect detection.
[0137] In industrial applications, especially in tasks such as corrugated paper defect detection, the interpretability of the model is crucial. A high-performance model not only needs to perform excellently in terms of accuracy but also needs to enable users to understand its decision-making process. Therefore, this embodiment integrates an interpretability module into the corrugated paper defect detection model to improve the transparency of the model and help users understand the basis for the model to make decisions. 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 model interpretation method that can provide local interpretations for any black-box model. By generating local perturbations of the model input, LIME analyzes the impact of these perturbations on the model output to determine which features contribute the most to the model's decision-making. In the present invention, LIME is used to interpret the prediction results of the model in the corrugated paper defect detection task, helping operation and maintenance personnel understand why the model marks a certain area as a defect.
[0140] The main steps of the LIME interpretation process are as follows:
[0141] S4.1.1, Perturbation generation: First, in this embodiment, multiple perturbation samples are randomly generated in the corrugated paper defect image. Each perturbation sample is a local modification of the original input image, which may be achieved by covering certain areas or changing local pixel values.
[0142] S4.1.2, Local linear model training: Next, for each perturbation sample, the model is used to make predictions on it and record the results. Then, LIME trains a simple linear model on the basis of 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 areas that the model pays the most attention to during the prediction process.
[0144] Formally, the goal of LIME is to find a local interpretation model g(x) to approximate the original complex model f(x) through the following optimization problem:
[0145]
[0146] Where: is the difference between the model f and the local interpretation model g, π x is the weight function, representing the similarity between the perturbation sample and the original input sample, and Ω(g) is the complexity constraint on the interpretation model to ensure that the interpretation model is simple enough.
[0147] S4.2, Grad-CAM (Gradient-weighted Class Activation Mapping).
[0148] To further improve the interpretability of the model, this embodiment adopts the Grad-CAM technology. Grad-CAM is a visualization method that generates a heat map by calculating the gradient of a certain category with respect to the convolutional layer feature map, showing the image areas that the model pays the 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, calculate the gradient of the target category y c with respect to the feature map A of the model's convolutional layer k , that is These gradients reflect the importance of each feature map to the target category.
[0151] S4.2.2. Weight calculation: Then, perform global average pooling on these gradients to obtain the weights of each feature map
[0152] where Z is the spatial dimension of the feature map.
[0153] S4.2.3. Generate heatmap: Finally, apply these weights to the feature map to generate a heatmap indicating the regions that the model focuses on:
[0154]
[0155] This heatmap can visually show the regions that the model focuses on the most 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 techniques, the corrugated paper defect detection model in the present invention can not only provide accurate defect detection results, but also generate an explanatory report for each decision, showing which regions in the image the model identifies as the key factors leading to the defect judgment. These explanatory reports can help maintenance personnel better understand the behavior of the model, reduce unnecessary manual inspections, and improve the efficiency of the entire production process.
[0158] In addition, the integrated interpretability module can be integrated with the quality management system of the production line, enabling users to timely detect possible errors and anomalies in the detection process, thereby more effectively optimizing the corrugated paper production process.
[0159] S4.4. Computational resources and real-time performance.
[0160] The method of the present invention not only considers the accuracy and transparency of the model, but also optimizes the use of computational resources. By implementing with lightweight Grad-CAM during the inference process, the interpretability module can generate an explanatory report without significantly increasing the computational cost, ensuring that the corrugated paper defect detection can be carried out in real time to meet the requirements of the industrial production line.
[0161] S5. Evaluation and iterative optimization of the defect detection model.
[0162] The evaluation and optimization of the model are the key steps to ensure the stable operation 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] In the model evaluation process, this embodiment uses cross-validation to test the stability and generalization ability of the model.
[0165] The specific steps are as follows:
[0166] Dataset Division: The dataset is divided into a training set, a validation set, and a test set, which are used for model training, hyperparameter tuning, and final performance evaluation respectively. This embodiment uses five-fold cross-validation to ensure the stability of the model on different data divisions.
[0167] Validation Set Evaluation: After each training cycle, the model is tested on the validation set, various metrics are calculated, and the parameters are adjusted according to the performance of the validation set (such as learning rate adjustment, optimization of regularization strategies, etc.).
[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 has not participated in training or validation and is used to measure the true performance and generalization ability of the model.
[0169] (2) Iterative Optimization Strategy
[0170] To further improve the performance of the model, the following iterative optimization strategy is adopted in the evaluation process of this embodiment:
[0171] Hyperparameter Optimization: The hyperparameters of the model (such as learning rate, regularization coefficient, batch size, etc.) are optimized through grid search and random search. This embodiment conducts multiple rounds of experiments on the validation set to find the optimal combination of hyperparameters.
[0172] Model Pruning and Distillation: To reduce the computational cost during model inference, this embodiment uses model pruning and knowledge distillation techniques. Through the pruning technique, this embodiment removes redundant neurons in the model, thereby reducing the computational complexity. Through knowledge distillation, this embodiment transfers the knowledge of a large model to a lightweight model, ensuring the inference speed while maintaining the detection accuracy.
[0173] Learning Rate Scheduling: During the model training process, this embodiment adopts a 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 optima.
[0174] Regularization Techniques: To prevent the model from overfitting, this embodiment introduces regularization terms during the training process, including L2 regularization and Dropout. L2 regularization reduces the model complexity by adding a weight term to the loss function; Dropout enhances the generalization ability of the model by randomly discarding neurons.
[0175] (3) Error Analysis and Continuous Improvement
[0176] After each model evaluation, this embodiment conducts a detailed analysis of the misclassification results of the model. By analyzing the reasons for misclassification, this embodiment can identify the weaknesses of the model and make targeted improvements. Specifically, the error analysis mainly includes the following aspects:
[0177] Class Imbalance: If there are fewer samples of certain types of defects in the dataset, the model is prone to misclassify them. To address this, this embodiment introduces a class balancing sampling strategy and increases the sample size of the minority classes through data augmentation techniques.
[0178] Background Noise: In some complex production environments, the background noise of corrugated paper is relatively large, which may interfere with the detection results of the model. This embodiment adopts background suppression technology and trains the model with additional background samples and noise samples to enable it to distinguish defects from 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 address this, this embodiment introduces a multi-scale feature fusion mechanism to enhance the model's detection ability for defects of different scales.
[0180] (4) Performance Testing in Industrial Production
[0181] To verify the effectiveness of the method of the present invention in an actual production environment, this embodiment tests the model on an actual corrugated paper production line. By collecting images of corrugated paper at different production stages and simulating various environmental changes during the production process (such as light changes, background complexity, etc.), the robustness and real-time performance of the model are tested.
[0182] Through the above model evaluation and iterative optimization strategies, the method of the present invention can achieve high accuracy, low false alarm rate, fast inference in the corrugated paper defect detection task, and meet the actual requirements of industrial production lines.
[0183] It should be noted that for the foregoing method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should understand that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences 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 embodiments, the present invention 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. For the sake of convenience of description, in the structural schematic diagram of the embodiment of the corrugated paper defect detection system based on transfer learning and scene adaptive segmentation, only the parts related to the embodiments of the present invention are shown. Those skilled in the art can understand that the illustrated structure does not constitute a limitation on the device, and it may include more or fewer components than those illustrated, or combine certain components, or arrange different components.
[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. The system includes a data acquisition module 101, a model construction module 102, a model training module 103, a model interpretation module 104, and an evaluation and optimization module 105;
[0186] The data acquisition module 101 is used to collect the surface image data of the corrugated paper and perform preprocessing to construct a data set;
[0187] The model construction module 102 is used to select a pre-trained deep learning model for scene adaptive segmentation, 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 by 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 and optimization module 105 is used to evaluate and iteratively optimize the corrugated paper defect detection model.
[0191] It should be noted here that the system provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules according to needs, that is, the internal structure is divided into different functional modules to complete all or part of the functions described above. This system is applied to a corrugated paper defect detection method based on transfer learning and scene adaptive segmentation in the above embodiment.
[0192] It should be noted that the corrugated paper defect detection system based on transfer learning and scene adaptive segmentation of the present invention corresponds one-to-one to the corrugated paper defect detection method based on transfer learning and scene adaptive segmentation of the present invention. The technical features and beneficial effects described in the above-mentioned embodiment of the corrugated paper defect detection method based on transfer learning and scene adaptive segmentation are applicable to the embodiment of corrugated paper defect detection based on transfer learning and scene adaptive segmentation. For specific contents, please refer to the description in the embodiment of the method of the present invention, which will not be repeated here. This is hereby declared.
[0193] In addition, in the implementation of the corrugated paper defect detection system based on transfer learning and scene adaptive segmentation in the above-mentioned embodiment, the logical division of each program module is only an example. In actual applications, the above-mentioned functions can be assigned to different program modules as needed, for example, for the convenience of corresponding hardware configuration requirements or software implementation. That is, the internal structure of the corrugated paper defect detection system based on transfer learning and scene adaptive segmentation is divided into different program modules to complete all or part of the functions described above.
[0194] See also Figure 7 In one embodiment, an electronic device for implementing a corrugated paper defect detection method based on transfer learning and scene adaptive segmentation is provided. The electronic device 200 may include a first processor 201, a first memory 202 and a bus, and may also 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 transfer learning and scene adaptive segmentation.
[0195] The first memory 202 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the first memory 202 may be an internal storage unit of the electronic device 200, such as a mobile hard disk of the electronic device 200. In other embodiments, the first memory 202 may also be an external storage device of the electronic device 200, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 200. Further, the first memory 202 may also include both an internal storage unit of the electronic device 200 and an external storage device. The first memory 202 can not only be used to store application software and various types of data installed in the electronic device 200, such as the code of the corrugated paper defect detection program 203 based on transfer learning and scene adaptive segmentation, but also can be used to temporarily store data that has been output or is to be output.
[0196] In some embodiments, the first processor 201 may be composed of an integrated circuit. For example, it may be composed of a single packaged integrated circuit, or may be composed of multiple packaged integrated circuits with the same or different functions, including a combination of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The first processor 201 is the control core (Control Unit) of the electronic device, connecting various components of the entire electronic device through various interfaces and circuits, and by running or executing programs or modules stored in the first memory 202, and calling data stored in the first memory 202, to execute various functions of the electronic device 200 and process data.
[0197] Figure 7 Only an electronic device with components is shown. Those skilled in the art can understand that, Figure 3 the shown structure does not constitute a limitation on the electronic device 200, and it may include fewer or more components than shown, or combine certain components, or have different component arrangements.
[0198] The corrugated paper defect detection program 203 stored in the first memory 202 of the electronic device 200 is a combination of multiple instructions. When running in the first processor 201, it can achieve:
[0199] Collect surface image data of corrugated paper and perform preprocessing to construct a data set;
[0200] Select a pre-trained deep learning model for scene adaptive segmentation, adapt it through transfer learning, and construct a corrugated paper defect detection model;
[0201] Use the data set to train and optimize the corrugated paper defect detection model;
[0202] Generate an explanation for each prediction of the corrugated paper defect detection model and provide it to the user;
[0203] Evaluate and iteratively optimize the corrugated paper defect detection model.
[0204] Furthermore, if the modules / units integrated in the electronic device 200 are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory).
[0205] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memories. 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 many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0206] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, 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, it should be considered as the scope recorded in this specification.
[0207] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications made without departing from the spirit and principle of the present invention should be equivalent replacement methods and are all included in the protection scope of the present invention.
Claims
1. A corrugated paper defect detection method based on transfer learning and scene adaptive segmentation, characterized in that It includes the following steps: Collect the surface image data of corrugated paper and perform preprocessing to construct a dataset; Select a pre-trained deep learning model for scene adaptive segmentation, adapt it through transfer learning, and construct 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 paper defect detection model and provide them to the user; Evaluate and iteratively optimize the corrugated paper defect detection model.
2. The corrugated paper defect detection method based on transfer learning and scene adaptive segmentation according to claim 1, characterized in that, The collection of the image data on the surface of the corrugated paper is specifically: Under standardized lighting conditions, collect the image data on the surface of corrugated paper with normal, different defect types, and different background noise scenarios from the corrugated paper production line, and label the collected image data according to the defect types; The preprocessing includes grayscaling, filtering and denoising, data augmentation, and normalization.
3. A corrugated paper defect detection method based on transfer learning and scene adaptive segmentation according to claim 1, characterized in that, The adaptation through transfer learning to construct a corrugated paper defect detection model is 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: Among them, represents the weight of the i-th layer in the frozen state, represents the weight in the pre-trained state; Add one or more custom layers at the end of the model, where the custom layers include fully connected layers, convolutional layers, or classification layers, and the parameters of the custom layers are updated during training. The weight W of the custom layer (c) = trainable; Define the loss function, specifically as follows: Among them, is the cross-entropy loss function, y is the distribution of the true labels, and y i represents the prediction for the i-th label, is the distribution predicted by the model; Fine-tune the model. Specifically: During the process of transfer learning, instead of unfreezing all layers of the pre-trained model at one time for weight update, gradually increase the weight update ratio β of specific layers according to the training progress or time. Then: Among them, represents the weight of the i-th layer during the fine-tuning process, is the initial pre-trained weight, and β is the weight update ratio adjusted over time or training progress, represents the update amount of the weight.
4. A corrugated paper defect detection method based on transfer learning and scene adaptive segmentation according to claim 1, characterized in that, The use of the dataset to train and optimize the corrugated paper defect detection model is specifically: Divide the dataset into a training set, a validation set, and a test set. Among them, the training set is used for the training of the corrugated paper defect detection model, the validation set is used for the tuning of the corrugated paper defect detection model and to prevent overfitting, and the test set is used to evaluate the performance of the corrugated paper defect detection model; Adopt the binary cross-entropy loss function, as follows: Among them, L BCE is the binary cross-entropy loss function, N is the number of samples in the batch, y i is the true label of the i-th sample, is the probability predicted by the corrugated paper defect detection model; Adopt the Adam or SGD optimizer to adjust the model weights; Adjust the hyperparameters of the corrugated paper defect detection model on the validation set. The hyperparameters include the learning rate, batch size, and number of training epochs; Evaluate the performance of the corrugated paper defect detection model on the validation set using accuracy, recall, and F1-score metrics, and adjust and optimize the corrugated paper defect detection model according to the evaluation results; When the improvement rate of the performance of the corrugated paper defect detection model on the validation set is less than the set threshold in consecutive multiple training epochs, stop training.
5. A corrugated paper defect detection method based on transfer learning and scene adaptive segmentation according to claim 1, wherein, The generation of explanations for each prediction of the corrugated paper defect detection model and providing them to the user is specifically: Use the LIME algorithm to perturb the input data around the prediction of the corrugated paper defect detection model and learn the local model to explain the prediction. As follows, for each test sample: mina∑ i∈s L(a, x′ i , y i ) + Ω(a); Among them, L(a, x′ i , y i ) is the loss function between the local model and the prediction of the SAM model, a is the parameter of the local model, x′ i is the input sample in the perturbation dataset, y i is the true label or target value corresponding to the input sample x′ i ; S is the perturbation dataset, and Ω is the regularization term used to control the model complexity; Highlight the key features of the explanation instances generated by the LIME algorithm in the original corrugated paper surface image data; Integrate the generated explanations into the user interface; Use the feedback from the user on the predictions and explanations output by the corrugated paper defect detection model to further train and optimize the corrugated paper defect detection model.
6. The corrugated paper defect detection method based on transfer learning and scene adaptive segmentation according to claim 1, characterized in that, Use the gradient-weighted class activation mapping method to highlight the key features of the explanation instances generated by the LIME algorithm in the original corrugated paper surface image data, specifically: Calculate the target category y through backpropagation c with respect to the feature map A of the convolutional layer of the model k gradient, that is Perform global average pooling on the gradient to obtain the weight of each feature map Where Z is the spatial dimension of the feature map; Apply the weights to the feature map to generate a heat map Indicates the area that the model focuses on:
7. A corrugated paper defect detection method 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: The cross-validation method is adopted to test the stability and generalization ability of the model. After each training cycle, the model will be tested on the validation set, various indicators will be calculated, and the parameters will be adjusted according to the performance on the validation set; when the model reaches the best performance on the validation set, the test set will be finally used to evaluate the model; the test set has not participated in training or validation and is used to measure the true performance and generalization ability of the model; The following iterative optimization strategies are adopted during the evaluation process: Hyperparameter optimization: The hyperparameters of the model are optimized by means of grid search and random search; Model pruning and distillation: Model pruning and knowledge distillation techniques are adopted to reduce the computational amount during model inference; through the pruning technique, redundant neurons in the model are removed to reduce the computational complexity; through knowledge distillation, the knowledge of the large model is transferred to the lightweight model to ensure the inference speed while maintaining the detection accuracy; Learning rate scheduling: During the model training process, a learning rate decay strategy is adopted. In the early stage of training, a larger learning rate is adopted to accelerate convergence; in the later stage of training, the learning rate is gradually reduced to avoid the model falling into local optimum; Regularization techniques: Regularization terms are introduced during training to prevent the model from overfitting, including L2 regularization and Dropout; L2 regularization reduces the model complexity by adding a weight term to the loss function; Dropout enhances the generalization ability of the model by randomly discarding neurons.
8. A corrugated paper defect detection system based on transfer learning and scene adaptive segmentation, characterized in that, Applied to the corrugated paper defect detection method based on transfer learning and scene adaptive segmentation described in any one of claims 1-7, including 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 the surface image data of corrugated paper and perform preprocessing to construct a data set; The model construction module is used to select a pre-trained deep learning model for scene adaptive segmentation, and adapt it through transfer learning to construct a corrugated paper defect detection model; The model training module is used to train and optimize the corrugated paper defect detection model by using the data set; The model interpretation 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.
9. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, 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 so that the at least one processor can execute the corrugated paper defect detection method based on transfer learning and scene adaptive segmentation described in any one of claims 1-7.
10. A computer-readable storage medium stores a program, characterized in that: When the program is executed by the processor, it implements the corrugated paper defect detection method based on transfer learning and scene adaptive segmentation described in any one of claims 1-7.
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
Large model image segmentation method for surface defect detection in industrial field
CN117132605A
Ceramic bottle defect detection method and system based on transfer learning
CN118781073A
Corrugated carton defect detection method and system based on adaptive spatial feature fusion and structure re-parameterization
CN118918077A
Cited By
Efficient industrial quality inspection data cleaning method, storage medium and electronic equipment
CN121074440A