Method and system for detecting flaws on surface of flour cake based on YOLOv8 improvement

By replacing the C2f module with the C2f-OD module in the YOLOv8 model, adding a small object detection layer, and using the Inner-MPDIoU loss function, the problem of low accuracy and speed in the detection of surface defects of the dough is solved, achieving more efficient and accurate defect detection.

CN119494811APending Publication Date: 2025-02-21FUJIAN UNIV OF TECH +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410979749.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2024-05-15
Filing Date
2024-07-22
Publication Date
2025-02-21

AI Technical Summary

Technical Problem

The prior art has problems in the detection of surface defects of dough cakes, especially when the surface defects of dough cakes are small.

Method used

Based on YOLOv8's improved surface defect detection method, by replacing the C2f module of the YOLOV8s backbone network with the C2f-OD module, a small object detection layer is added, and using the Inner-MPDIoU loss function, an improved YOLOv8s model is built to improve detection accuracy and speed. .

Benefits of technology

It improves the accuracy and speed of surface defect detection of dough cakes, enhances the detection ability of small target defects, reduces missed detection, and can accurately locate defects in the presence of various noises.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119494811A_ABST
    Figure CN119494811A_ABST
Patent Text Reader

Abstract

The invention discloses a cake surface flaw detection method and system based on YOLOv8 improvement, and the method comprises the steps: S1, obtaining a cake image through an image collection device, and constructing a data set of cake surface flaws with labels; s2, a C2f module of the YOLOV8s backbone network is replaced by a C2f-OD module; s3, adding a small target detection layer in the neck network of the YOLOv8s; s4, the CIoU of the YOLOv8s is replaced by the Inner-MPDIOU, so that an improved YOLOv8s model is constructed and obtained; and S5, training the improved YOLOv8s model to obtain a final pancake surface defect detection model, and finally detecting the pancake surface defect image to be detected by using the pancake surface defect detection model. According to the method, accurate positioning can still be realized under the condition that various noises exist in the flour cake surface defect image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of small target detection, and in particular to a method and system for detecting surface defects of dough based on an improved YOLOv8. Background Art

[0002] With the rapid development of automated defect detection technology, the defect detection method based on manual observation of surface defects of dough cakes has gradually shifted to machine vision. Traditional manual detection is difficult to meet the requirements of real-time detection. The surface defect detection method based on machine vision can detect defects more efficiently and accurately. In modern dough production, the surface defect detection of dough cakes requires professional personnel to determine whether there are defects on the surface of the dough cakes. Manual detection has a certain degree of subjectivity, and missed detection and false detection are inevitable. The detection method based on machine vision has certain advantages in solving these problems, so it is necessary to develop a set of surface defect detection system for dough cakes.

[0003] At present, algorithms for object detection are divided into one-stage and two-stage algorithms. The two-stage algorithms include the R-CNN series, which generates a series of candidate regions in the input image, and then uses a deep convolutional neural network for each candidate region to extract features from the candidate region, and then classify and locate the object. However, the R-CNN algorithm is slow and has a high memory usage.

[0004] In recent years, with the continuous improvement of deep learning algorithms, certain progress has been made in the field of target detection. However, in the defect detection of surface defects of dough cakes, the size, shape, and texture characteristics of the defects are different, which leads to certain difficulties in the accurate detection of surface defects of dough cakes. In addition, the surface defects of dough cakes are relatively small, and the detection accuracy and speed of traditional target detection algorithms are not high, and there is a certain amount of missed detection. Summary of the invention

[0005] The purpose of the present invention is to provide a method and system for detecting surface defects of dough based on improved YOLOv8.

[0006] The technical solution adopted by the present invention is:

[0007] The improved method for detecting surface defects of dough based on YOLOv8 includes the following steps:

[0008] S1: Obtain a dough image through an image acquisition device and construct a dataset of dough surface defects with annotations;

[0009] S2: Replace the C2f module of the YOLOV8s backbone network with the C2f-OD module;

[0010] S3: Add a small object detection layer to the neck network of YOLOv8s;

[0011] S4: Replace CIoU of YOLOv8s with Inner-MPDIoU to build an improved YOLOv8s model;

[0012] S5: Train the improved YOLOv8s model to obtain the final noodle surface defect detection model, and finally use the noodle surface defect detection model to detect the noodle surface defect image to be detected.

[0013] Furthermore, the specific steps of step S1 are as follows:

[0014] Step S11: Acquire a dataset of surface defects of dough cakes;

[0015] Step S12: Use labelImg to make a defect label;

[0016] Step S13: Use the mosaic method to perform data enhancement on the defect labels to expand the overall data volume and prevent overfitting of the trained model. Four images with a pixel value of 400*400 are assembled into a group, and the blank parts are filled with average grayscale; the mosaic data is enhanced to a 1280*1280 labeled image.

[0017] Furthermore, in the step S11, the data set is annotated and divided into a picture data set file and a picture corresponding label file;

[0018] In step S12, the labeled data set is classified into black spot category and burnt category;

[0019] In step S13, the processed data set is preprocessed and divided into a training set, a validation set, and a test set in a ratio of 7:2:1; using the mosaic data enhancement scheme, 4 pictures are randomly selected and spliced ​​by random scaling, random cropping, and random arrangement to generate new training samples to improve the robustness and generalization ability of the model.

[0020] Furthermore, step S2 is specifically as follows: replace the C2f module of the YOLOV8s backbone network with the C2f-OD module. The C2f-OD module optimizes the ordinary convolution of the Bottleneck of the original C2f module to the ODConv full-dimensional dynamic convolution, adaptively adjusts the convolution kernel according to different input image data, and specifically extracts the features of the pancake defects, which significantly enhances the feature extraction ability of the model, strengthens the learning ability of the network, and improves the recognition accuracy of the model. ODConv can be described as follows.

[0021] y=(α ω1 ⊙α f1 ⊙α c1 ⊙α s1⊙W1+…+α ωi ⊙α fi ⊙α ci ⊙α si ⊙W i +…+α ωn ⊙α fn ⊙α cn ⊙α sn ⊙W n )*x

[0022] Among them, y represents the output of ODConv full-dimensional dynamic convolution; x represents the input of ODConv full-dimensional dynamic convolution; α ωi Represents the convolution kernel W i The attention scalar α si Represents the i-th convolution kernel W i The attention scalar of the spatial position of ci Represents the i-th convolution kernel W i The attention scalar along the input channel dimension; a fi Represents the i-th convolution kernel W i The attention scalar along the output channel dimension; ⊙ represents the multiplication operation along different dimensions of the kernel space; n represents the total number of convolution kernels.

[0023] Furthermore, step S3 is specifically as follows: a small target detection layer is added to the neck network of the YOLOv8s network model, and the feature layer fused from top to bottom by the original YOLOv8s network is processed by the C2f-OD module and upsampling to form a deep semantic feature layer, including more low-order feature information. Next, the feature layer is fused with the features extracted by the third layer of the backbone network, and processed by an additional decoupling head to realize the detection of small target feature maps (specifically, 320*320 feature maps), so that the model can detect targets containing more detailed low-order information and smaller targets.

[0024] Furthermore, step S4 is specifically as follows: use the inner-MPDIoU loss function as the bounding box regression loss to assist the border in calculating IoU, improve the learning ability of complex samples, and further improve the generalization ability of the model. As shown in the figure. The Inner-MPDIoU expression is as follows:

[0025]

[0026] in, Refers to the upper left corner and lower right corner of the predicted box and the real box respectively. Calculate the distance between corresponding points, h and w represent the height and width of the box;

[0027] IoU inner is the auxiliary bounding box IoU, IoUinner The definition is as follows:

[0028]

[0029] union=(w gt *h gt )*(ratio) 2 +(w*h)*(ratio) 2 -inter

[0030]

[0031] Among them, b bt and b are the target box and anchor box respectively; is the center point of the target frame; (x c ,y c ) is the center point of the anchor box; the width and height of the target box are w gt and h gt ; The width and height of the anchor box are w and h respectively; ratio is an adjustable factor, ratio∈[0.5,1.5]. When ratio<1, the auxiliary box is smaller than the actual box, and the effective range of regression is smaller than the IoU loss, but the absolute value of the gradient is larger than the gradient obtained by the IoU loss, which can accelerate the convergence of high IoU samples. When ratio>1, the auxiliary box is larger than the actual box, which expands the effective range of regression and is beneficial to the regression of low IoU.

[0032] Further, the specific steps of step S5 are as follows:

[0033] A: Configure the network environment, Python version 3.9, deep learning framework Pytorch 2.1.0, and use CUDA 11.8 for training acceleration;

[0034] B: Set the initial learning rate to 0.01;

[0035] C: Set the number of images per batch input to 8;

[0036] D: Use the improved YOLOv8s model for training; the network model does not use pre-trained weights, and the overall network loss is calculated and iterated after each cycle of training. The network training of the improved YOLOv8s model is stopped when the mAP (mean Average Precision) indicator of the validation set stabilizes (the mAP indicator does not increase after 50 consecutive rounds of training).

[0037] Furthermore, the present invention also discloses a surface defect detection system for dough based on YOLOv8 network, which comprises the following modules:

[0038] Image acquisition module: collects industrially produced dough image datasets;

[0039] Data enhancement module: enhances the collected images to expand the data set and improve the robustness of the model;

[0040] Dataset partitioning module: divide the data set into training set, validation set, and test set according to a certain ratio;

[0041] Model improvement module: The training set and validation set are input into the original YOLOv8 model for training to improve the performance and generalization ability of the model, and finally an optimized YOLOv8 model is obtained. During the training process, the data of the training set is used to optimize the parameters and learn the features of the model. At the same time, the hyperparameters of the model are adjusted through the evaluation indicators of the validation set to improve the prediction effect of the model on unknown data. After multiple rounds of iterative training and verification, the optimized model can more accurately identify targets and improve the accuracy and stability of detection;

[0042] Object detection module: used to input the test set into the improved YOLOv8 model to detect surface defects of the dough and obtain the detection results of surface defects of the dough.

[0043] The present invention adopts the above technical scheme, replaces the C2F module of the backbone network of the YOLOv8s model with the C2f-OD module, refines local features to enhance the feature extraction ability of the algorithm and reduces additional parameters; adds a small target detection layer in the neck network structure, contains more shallow semantic features, and constructs a detection head for detecting 320×320 feature maps, thereby improving the algorithm's detection ability for small target defects; replaces the YOLOv8s loss function with Inner-MPDIoU with higher convergence speed and positioning accuracy, making it more suitable for dough defect detection tasks. Compared with the prior art, the present invention has the following beneficial technical effects: (1) The C2F module of the YOLOV8s model backbone network is replaced with a C2f-OD module, local features are refined to enhance feature extraction capability and reduce additional parameters, thereby solving the problem of poor feature extraction effect due to the small area of ​​surface defects on the pancake; (2) a small target detection layer is added to the neck network structure, which contains more shallow semantic features, and a detection head for detecting 320×320 feature maps is constructed to improve the detection capability of small target defects, thereby enhancing the detection of different defect sizes and different defect densities on the pancake surface; (3) the present invention introduces Inner-MPDIoU with higher convergence speed and positioning accuracy, calculates IoU through auxiliary borders, and improves the generalization ability of the model at the same time, so that it can still accurately locate the surface defect image of the pancake in the presence of various noises. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments;

[0045] Figure 1 It is a flow chart of a method for detecting surface defects of dough cakes based on an improved YOLOv8 model of the present invention;

[0046] Figure 2 This is the original YOLOv8 network model structure diagram;

[0047] Figure 3 It is a structural diagram of the improved YOLOv8 network model of the present invention;

[0048] Figure 4 This is the ODConv convolution structure diagram;

[0049] Figure 5 It is a structural diagram of the improved C2f-OD module proposed in the present invention;

[0050] Figure 6 Schematic diagram of inner-MPDIoU loss function for burnt dough defects;

[0051] Figure 7 Schematic diagram of inner-MPDIoU loss function for black spot defects in dough;

[0052] Figure 8 A schematic diagram of the fitting curves of the improved YOLOv8s model of the present invention and the original YOLOv8s model during the training process;

[0053] Fig. 9 Visualize the heat map of C2f-OD parameters during model training;

[0054] Fig.10 Visualize the heat map of small object detection layer parameters during model training;

[0055] Fig.11 This is a schematic diagram of the system structure of the present invention. Implementation

[0057] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0058] like Figures 1 to 11 As shown in one, the present invention discloses a method for detecting surface defects of dough based on an improved YOLOv8, which comprises the following steps:

[0059] S1: Obtain a dough image through an image acquisition device and construct a dataset of dough surface defects with annotations;

[0060] S2: Replace the C2f module of the YOLOV8s backbone network with the C2f-OD module;

[0061] S3: Add a small object detection layer to the neck network of YOLOv8s;

[0062] S4: Replace CIoU of YOLOv8s with Inner-MPDIoU to build an improved YOLOv8s model;

[0063] S5: Train the improved YOLOv8s model to obtain the final noodle surface defect detection model, and finally use the noodle surface defect detection model to detect the noodle surface defect image to be detected.

[0064] Furthermore, the specific steps of step S1 are as follows:

[0065] Step S11: Acquire a dataset of surface defects of dough cakes;

[0066] Step S12: Use labelImg to make a defect label;

[0067] Step S13: Use the mosaic method to perform data enhancement on the defect labels to expand the overall data volume and prevent overfitting of the trained model. Four images with a pixel value of 400*400 are assembled into a group, and the blank parts are filled with average grayscale; the mosaic data is enhanced to a 1280*1280 labeled image.

[0068] Furthermore, in the step S11, the data set is annotated and divided into a picture data set file and a picture corresponding label file;

[0069] In step S12, the labeled data set is classified into black spot category and burnt category;

[0070] In step S13, the processed data set is preprocessed and divided into a training set, a validation set, and a test set in a ratio of 7:2:1; using the mosaic data enhancement scheme, 4 pictures are randomly selected and spliced ​​by random scaling, random cropping, and random arrangement to generate new training samples to improve the robustness and generalization ability of the model.

[0071] Furthermore, step S2 is specifically as follows: replace the C2f module of the YOLOV8s backbone network with the C2f-OD module. The C2f-OD module optimizes the ordinary convolution of the Bottleneck of the original C2f module to the ODConv full-dimensional dynamic convolution, adaptively adjusts the convolution kernel according to different input image data, and specifically extracts the features of the pancake defects, which significantly enhances the feature extraction ability of the model, strengthens the learning ability of the network, and improves the recognition accuracy of the model. ODConv can be described as follows.

[0072] y=(α ω1 ⊙α f1 ⊙α c1 ⊙α s1 ⊙W1+…+α ωi ⊙α fi ⊙α ci ⊙α si ⊙W i +…+α ωn ⊙α fn ⊙α cn ⊙α sn ⊙W n )*x

[0073] Among them, y represents the output of ODConv full-dimensional dynamic convolution; x represents the input of ODConv full-dimensional dynamic convolution; α ωi Represents the convolution kernel W i The attention scalar α si Represents the i-th convolution kernel W i The attention scalar of the spatial position of ci Represents the i-th convolution kernel W i The attention scalar along the input channel dimension; a fi Represents the i-th convolution kernel W i The attention scalar along the output channel dimension; ⊙ represents the multiplication operation along different dimensions of the kernel space; n represents the total number of convolution kernels.

[0074] Furthermore, step S3 is specifically as follows: a small target detection layer is added to the neck network of the YOLOv8s network model, and the feature layer fused from top to bottom by the original YOLOv8s network is processed through the C2f-OD module and upsampling to form a deep semantic feature layer, including more low-order feature information. Next, the feature layer is fused with the features extracted by the third layer of the backbone network, and processed through an additional decoupling head to realize the detection of the 320*320 feature map, so that the model can detect targets containing more detailed low-order information and smaller targets.

[0075] Furthermore, step S4 is specifically as follows: use the inner-MPDIoU loss function as the bounding box regression loss to assist the border in calculating IoU, improve the learning ability of complex samples, and further improve the generalization ability of the model. As shown in the figure. The Inner-MPDIoU expression is as follows:

[0076]

[0077] in, Refers to the upper left corner and lower right corner of the predicted box and the real box respectively. Calculate the distance between corresponding points, h and w represent the height and width of the box;

[0078] IoU inner is the auxiliary bounding box IoU, IoU inner The definition is as follows:

[0079]

[0080] union=(w gt *h gt )*(ratio) 2 +(w*h)*(ratio) 2 -inter

[0081]

[0082] Among them, b gt and b are the target box and anchor box respectively; is the center point of the target frame; (x c ,y c ) is the center point of the anchor box; the width and height of the target box are w gt and h gt ; The width and height of the anchor box are w and h respectively; b l , b r , b t , b b , inter, and union have no actual mathematical meaning and can be understood as a parameter representing a polynomial; ratio is an adjustable factor, ratio∈[0.5,1.5]. When ratio<1, the auxiliary bounding box is smaller than the actual bounding box, and the effective range of regression is smaller than the IoU loss, but the absolute value of the gradient is larger than the gradient obtained by the IoU loss, which can accelerate the convergence of high IoU samples. When ratio>1, the auxiliary bounding box is larger than the actual box, which expands the effective range of regression and is beneficial to the regression of low IoU.

[0083] Further, the specific steps of step S5 are as follows:

[0084] A: Configure the network environment, Python version 3.9, deep learning framework Pytorch 2.1.0, and use CUDA 11.8 for training acceleration;

[0085] B: Set the initial learning rate to 0.01;

[0086] C: Set the number of images per batch input to 8;

[0087] D: Use the improved YOLOv8s model for training. The network model does not use pre-trained weights. After each cycle of training, the overall network loss is calculated and iterated until the mAP (mean Average Precision) indicator of the validation set is stable (the mAP indicator does not increase after 50 consecutive rounds of training). At this time, stop the improved YOLOv8s network training.

[0088] On the other hand, the present invention also discloses a surface defect detection system for dough based on YOLOv8 network, which comprises the following modules:

[0089] Image acquisition module: collects industrially produced dough image datasets;

[0090] Data enhancement module: enhances the collected images to expand the data set and improve the robustness of the model;

[0091] Dataset partitioning module: divide the data set into training set, validation set, and test set according to a certain ratio;

[0092] Model improvement module: The training set and validation set are input into the original YOLOv8 model for training to improve the performance and generalization ability of the model, and finally an optimized YOLOv8 model is obtained. During the training process, the data of the training set is used to optimize the parameters and learn the features of the model. At the same time, the hyperparameters of the model are adjusted through the evaluation indicators of the validation set to improve the prediction effect of the model on unknown data. After multiple rounds of iterative training and verification, the optimized model can more accurately identify targets and improve the accuracy and stability of detection;

[0093] Object detection module: used to input the test set into the improved YOLOv8 model to detect surface defects of the dough and obtain the detection results of surface defects of the dough.

[0094] In order to evaluate the detection performance of the model of the present invention, mean Average Precision (mAP), precision, recall and GFLOPs indicators were selected as evaluation indicators. The calculation formulas of each indicator are as follows:

[0095]

[0096] TP indicates the number of positive samples correctly predicted as positive samples by the model, FP indicates the number of negative samples incorrectly predicted as positive samples by the model, FN indicates the number of positive samples incorrectly predicted as negative samples by the model, and FLOPs indicates the number of floating-point operations that can be performed in one second. It is an important indicator for measuring model complexity and computing resource requirements.

[0097] In this example, in order to verify the effectiveness of the improved module, YOLOv8s is used as the baseline network, and the surface defect dataset of pancakes is used to design an ablation experiment for verification and comparison experiments. mAP@0.5, Precise, Recall, and FLOPs are used as evaluation indicators. The experimental results are shown in the following table.

[0098] Table 1: Evaluation index results of verification and comparison experiments

[0099] Small object detection layer C2f-OD Inner-MPDIoU P(%) R(%) mAP@0.5 FLOPs — — — 89.7 84.9 90.2 28.4 √ — — 91.0 85.9 92.0 36.6 — √ — 93.8 82.8 91.9 19.0 — — √ 90.4 85.0 90.9 28.6 √ √ √ 91.1 96.8 92.9 25.3

[0100] From the analysis of Table 1, it can be seen that after the network uses the small target detection layer, the average accuracy of each category is improved by 1.8%, the precision rate is improved by 1.3%, the recall rate is improved by 1%, and the FLOPs is improved by 8.2; after the model replaces the C2f module with the C2f-OD module, the average accuracy of each category is improved by 1.7%, the precision rate is improved by 4.1%, and the introduction of the Inner-MPDIoU loss function increases the average accuracy and precision rate of each category by 0.7%. At the same time, the introduction of the small target detection layer, the replacement of the C2f module with the C2f-OD module, and the replacement of C-IoU with Inner-MPDIoU, FLOPs has a certain decrease, but the average accuracy of each category is increased by 2.7%, the precision rate is increased by 1.4%, and the recall rate is increased by 11.9%, and the overall performance of the model is significantly improved.

[0101] The present invention adopts the above technical scheme, replaces the C2F module of the backbone network of the YOLOv8s model with the C2f-OD module, refines local features to enhance the feature extraction ability of the algorithm and reduces additional parameters; adds a small target detection layer in the neck network structure, contains more shallow semantic features, and constructs a detection head for detecting 320×320 feature maps, thereby improving the algorithm's detection ability for small target defects; replaces the YOLOv8s loss function with Inner-MPDIoU with higher convergence speed and positioning accuracy, making it more suitable for dough defect detection tasks. Compared with the prior art, the present invention has the following beneficial technical effects: (1) The C2F module of the YOLOV8s model backbone network is replaced with a C2f-OD module, local features are refined to enhance feature extraction capability and reduce additional parameters, thereby solving the problem of poor feature extraction effect due to the small area of ​​surface defects on the pancake; (2) a small target detection layer is added to the neck network structure, which contains more shallow semantic features, and a detection head for detecting 320×320 feature maps is constructed to improve the detection capability of small target defects, thereby enhancing the detection of different defect sizes and different defect densities on the pancake surface; (3) the present invention introduces Inner-MPDIoU with higher convergence speed and positioning accuracy, calculates IoU through auxiliary borders, and improves the generalization ability of the model at the same time, so that it can still accurately locate the surface defect image of the pancake in the presence of various noises.

[0102] Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of the present application is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians of the art without making creative work are within the scope of protection of the present application.

Claims

1. The improved method for detecting surface defects of dough based on YOLOv8 is characterized by: It includes the following steps: S1: Obtain a dough image through an image acquisition device and construct a dataset of dough surface defects with annotations; S2: Replace the C2f module of the YOLOV8s backbone network with the C2f-OD module; S3: Add a small object detection layer to the neck network of YOLOv8s; S4: Replace CIoU of YOLOv8s with Inner-MPDIoU to build an improved YOLOv8s model; S5: Train the improved YOLOv8s model to obtain the final noodle surface defect detection model, and finally use the noodle surface defect detection model to detect the noodle surface defect image to be detected.

2. The method for detecting surface defects of dough based on improved YOLOv8 according to claim 1, characterized in that: The specific steps of step S1 are as follows: Step S11: Acquire a dataset of surface defects of dough cakes; Step S12: Use labelImg to make a defect label; Step S13: Divide the produced defect labels into a training set, a validation set, and a test set according to a set ratio, and use the mosaic method to perform data enhancement to expand the overall data volume to prevent the trained model from overfitting.

3. The method for detecting surface defects of dough based on improved YOLOv8 according to claim 2, characterized in that: In step S11, the data set is annotated and divided into an image data set file and an image corresponding label file; In step S12, the labeled data set is classified into black spot category and burnt category; In step S13, the defect labels are divided into a training set, a validation set, and a test set in a ratio of 7:2:1; four pictures are randomly selected using the mosaic data enhancement scheme and spliced ​​by random scaling, random cropping, and random arrangement to generate new training samples, thereby improving the robustness and generalization ability of the model.

4. The method for detecting surface defects of dough based on improved YOLOv8 according to claim 1, characterized in that: The C2f-OD module in step S2 optimizes the ordinary convolution of the Bottleneck of the original C2f module to the ODConv full-dimensional dynamic convolution, adaptively adjusts the convolution kernel according to different input image data, and specifically extracts the features of pancake defects to enhance the feature extraction capability of the model; the expression of the ODConv full-dimensional dynamic convolution is as follows: y=(a ω1 ⊙a f1 ⊙a c1 ⊙a s1 ⊙W1+…+α ωi ⊙a fi ⊙a ci ⊙a si ⊙Wi i +…+a ωn ⊙a fn ⊙a cn ⊙a sn ⊙W n )*x Among them, y represents the output of ODConv full-dimensional dynamic convolution; x represents the input of ODConv full-dimensional dynamic convolution; α ωi Represents the convolution kernel W i The attention scalar α si Represents the i-th convolution kernel W i The attention scalar of the spatial position of ci Represents the i-th convolution kernel W i The attention scalar along the input channel dimension; a fi Represents the convolution kernel W i The attention scalar along the output channel dimension; ⊙ represents the multiplication operation along different dimensions of the kernel space; n represents the total number of convolution kernels.

5. The method for detecting surface defects of dough based on improved YOLOv8 according to claim 1, characterized in that: In step S3, a small target detection layer is added to the neck network of the YOLOv8s network model, and the feature layer fused from top to bottom by the original YOLOv8s network is formed into a deep semantic feature layer through the C2f-OD module and upsampling processing; then the deep semantic feature layer is fused with the features extracted by the third layer of the backbone network, and processed through an additional decoupling head to realize the detection of small target feature maps.

6. The method for detecting surface defects of dough based on improved YOLOv8 according to claim 1, characterized in that: In step S4, the inner-MPDIoU loss function is used as the bounding box regression loss to calculate the IoU with the auxiliary border; the inner-MPDIoU expression is as follows: in, and Respectively represent the points in the upper left corner and lower right corner of the prediction box; and Respectively represent the upper left and lower right points of the real box, Calculate the distance between corresponding points, h and w represent the height and width of the box; IoU inner is the auxiliary bounding box IoU, IoU inner The definition is as follows: Among them, b bt and b are the target box and anchor box respectively; is the center point of the target frame; (x c ,y c ) is the center point of the anchor box; the width and height of the target box are w gt and h gt ; The width and height of the anchor box are w and h respectively; ratio is an adjustable factor, ratio∈[0.5,1.5].

7. The method for detecting surface defects of dough based on improved YOLOv8 according to claim 1, characterized in that: The specific steps of step S5 are as follows: A: Configure the network environment, Python version 3.9, deep learning framework Pytorch 2.1.0, and use CUDA 11.8 for training acceleration; B: Set the initial learning rate to 0.01; C: Set the number of images per batch input to 8; D: Use the improved YOLOv8s model for training; the network model does not use pre-trained weights, and the overall network loss is calculated and iterated after each cycle of training. When the mAP index of the validation set does not increase after 50 consecutive rounds of training, the network training of the improved YOLOv8s model is stopped after the mAP index is judged to be stable.

8. A dough surface defect detection system based on improved YOLOv8, using the dough surface defect detection method based on improved YOLOv8 according to any one of claims 1 to 7, characterized in that: The system includes the following modules: Image acquisition module: collects industrially produced dough image datasets; Data enhancement module: enhances the collected images to expand the data set and improve the robustness of the model; Dataset partitioning module: divide the data set into training set, validation set, and test set according to a certain ratio; Model improvement module: The training set and validation set are input into the original YOLOv8 model for training to improve the performance and generalization ability of the model, and finally an optimized YOLOv8 model is obtained; during the training process, the data of the training set is used to optimize the model parameters and learn features, and the hyperparameters of the model are adjusted through the evaluation indicators of the validation set to improve the prediction effect of the model on unknown data; after multiple rounds of iterative training and verification, the model is optimized; Object detection module: used to input the test set into the improved YOLOv8 model to detect surface defects of the dough and obtain the detection results of surface defects of the dough.

Citation Information

Cited By

  • Ceramic tile surface flaw detection method and system based on improved YOLOv8n

    CN120525814A