A Defect Detection Method and Related Device for Corrugated Cardboard Based on an Improved YOLOv5 Model
Through dataset construction, model optimization, and training inference, efficient detection of defects in corrugated cardboard was achieved, improving detection accuracy and speed, adapting to the diverse defect characteristics of corrugated cardboard, and meeting the real-time quality control needs of industrial production lines.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HEBEI BAISHA TOBACCO
- Filing Date
- 2025-12-29
- Publication Date
- 2026-05-26
AI Technical Summary
In existing technologies, the detection of defects in corrugated cardboard suffers from the problem of difficulty in balancing accuracy and speed, poor detection effect for small target defects, and the existing deep learning models cannot meet the real-time requirements of industrial production lines.
An improved YOLOv5 model is adopted. By constructing a multi-class defect dataset, the ordinary convolutions in the backbone network are replaced with Ghost convolutions. A BiFPN structure is introduced for feature fusion, and the GIoU loss function is used to optimize bounding box prediction, thereby improving detection accuracy and speed.
It enables real-time, high-precision detection of defects in corrugated cardboard, significantly improving detection speed, meeting the real-time quality control needs of industrial production lines, and reducing product losses caused by packaging damage.
Smart Images

Figure CN122089643A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of industrial product quality testing technology, specifically to its application in packaging material testing, and particularly to a method and related apparatus for detecting defects in corrugated cardboard based on an improved model of YoloV5. Background Technology
[0002] Corrugated cardboard, as one of the most widely used materials in the packaging industry, is susceptible to surface defects (such as tears, missing corners, stains, and dents) that directly affect packaging stability and may lead to damage to goods during transportation. Therefore, real-time defect detection in corrugated cardboard production lines is a crucial aspect of quality control.
[0003] Traditional manual feature extraction methods involve manually designing image features (such as texture, grayscale, and edges) and combining them with machine vision algorithms for defect identification. This method has significant limitations: it is poorly adaptable to complex and diverse defects, prone to missed or false detections, and its detection efficiency is heavily influenced by human experience, failing to meet the real-time inspection requirements of high-speed production lines.
[0004] With the development of deep learning technology, replacing previous machine vision methods with deep learning has become a key approach. However, existing deep learning models suffer from the following problems: (1) When the general pre-trained model is directly transferred to the corrugated cardboard defect detection task, there is a lot of room for improvement in both accuracy and detection speed, and it is difficult to adapt to the characteristics of corrugated cardboard defects that are "numerous, small in size and have variable dimensions". (2) There is a contradiction between model complexity and detection speed: high-precision models (such as Faster R-CNN) have slow inference speed and cannot meet the real-time requirements of the production line; while high-speed models (such as basic YOLOv5) are not accurate enough in small target defect detection. (3) Existing feature fusion methods (such as traditional FPN) have limited ability to interact with features of multi-scale defects, and the bounding box regression loss function (such as IoU) is not accurate enough in modeling overlapping areas, resulting in large defect localization errors.
[0005] Therefore, developing a detection method that combines high precision and high speed and is adapted to the characteristics of corrugated cardboard defects has become the key to solving the quality control problem in industrial production lines. Summary of the Invention
[0006] This application provides a method and related device for detecting defects in corrugated cardboard based on an improved model of YOLOv5, so as to realize real-time and high-precision detection of defects in corrugated cardboard and solve the problems of difficulty in balancing accuracy and speed and poor detection effect of small target defects in the prior art.
[0007] The technical solution is as follows: Firstly, a defect detection method for corrugated cardboard based on an improved model of YoloV5 is provided, including: Images of corrugated cardboard in the factory packaging production line were collected, and various typical defects in the images were accurately labeled. After data cleaning, a corrugated cardboard defect dataset was constructed. In the YOLOv5 model, ordinary convolutions in the backbone network are replaced with Ghost convolutions for backbone network optimization; BiFPN structure is used to replace the original FPN structure, and features at different levels are weighted and fused to enhance multi-scale defect perception capability; at the same time, GIoU loss function is introduced as regression loss function to improve bounding box prediction accuracy. The constructed dataset is divided into training, validation and test sets. The optimized YOLOv5 model is trained and the model parameters are adjusted through backpropagation until the model converges to obtain the defect detection model. The image of the corrugated cardboard to be detected is input into the defect detection model, which outputs the type, location, and confidence level of the defect, thereby realizing the automatic detection of defects in corrugated cardboard.
[0008] In one possible implementation, the multiple typical defects include at least three or more types of defects among corrugated cardboard, such as damage, missing corners, stains, dents, and cracks.
[0009] In one possible implementation, the BiFPN structure adjusts the contribution of features at different levels through weighting coefficients to achieve bidirectional feature fusion from top to bottom and bottom to top, thereby improving the detection capability of small-scale defects.
[0010] In one possible implementation, the GIoU loss function performs regression prediction of the overlapping area based on the overlap between the predicted box and the ground truth box, the distance between the center points, and the size of the bounding box, thereby improving the matching degree between the predicted box and the ground truth box by more than 15%.
[0011] In one possible implementation, the model training parameters are set as follows: the initial learning rate is 0.01, and a cosine annealing decay strategy is used; the batch size is 16-32; the number of iterations is 300-500 rounds; and the optimizer is SGD or Adam.
[0012] Secondly, a defect detection device for corrugated cardboard based on an improved model of YoloV5 is provided, comprising: The dataset construction module is used to collect images of corrugated cardboard in the factory packaging production line, accurately label multiple typical defects in the images, and construct a corrugated cardboard defect dataset after data cleaning. The model optimization module is used to replace ordinary convolutions in the backbone network of the YOLOV5 model with Ghost convolutions for backbone network optimization; it replaces the original FPN structure with a BiFPN structure and performs weighted fusion of features at different levels to enhance multi-scale defect perception capability; at the same time, it introduces GIoU as a regression loss function to improve bounding box prediction accuracy. The model training module is used to divide the constructed dataset into training, validation and test sets, train the optimized YoloV5 model, adjust the model parameters through backpropagation until the model converges to obtain the defect detection model. The defect prediction module is used to input the image of the corrugated cardboard to be detected into the defect detection model and output the category, location and confidence level of the defect, so as to realize the automatic detection of defects in corrugated cardboard.
[0013] Thirdly, an optimized YOLOv5 model for detecting defects in corrugated cardboard is provided, comprising a backbone network, a feature fusion module, and a detection head; the backbone network uses Ghost convolution instead of ordinary convolution; the feature fusion module is a BiFPN structure; and the detection head uses GIoU as the regression loss function.
[0014] In one possible implementation, the backbone network further includes a Focus module, a C3 module, and an SPP module for feature extraction and dimensionality compression.
[0015] Fourthly, an electronic device is provided, comprising: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the methods described above and any possible implementations.
[0016] Fifthly, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the aspects and any possible implementations described above.
[0017] The beneficial effects of the technical solution provided in this application include at least the following: As can be seen from the above technical solution, the embodiments of this application achieve efficient detection through dataset construction, model architecture optimization, and training inference. First, a multi-class defect annotation dataset is constructed based on corrugated cardboard images collected from factory packaging lines. Second, the YOLOv5 model undergoes triple optimization: Ghost convolutions are used to replace ordinary convolutions in the backbone network to reduce the number of parameters and improve inference speed; a BiFPN structure is used to achieve multi-scale feature weighted fusion, enhancing the ability to perceive small target defects; and GIoU is introduced as a regression loss function to optimize bounding box prediction accuracy. Finally, real-time, high-precision detection of corrugated cardboard defects is achieved. This invention significantly improves detection speed while ensuring detection accuracy, meeting the real-time quality control needs of industrial production lines and reducing product losses caused by packaging damage. It has significant engineering application value, especially in improving the processing accuracy and efficiency of the cigarette manufacturing process.
[0018] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this application, nor is it intended to limit the scope of this application. Other features of this application will become readily apparent from the following description. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a schematic diagram illustrating the steps of a method for detecting defects in corrugated cardboard based on an improved model of YoloV5, provided in one embodiment of this application.
[0021] Figure 2 is a schematic diagram of the corrugated cardboard defect detection process provided in one embodiment of this application. Figure 3 This is a structural block diagram of a corrugated cardboard defect detection device based on an improved model of YoloV5 provided in one embodiment of this application. Figure 4 This is a schematic diagram of an optimized YoloV5 model structure for corrugated cardboard defect detection provided in one embodiment of this application.
[0022] Figure 5 This is a block diagram of an electronic device used to implement the method for detecting defects in corrugated cardboard based on the improved model of YoloV5 in the embodiments of this application. Detailed Implementation
[0023] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of this application, including various details to aid understanding. These embodiments should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this application. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0024] Obviously, the described embodiments are only some, not all, of the embodiments in this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.
[0025] It should be noted that the terminal devices involved in the embodiments of this application may include, but are not limited to, smart devices such as mobile phones, personal digital assistants (PDAs), wireless handheld devices, and tablet computers; the display devices may include, but are not limited to, personal computers, televisions, and other devices with display functions.
[0026] Furthermore, the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0027] To address the challenges of balancing accuracy and speed in corrugated cardboard defect detection, and the poor performance in detecting small-target defects in existing technologies, this application proposes a corrugated cardboard defect detection scheme based on an improved model of YOLOv5. The main inventive concepts are as follows: Images of corrugated cardboard from a factory packaging line are collected; multiple typical defects in the images are accurately labeled; and a corrugated cardboard defect dataset is constructed after data cleaning. The backbone network of the YOLOv5 model is optimized by replacing ordinary convolutions with Ghost convolutions. A BiFPN structure replaces the original FPN structure, and weighted fusion of features at different levels enhances multi-scale defect perception capabilities. Simultaneously, a GIoU loss function is introduced as a regression loss function to improve bounding box prediction accuracy. The constructed dataset is divided into training, validation, and test sets, and the optimized YOLOv5 model is trained using backpropagation to adjust model parameters until the model converges, resulting in a defect detection model. The image of the corrugated cardboard to be detected is input into the defect detection model, which outputs the defect category, location, and confidence level, thus achieving automatic detection of corrugated cardboard defects. This invention significantly improves detection speed while ensuring detection accuracy, meets the real-time quality control requirements of industrial production lines, and reduces product losses caused by packaging damage. It has significant engineering application value, especially in improving the processing accuracy and efficiency of the production line in the cigarette manufacturing process.
[0028] Reference Figure 1 The diagram illustrates the steps of a defect detection method for corrugated cardboard based on an improved model of YoloV5, as provided in an embodiment of this application. The method may include: Step 102: Collect images of corrugated cardboard in the factory packaging line, accurately label the various typical defects in the images, and construct a corrugated cardboard defect dataset after data cleaning.
[0029] In practice, step 102 may include the following steps: First, using a camera installed on the packaging production line, images of all five sides of the corrugated cardboard box (excluding the bottom) are taken to obtain several images of the box's exterior. Second, the images are cropped to ensure that the corrugated cardboard box is centered and the image is square. Finally, annotation software is used to annotate the images to create a defect dataset for corrugated cardboard boxes.
[0030] Optionally, in this application, the multiple typical defects include at least three or more types of defects among the following: damage, missing corners, stains, indentations, and cracks in corrugated cardboard.
[0031] Step 104: Replace the ordinary convolutions in the backbone network of the YOLOV5 model with Ghost convolutions to optimize the backbone network; replace the original FPN structure with a BiFPN structure to perform weighted fusion of features at different levels to enhance the multi-scale defect perception capability; at the same time, introduce the GIoU loss function to determine the regression loss function to improve the bounding box prediction accuracy.
[0032] It should be understood that this application mainly improves the YOLOv5 model in three aspects: 1. Replacing convolutions in the backbone network with Ghost convolutions to improve the model's detection speed; 2. Introducing BiFPN in the neck region to increase the model's multi-scale feature extraction capability; 3. Introducing the GIoU loss function to improve the accuracy of bounding box prediction.
[0033] Specifically, this application replaces the convolutional operations in the YOLOv5 backbone network with Ghost convolutions, which significantly reduces the number of model parameters while minimizing performance loss, thus meeting the lightweight deployment requirements in real-world factories. (See reference...) Figure 2a The diagram shown illustrates the process of obtaining the final feature map using Ghost convolution, as provided in this embodiment. Ghost convolution first extracts features from the image using a small number of kernels, then uses depth-wise convolution, which has lower computational overhead, to calculate the extracted redundant feature maps. Finally, the final feature map is obtained by concatenating these features. The calculation process is as follows: First, for the input feature map Perform standard convolution: in, It uses a smaller number of standard convolutional kernels. For the first bias term, This is the initial feature extracted using a small number of standard convolutional kernels.
[0034] Next, depth-wise convolutions are used to generate feature maps with lower computational cost, i.e., grouped convolutions are used to generate Ghost feature maps: in, Let S be the Ghost feature map of the i-th layer, and S be the expansion factor of the Ghost features. It is a Ghost convolution kernel that operates independently on each channel. It is a bias term; The Ghost feature map is concatenated with the extracted initial features to obtain the final feature map: .
[0035] Furthermore, the feature fusion module in the YOLOv5 neck region is replaced with BiFPN, thereby achieving weighted fusion of features at different scales. For details, please refer to [link to relevant documentation]. Figure 2b The core idea of BiFPN is to perform weighted fusion of multi-scale feature maps in FPN. The BiFPN used in this application has four layers, with each layer taking input features as... Where i = 3, 4, 5, 6, 7. The calculation formula for each layer of BiFPN is as follows: ; ; ; ; ; in, It outputs a feature map; It is the input feature map; These are learnable weights; i refers to the layer number, and k corresponds to the weights of that layer. Pick To prevent the denominator from being 0.
[0036] Finally, BiFPN is used to replace the ConCat operation in the YOLOv5 header, enabling selective feature fusion and enhancing the model's feature fusion capabilities.
[0037] Furthermore, the loss function CIoU used during YOLOv5 training is replaced with GIoU, which improves the model's ability to model relative positions without increasing the model size.
[0038] For predicted bounding boxes A and B, the minimum bounding rectangle C of both is first determined. The positional relationship between the ground truth bounding box and the predicted bounding box can be reflected in the loss by calculating the ratio of the area of C \ (A∪ B) to the area of C. The specific calculation formula is as follows: The GIoU loss function is based on the overlap region between the predicted and ground truth bounding boxes, the distance between their centers, and the size of their bounding boxes to perform regression prediction of the overlap region, resulting in the model's loss function: in, For confidence loss, For classifying losses, Loss due to IoU; , and These are the weight parameters we.
[0039] In this application, the Ghost convolution generates more feature maps through low-cost computation, reducing the number of model parameters by more than 30% and improving inference speed by more than 25% without significantly reducing detection accuracy. The BiFPN structure adjusts the contribution of features at different levels through weighting coefficients, achieving bidirectional feature fusion from top to bottom and bottom to top, thereby improving the detection capability for small-scale defects. The GIoU loss function performs regression prediction of the overlapping region based on the overlap area between the predicted box and the ground truth box, the distance between the center point, and the size of the bounding box, improving the matching degree between the predicted box and the ground truth box by more than 15%.
[0040] Step 106: Divide the constructed dataset into training, validation and test sets, train the optimized YoloV5 model, adjust the model parameters through backpropagation until the model converges to obtain the defect detection model.
[0041] Optionally, during model training, the model training parameters can be set as follows: initial learning rate of 0.01, cosine annealing decay strategy; batch size of 16-32; number of iterations of 300-500 rounds; and SGD or Adam optimizer.
[0042] Step 108: Input the image of the corrugated cardboard to be detected into the defect detection model, and output the type, location and confidence level of the defect to realize the automatic detection of corrugated cardboard defects.
[0043] Reference Figure 2c The diagram shown is a schematic of the corrugated cardboard defect detection process provided in an embodiment of this application.
[0044] The corrugated cardboard defect dataset was constructed by collecting images of corrugated cardboard from a factory's packaging production line. The image resolution was set to 640×640 pixels, covering corrugated cardboard samples from different lighting conditions and production batches. The LabelImg tool was used to accurately label various typical defects in the images, such as damage, missing corners, stains, dents, and cracks, in YOLO format (including defect category and bounding box coordinates). The labeled images underwent data cleaning to remove blurry and duplicate samples. Finally, a corrugated cardboard defect dataset was constructed, comprising a training set (70%), a validation set (15%), and a test set (15%), providing data support for model training.
[0045] The model architecture optimization is based on the YOLOV5 model and is specifically optimized. The optimized model architecture includes three parts: backbone, feature fusion module and head. The specific optimizations are as follows: (1) Backbone optimization: The ordinary convolution in the YOLOV5 backbone is replaced with Ghost convolution. Ghost convolution reduces the number of model parameters and computation by "generating core feature maps by basic convolution + generating Ghost feature maps by cheap operation" while maintaining the feature expression capability. For example, for a convolutional layer with C output channels, ordinary convolution needs to be calculated K×K×C_in×C times (K is the kernel size and C_in is the number of input channels), while Ghost convolution can reduce the computation by about 60% by decomposing the operation, which significantly improves the model inference speed. (2) Feature fusion module optimization: BiFPN (bidirectional weighted feature pyramid network) is used to replace the original FPN (feature pyramid network). The BiFPN structure improves the feature fusion effect in the following two ways: ① It introduces a weighted fusion mechanism, which allocates weights according to the importance of features at different levels, thereby enhancing the contribution of effective features; ② It constructs a bidirectional feature fusion path to realize the top-down semantic feature transfer and the bottom-up position feature supplementation, so that the model can make full use of multi-scale feature information and improve the detection capability of small targets and multi-scale defects. (3) Loss function optimization: The original IoU loss function of YOLOV5 is replaced with the GIoU (Generalized Intersection over Union) loss function. GIoU not only considers the overlapping area between the predicted box and the real box, but also introduces the minimum bounding rectangle of the bounding box, which can effectively solve the problem of gradient vanishing when the predicted box and the real box do not overlap. At the same time, it optimizes the position regression accuracy of the bounding box, so that the predicted box fits the real defect area better.
[0046] Model Training and Inference (1) Model Training: Input the constructed dataset into the optimized YOLOV5 model and set the training parameters: the initial learning rate is 0.01, and the cosine annealing decay strategy is adopted; the batch size is 32; the number of iterations is 400 rounds; the optimizer is Adam; and the weight decay coefficient is 0.0005. During the training process, the mAP (mean accuracy) and loss value of the model are monitored in real time through the validation set. When the mAP of the validation set tends to be stable and there is no improvement for 20 consecutive rounds, the training is stopped and the optimal model weights are saved. (2) Defect Detection Inference: Input the corrugated cardboard image to be detected into the trained model. The model extracts image features through the backbone network, performs multi-scale feature fusion through the BiFPN module, and finally outputs the defect category, bounding box coordinates and confidence score by the detection head. When the confidence score is greater than the set threshold (default 0.5), it is determined to be a valid defect, and the automatic detection of corrugated cardboard defects is realized.
[0047] Compared with the prior art, the present invention has the following beneficial effects: Balancing detection speed and accuracy: Through Ghost convolution optimization, the number of model parameters is reduced by more than 60%, and the inference speed is improved by 25%-30%, meeting the real-time detection needs of the production line; at the same time, BiFPN feature fusion and GIoU loss function optimization improve the model mAP to more than 92%, significantly reducing the false negative and false positive rates, especially for small-scale defects, the detection accuracy is significantly improved.
[0048] High adaptability: It is specifically optimized to address the characteristics of corrugated cardboard defects such as "large quantity, small size, and inconsistent dimensions", eliminating the need for secondary model adjustments for different types of corrugated cardboard and ensuring high adaptability.
[0049] High engineering practicality: The model is based on an improved YOLOv5 architecture, which is easy to deploy and can be directly integrated into existing packaging production lines without additional hardware costs; the detection process is automated, replacing manual inspection, reducing labor costs, and avoiding the subjective errors of manual inspection.
[0050] Significant quality control results: It enables defect screening of corrugated cardboard before use, effectively preventing damaged corrugated cardboard from entering the packaging process, reducing product losses due to packaging damage, and improving product packaging quality.
[0051] To further illustrate the technical effects of the present invention, the following detailed description is provided in conjunction with specific embodiments: Dataset parameters: The constructed corrugated cardboard defect dataset contains 5000 images, including 3500 images for training, 750 images for validation, and 750 images for testing; the defect types cover 5 categories: damage, missing corners, stains, indentations, and cracks, among which small-scale defects (area less than 5% of the total image area) account for 40%.
[0052] Training environment: Hardware environment consists of Intel Core i7-12700K CPU and NVIDIA RTX 3090 GPU (24G VRAM); Software environment consists of Python 3.8, PyTorch 1.12.0, and OpenCV 4.5.5.
[0053] Performance Comparison: The optimized model of this invention (denoted as YoloV5-Ghost-BiFPN-GIoU) was compared with the basic YoloV5 model and YoloV3 model. The test metrics included mAP (IoU=0.5), FPS (frames per second), and number of parameters. The results are shown in the table below:
[0054] As shown in the table above, the mAP of the model of this invention is improved by 6.8 percentage points, the FPS is improved by 26.3%, and the number of parameters is reduced by 60.2% compared with the basic YOLOV5 model. It achieves simultaneous optimization of accuracy and speed and is significantly better than the traditional YOLOV3 model.
[0055] Practical application results: The model of this invention was deployed on the packaging production line of a cigarette factory. The corrugated cardboard conveying speed was 1m / s. The model could output the detection results in real time with a detection delay of less than 100ms. After one month of trial operation, a total of 120,000 sheets of corrugated cardboard were inspected, with a defect detection rate of 99.2%, a false detection rate of 0.8%, and a missed detection rate of 0.3%. The efficiency was increased by 5 times compared with the previous manual inspection, and the loss of goods caused by packaging damage was reduced by 80%.
[0056] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0057] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0058] Figure 3 This paper illustrates a structural block diagram of a corrugated cardboard defect detection device based on an improved model of YoloV5, according to an embodiment of this application. Figure 3As shown. The corrugated cardboard defect detection device 300 based on an improved YOLOv5 model in this embodiment may include a dataset construction module 301, a model optimization module 302, a model training module 303, and a defect prediction module 304. The dataset construction module 301 is used to collect images of corrugated cardboard from a factory packaging line, accurately label multiple typical defects in the images, and construct a corrugated cardboard defect dataset after data cleaning. The model optimization module 302 is used to replace ordinary convolutions in the backbone network of the YOLOv5 model with Ghost convolutions for backbone network optimization; to replace the original FPN structure with a BiFPN structure, and to perform weighted fusion of features at different levels to enhance multi-scale defect perception capabilities; and to introduce GIoU as a regression loss function to improve bounding box prediction accuracy. The model training module 303 is used to divide the constructed dataset into training, validation, and test sets, train the optimized YOLOv5 model, adjust model parameters through backpropagation until the model converges to obtain a defect detection model. The defect prediction module 304 is used to input the image of the corrugated cardboard to be detected into the defect detection model and output the category, location and confidence level of the defect to realize the automatic detection of defects in corrugated cardboard.
[0059] It should be noted that some or all of the corrugated cardboard defect detection device based on the improved model of YOLOv5 in this embodiment can be an application located on a local terminal, or it can be a plugin or software development kit (SDK) or other functional unit set in the application located on the local terminal, or it can be a processing engine located on the network-side server, or it can be a distributed system located on the network side, such as a processing engine or distributed system in an autonomous driving platform on the network side. This embodiment does not make any special limitations on this.
[0060] It is understood that the application can be a native program installed on the local terminal, or it can be a web application of a browser on the local terminal. This embodiment does not limit this.
[0061] Optionally, in one possible implementation of this embodiment, the multiple typical defects include at least three or more types of defects among corrugated cardboard, such as damage, missing corners, stains, indentations, and cracks.
[0062] Optionally, in one possible implementation of this embodiment, the model optimization module 302 can specifically adjust the contribution of features at different levels of the BiFPN structure through weighting coefficients to achieve bidirectional feature fusion from top to bottom and from bottom to top, thereby improving the detection capability of small-scale defects.
[0063] Optionally, in one possible implementation of this embodiment, the model optimization module 302 can specifically perform regression prediction of the overlapping area of the predicted box and the ground truth box based on the GIoU loss function, the distance between the center points and the bounding box size, so as to improve the matching degree between the predicted box and the ground truth box by more than 15%.
[0064] Optionally, in one possible implementation of this embodiment, the model training module 303 can specifically set the model training parameters as follows: the initial learning rate is 0.01, and a cosine annealing decay strategy is adopted; the batch size is 16-32; the number of iterations is 300-500 rounds; and the optimizer is SGD or Adam.
[0065] Reference Figure 4 The diagram shown is a schematic representation of the optimized YoloV5 model structure for corrugated cardboard defect detection provided in an embodiment of this application. Figure 4 As shown, this model includes the basic YOLOv5 network structure, as well as a backbone network, a feature fusion module, and a detection head. The backbone network uses Ghost convolutions instead of ordinary convolutions. The feature fusion module is a BiFPN structure. The detection head uses GIoU as the regression loss function. The backbone network also includes a Focus module, a C3 module, and an SPP module for feature extraction and dimensionality compression.
[0066] In this embodiment, efficient detection can be achieved through dataset construction, model architecture optimization, and training inference. First, a multi-class defect annotation dataset is constructed based on corrugated cardboard images collected from factory packaging lines. Second, the YoloV5 model undergoes triple optimization: Ghost convolutions replace ordinary convolutions in the backbone network to reduce the number of parameters and improve inference speed; a BiFPN structure is used to achieve multi-scale feature weighted fusion, enhancing the ability to perceive small target defects; and GIoU is introduced as a regression loss function to optimize bounding box prediction accuracy. Finally, real-time, high-precision detection of corrugated cardboard defects is achieved. This invention significantly improves detection speed while ensuring detection accuracy, meeting the real-time quality control needs of industrial production lines and reducing product losses caused by packaging damage. It has significant engineering application value, especially in improving the processing accuracy and efficiency of the cigarette manufacturing process.
[0067] One embodiment of this application provides a computer-readable storage medium storing at least one instruction, which is loaded and executed by a processor to implement the method for detecting defects in corrugated cardboard based on the improved YoloV5 model as described above.
[0068] One embodiment of this application provides an electronic device including a processor and a memory, wherein the memory stores at least one instruction, which is loaded and executed by the processor to implement the method for detecting corrugated cardboard defects based on the improved model of YoloV5 as described above.
[0069] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the technical solution of this application all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0070] Figure 5 A schematic block diagram of an example electronic device 500 that can be used to implement embodiments of this application is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the application described and / or claimed herein.
[0071] like Figure 5 As shown, the electronic device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. The RAM 503 may also store various programs and data required for the operation of the electronic device 500. The computing unit 501, ROM 502, and RAM 503 are interconnected via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0072] Multiple components in electronic device 500 are connected to I / O interface 505, including: input unit 506, such as keyboard, mouse, etc.; output unit 507, such as various types of monitors, speakers, etc.; storage unit 508, such as disk, optical disk, etc.; and communication unit 509, such as network card, modem, wireless transceiver, etc. Communication unit 509 allows electronic device 500 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0073] The computing unit 501 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 501 performs the various methods and processes described above, such as the method for detecting corrugated cardboard defects based on an improved model of YoloV5. For example, in some embodiments, the method for detecting corrugated cardboard defects based on an improved model of YoloV5 can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 508. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 500 via ROM 502 and / or communication unit 509. When the computer program is loaded into RAM 503 and executed by the computing unit 501, one or more steps of the method for detecting corrugated cardboard defects based on an improved model of YoloV5 described above can be performed. Alternatively, in other embodiments, computing unit 501 may be configured by any other suitable means (e.g., by means of firmware) to perform a method for detecting corrugated cardboard defects based on an improved model of YoloV5.
[0074] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations may include: implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transferring data and instructions to the storage system, at least one input device, and at least one output device.
[0075] The program code used to implement the methods of this application may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing device, such that when executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0076] In the context of this application, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0077] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0078] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0079] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0080] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this application can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this application can be achieved, and this is not limited herein.
[0081] The specific embodiments described above do not constitute a limitation on the scope of protection of this application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A defect detection method for corrugated cardboard based on an improved model of YOLOv5, characterized in that, include: Images of corrugated cardboard in the factory packaging production line were collected, and various typical defects in the images were accurately labeled. After data cleaning, a corrugated cardboard defect dataset was constructed. In the YOLOv5 model, ordinary convolutions in the backbone network are replaced with Ghost convolutions for backbone network optimization; BiFPN structure is used to replace the original FPN structure, and features at different levels are weighted and fused to enhance multi-scale defect perception capability; at the same time, GIoU loss function is introduced to determine the regression loss function to improve bounding box prediction accuracy. The constructed corrugated cardboard defect dataset is divided into training set, validation set and test set. The optimized YoloV5 model is trained and the model parameters are adjusted through backpropagation until the model converges to obtain the defect detection model. The image of the corrugated cardboard to be detected is input into the defect detection model, which outputs the type, location, and confidence level of the defect, thereby realizing the automatic detection of defects in corrugated cardboard.
2. The method as described in claim 1, characterized in that, The method further includes: In the backbone network, Ghost convolutions use a small number of convolution kernels to extract features from the image; Generate Ghost feature maps using grouped convolution: in, This is the Ghost feature map, where S is the expansion factor of the Ghost features. It is a Ghost convolution kernel that operates independently on each channel. It is a bias term; The Ghost feature map is concatenated with the extracted initial features to obtain the final feature map.
3. The method as described in claim 1, characterized in that, The BiFPN structure consists of four layers, and the input features of each layer include: ; ; ; ; ; in, It outputs a feature map; It is the input feature map; These are learnable weights; i refers to the layer number, and k corresponds to the weights of that layer. Pick .
4. The method as described in claim 1, characterized in that, The GIoU loss function is based on the overlap region between the predicted and ground truth bounding boxes, the distance between their centers, and the size of their bounding boxes to perform regression prediction of the overlap region, resulting in the model's loss function: in, For confidence loss, For classifying losses, Loss due to IoU; , and These are the weight parameters we.
5. The method according to any one of claims 1-4, characterized in that, The model training parameters were set as follows: initial learning rate of 0.01, cosine annealing decay strategy; batch size of 16-32; number of iterations of 300-500 rounds; and SGD or Adam optimizer.
6. A defect detection device for corrugated cardboard based on an improved model of YOLOv5, characterized in that, include: The dataset construction module is used to collect images of corrugated cardboard in the factory packaging production line, accurately label multiple typical defects in the images, and construct a corrugated cardboard defect dataset after data cleaning. The model optimization module is used to replace ordinary convolutions in the backbone network of the YOLOV5 model with Ghost convolutions for backbone network optimization; it replaces the original FPN structure with a BiFPN structure and performs weighted fusion of features at different levels to enhance multi-scale defect perception capability; at the same time, it introduces the GIoU regression loss function to improve the bounding box prediction accuracy. The model training module is used to divide the constructed corrugated cardboard defect dataset into training, validation and test sets, train the optimized YoloV5 model, adjust the model parameters through backpropagation until the model converges to obtain the defect detection model. The defect prediction module is used to input the image of the corrugated cardboard to be detected into the defect detection model and output the category, location and confidence level of the defect, so as to realize the automatic detection of defects in corrugated cardboard.
7. An optimized YoloV5 model for defect detection of corrugated cardboard as described in any one of claims 1-5, characterized in that, It includes a backbone network, a feature fusion module, and a detection head; the backbone network uses Ghost convolution instead of ordinary convolution; the feature fusion module is a BiFPN structure; and the detection head uses GIoU as the regression loss function.
8. The optimized YOLOv5 model according to claim 7, characterized in that, The backbone network also includes a Focus module, a C3 module, and an SPP module for feature extraction and dimensionality compression.
9. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1-5.
10. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-5.