Tile surface defect detection method and system based on improved YOLOv8n
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NANCHANG UNIV
- Filing Date
- 2025-04-29
- Publication Date
- 2026-08-07
AI Technical Summary
[0004]本发明实施例的目的是提供基于改进YOLOv8n的瓷砖表面瑕疵检测方法及系统,能够解决现有技术的YOLOv8n模型瓷砖表面瑕疵检测效率和鲁棒性较低的问题
[0015]与现有技术相比,本发明提供的基于改进YOLOv8n的瓷砖表面瑕疵检测方法的有益效果在于,第一、采用Adown层替换初始YOLOv8n模型主干网络的下采样层,通过动态权重分配、多分支融合和自适应采样,能够保留关键信息、增强多尺度感知能力;第二、在YOLOv8n模型内部的主干网络层中加入SPPF_LSKA层,既能降低计算复杂度和内存占用,又能有效捕捉长距离依赖关系,并且具备空间和通道适应性,显著提升模型在多尺度特征提取、计算效率和模型鲁棒性等方面的性能,使模型能更精准地识别出微小缺陷和复杂背景下的目标;第三、引入多个AFusion特征聚合层,通过动态融合多模态、多尺度特征,可显著提升模型的表达能力和任务适应性,解决了传统方法在复杂场景下的特征冗余、噪声敏感和计算瓶颈问题。通过以上方法对初始YOLOv8n模型进行改进,搭建YOLOv8n_ASM模型,其瑕疵检测能力显著优于YOLOv8n原始模型。
Smart Images

Figure CN120525814B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of neural network technology, specifically relating to a method and system for detecting surface defects in ceramic tiles based on an improved YOLOv8n. Background Technology
[0002] To address the issue of small tile defect sizes, researchers have proposed a detection head for large targets in YOLOv5. This head replaces the convolution in the C3 module with Ghost Convolution from the Ghost Module and introduces a CA block module. The improved model achieves a 1.8% improvement in mAP compared to the original YOLOv5s model, reduces the number of parameters by 48.7%, and reduces computation by 38.7%. Comparisons show that YOLOv5 is stronger in small target detection and real-time detection, outperforming earlier versions of YOLO. With continuous upgrades to YOLO, YOLOv8n, due to its advantage of "achieving near-server-level model detection accuracy with edge device-level resource consumption," is more suitable for specific applications in tile defect detection. YOLOv8n is particularly suitable for industrial scenarios in tile defect detection that are sensitive to small targets, have high real-time requirements, and face demanding deployment environments. Therefore, YOLOv8n has become a rising star in the field of object detection.
[0003] However, existing technologies have the following problems: First, tile defects can present a variety of complex situations, such as complex backgrounds and texture interference, lighting changes and reflections. For example, defects such as microcracks and pinholes on the tile surface are small. When defects occupy less than 10×10 pixels in the image, YOLOv8n's shallow feature extraction ability is weak, which can easily lead to missed detections or inaccurate localization. Second, similar defects (such as cracks and scratches) are easy to confuse in terms of classification confidence due to their similar shapes. Uneven lighting or flickering interference in industrial settings can cause fluctuations in image quality, thereby affecting the detection efficiency and robustness of the YOLOv8n model. Summary of the Invention
[0004] The purpose of this invention is to provide a method and system for detecting surface defects in ceramic tiles based on an improved YOLOv8n model, which can solve the problems of low efficiency and robustness in the detection of surface defects in ceramic tiles using the existing YOLOv8n model.
[0005] To solve the above-mentioned technical problems, the present invention is implemented as follows: In a first aspect, embodiments of the present invention provide a method for detecting surface defects of ceramic tiles based on an improved YOLOv8n model. The method includes: acquiring a target dataset of surface defects of ceramic tiles; improving the initial YOLOv8n model to build a YOLOv8n_ASM model; and processing the target dataset based on the YOLOv8n_ASM model to generate surface defect results of ceramic tiles.
[0006] As an optional embodiment of the first aspect of the present invention, the process of improving the initial YOLOv8n model includes: replacing the downsampling layer of the backbone network of the initial YOLOv8n model with an Adown layer, adding an SPPF_LSKA layer to the backbone network layer inside the YOLOv8n model, and adding multiple AFusion feature aggregation layers to the Neck layer connecting the YOLOv8n model backbone network and the detection head layer, wherein, in the backbone network layer, a C2f layer is connected between every two Adown layers.
[0007] As an optional embodiment of the first aspect of the present invention, the Neck layer includes: multiple C2f layers, multiple CBS layers, multiple upsampling layers and multiple AFusion feature aggregation layers, wherein the AFusion feature aggregation layer includes: a multi-branch feature adaptation layer, a dynamic receptive field fusion layer and a residual enhancement layer.
[0008] As an optional embodiment of the first aspect of the present invention, the multi-branch feature adaptation layer consists of an Adown layer, an upsampling layer and multiple CBS layers. The stride and width / height of the convolutional kernels in the multiple CBS layers are equal. The dynamic receptive field fusion layer includes multiple parallel-connected depthwise separable convolutional layers and a CBS layer. The size of the convolutional kernels in the multiple depthwise separable convolutional layers increases sequentially.
[0009] As an optional embodiment of the first aspect of the present invention, the workflow of the Adown layer is as follows: The input feature map is subjected to average pooling to obtain an average pooled feature map; the average pooled feature map is split along the channel dimension to obtain a first average pooled feature map and a second average pooled feature map, wherein the batch size, number of channels, width, and height of the first average pooled feature map are the same as those of the second average pooled feature map; the first average pooled feature map is input into a first convolutional layer for feature extraction to obtain a first downsampled feature map, wherein the number of channels of the first downsampled feature map is twice that of the first average pooled feature map, and the width and height are equal to those of the first average pooled feature map. The first average pooling feature map is processed by inputting half of the first average pooling feature map into a max pooling layer to obtain a second downsampled feature map. The number of channels, height, and width of the second downsampled feature map are all half of the first average pooling feature map. The second downsampled feature map is then input into a second convolutional layer for feature extraction to obtain a second downsampled feature map. The kernel size of the first convolutional layer is different from that of the second convolutional layer. The height and width of the second downsampled feature map are both half of the first average pooling feature map, and the batch size and number of channels are the same as those of the first average pooling feature map. Finally, the first downsampled feature map and the second downsampled feature map are concatenated by channel to obtain a fused feature map.
[0010] As an optional embodiment of the first aspect of the present invention, the process of generating the surface defect result of the tile includes: processing the input tile image according to the backbone network of the YOLOv8n_ASM model to generate multiple backbone feature maps; Based on the Neck layer, multiple backbone feature maps are processed to generate multiple output feature maps for the Neck layer; based on multiple YOLO classification heads in the detection head layer, the output feature maps of multiple Neck layers are classified to generate the surface defect results of the tiles.
[0011] As an optional embodiment of the first aspect of the present invention, the scale of each backbone feature map is different, and the scale of the output feature maps of the Neck layer is also different.
[0012] Secondly, embodiments of the present invention provide a ceramic tile surface defect detection system based on an improved YOLOv8n, the system comprising: The target dataset building module is used to obtain a target dataset of surface defects on tiles; The YOLOv8n_ASM module is used to improve the initial YOLOv8n model based on the Adown layer, SPPF_LSKA layer, and AFusion feature aggregation layer to build the YOLOv8n_ASM model. The tile surface result generation module is used to input the target dataset into the YOLOv8n_ASM model to obtain the tile surface defect results.
[0013] Thirdly, embodiments of the present invention provide an electronic device including a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the method as described in the first aspect.
[0014] Fourthly, embodiments of the present invention provide a readable storage medium on which a program or instructions are stored, and when the program or instructions are executed by a processor, the steps of the method as described in the first aspect are implemented.
[0015] Compared with existing technologies, the beneficial effects of the tile surface defect detection method based on improved YOLOv8n provided by this invention are as follows: First, by replacing the downsampling layer of the initial YOLOv8n model backbone network with an Adown layer, key information can be retained and multi-scale perception capabilities can be enhanced through dynamic weight allocation, multi-branch fusion, and adaptive sampling. Second, by adding an SPPF_LSKA layer to the backbone network layer inside the YOLOv8n model, computational complexity and memory consumption can be reduced, long-distance dependencies can be effectively captured, and spatial and channel adaptability can be provided, significantly improving the model's performance in multi-scale feature extraction, computational efficiency, and model robustness, enabling the model to more accurately identify small defects and targets in complex backgrounds. Third, by introducing multiple AFusion feature aggregation layers, multi-modal and multi-scale features can be dynamically fused, significantly improving the model's expressive power and task adaptability, and solving the problems of feature redundancy, noise sensitivity, and computational bottlenecks in complex scenarios of traditional methods. By using the methods described above, the initial YOLOv8n model was improved to build the YOLOv8n_ASM model, which has significantly better defect detection capabilities than the original YOLOv8n model. Attached Figure Description
[0016] Figure 1 This is a flowchart of a method for detecting surface defects in ceramic tiles based on an improved YOLOv8n, provided in the first embodiment of the present invention; Figure 2 This is an internal structure diagram of the YOLOv8n_ASM model provided in the first embodiment of the present invention; Figure 3 This is an internal structure diagram of the SPPF_LSKA layer provided in the first embodiment of the present invention; Figure 4 This is a structural diagram of the internal structure of the Adown layer provided in the first embodiment of the present invention; Figure 5 This is an internal structure diagram of the AFusion feature aggregation layer provided in the first embodiment of the present invention; Figure 6 This is an internal structure diagram of the AFMFN layer provided in the first embodiment of the present invention; Figure 7 This represents the PR curve generated by the YOLOv8n model provided in the first embodiment of the present invention; Figure 8 This represents the PR curve generated by the YOLOv8n_ASM model provided in the first embodiment of the present invention; Figure 9 This diagram illustrates the internal structure of a tile surface defect detection system based on an improved YOLOv8n, as provided in the second embodiment of the present invention. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] The terms "first," "second," etc., used in the specification and claims of this invention are used to distinguish similar objects and are not used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention can be implemented in orders other than those illustrated or described herein. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0019] The following description, in conjunction with the accompanying drawings, details the method and system for detecting surface defects of ceramic tiles based on the improved YOLOv8n provided by the present invention through specific embodiments and application scenarios.
[0020] Example 1 Please see Figure 1 The flowchart below shows the method for detecting surface defects of ceramic tiles based on the improved YOLOv8n proposed in the first embodiment of the present invention. The proposed method includes steps S1 to S3.
[0021] Step S1: Obtain the target dataset of surface defects on the tiles.
[0022] Specifically, the process of obtaining the target dataset of surface defects on tiles includes: Collect a dataset of tile surface defects in JSON format and convert it to the YOLO format required by the YOLOv8n model of this invention. Specifically, the target bounding box information in the original labels is normalized to the [0, 1] interval using the corresponding transformation and normalization methods. The corresponding data items obtained after the transformation are written into a TXT file in YOLO format, with each line corresponding to one target.
[0023] An offline image slicing method is employed, using a sliding window to slice the original image to obtain sub-images of suitable size for the model. Specifically, the sliding window size is set to 640×640, and the sliding window step size is 512px, ensuring a 128px overlap between adjacent slices to guarantee the integrity of the edge target boxes. If the sliced image is smaller than 640×640, edge padding is used to make it meet the input requirements. Through data augmentation techniques such as geometric transformation, color adjustment, and copy-paste, a high-quality tile defect dataset suitable for training the YOLOv8n model of this invention is obtained as the target dataset.
[0024] This invention effectively expands the defect categories with limited samples through data augmentation techniques such as geometric transformation, color adjustment, and copy-paste, alleviating the class imbalance problem. After obtaining the target dataset, to avoid any one category being too large or too small in the training or test sets, this invention performs stratified sampling according to category. Specifically, the dataset is first randomly shuffled based on image filenames, and then the data is proportionally allocated to the training and test sets to ensure a reasonable distribution between the training and test sets, thus ensuring the model's generalization ability during training.
[0025] Step S2: Improve the initial YOLOv8n model and build the YOLOv8n_ASM model.
[0026] Specifically, in the backbone network of the traditional YOLOv8n model, a C2f layer is introduced to replace the C3 layer of YOLOv5, further lightweighting the model while enhancing feature extraction capabilities. The neck region employs a Feature Pyramid Network (FPN) and a Path Aggregation Network (PAN), enabling the model to more efficiently fuse feature maps of different scales. The detection head utilizes a more modern decoupled head structure and an anchor-free method, significantly reducing the number of hyperparameters and simplifying the training process. Among the various versions of YOLOv8, YOLOv8n has a small number of parameters and low latency, making it suitable for embedded devices and mobile devices, thus ideal for industrial defect detection scenarios.
[0027] However, considering that the improved dataset still inevitably contains a large number of tiny defects, and that some tiles have diverse backgrounds and patterns, the YOLOv8n model suffers from both false positives and false negatives, making it difficult to achieve fast and accurate detection. Therefore, this invention improves the initial YOLOv8n model to build the proposed YOLOv8n_ASM model.
[0028] In the YOLOv8n_ASM model proposed in this invention, the process of improving the initial YOLOv8n model includes: replacing the downsampling layer of the backbone network of the initial YOLOv8n model with an Adown layer, adding an SPPF_LSKA layer to the backbone network layer inside the YOLOv8n model, and adding multiple AFusion feature aggregation layers to the Neck layer connecting the YOLOv8n model backbone network and the detection head layer. In the backbone network, a C2f layer is connected between every two Adown layers.
[0029] Specifically, the Neck layer includes: multiple C2f layers, multiple CBS layers, multiple upsampling layers, and multiple AFusion feature aggregation layers. The AFusion feature aggregation layers include: a multi-branch feature adaptation layer, a dynamic receptive field fusion layer, and a residual enhancement layer.
[0030] The multi-branch feature adaptation layer consists of an Adown layer, an upsampling layer, and multiple CBS layers. The stride and width / height of the convolutional kernels in the multiple CBS layers are equal. The dynamic receptive field fusion layer includes multiple parallel-connected depthwise separable convolutional layers and a CBS layer. The size of the convolutional kernels in the multiple depthwise separable convolutional layers increases sequentially.
[0031] The specific workflow of the Adown layer proposed in this invention is as follows: The input feature map is subjected to average pooling to obtain an average pooled feature map; the average pooled feature map is split along the channel dimension to obtain a first average pooled feature map and a second average pooled feature map, wherein the batch size, number of channels, width, and height of the first average pooled feature map are the same as those of the second average pooled feature map; the first average pooled feature map is input into the first convolutional layer for feature extraction to obtain a first downsampled feature map, wherein the number of channels of the first downsampled feature map is twice that of the first average pooled feature map, and the width and height are half that of the first average pooled feature map. The second average pooling feature map is input into a max pooling layer for max pooling processing to obtain a second downsampled feature map. The number of channels, height, and width of the second downsampled feature map are all half of those of the first average pooling feature map. The second downsampled feature map is then input into a second convolutional layer for feature extraction to obtain another second downsampled feature map. The kernel size of the first convolutional layer is different from that of the second convolutional layer. The height and width of the second downsampled feature map are both half of those of the first average pooling feature map, and the batch size and number of channels are the same as those of the first average pooling feature map. Finally, the first downsampled feature map and the second downsampled feature map are concatenated by channel to obtain a fused feature map. Figure 4 This is a structural diagram showing the internal structure of the Adown layer provided by the present invention.
[0032] Specifically, the process of performing average pooling on the input feature map to obtain the average-pooled feature map includes: inputting the input feature map into an average pooling layer for average pooling to obtain the average-pooled feature map. The average pooling layer uses a 2×2 pooling kernel with a stride of 1. The pooling kernel traverses each 2×2 region of the feature map, calculates the average value of all pixels within that region, and uses this average value as the value at the corresponding position in the average-pooled feature map. Average pooling allows for the initial integration of information in the spatial dimension between the input feature map and the average-pooled feature map; that is, the shape of the average-pooled feature map is the same as the input feature map, but the distribution and information representation of the features have changed.
[0033] Specifically, the process of splitting the average pooled feature map along the channel dimension to obtain the first and second average pooled feature maps includes: uniformly splitting the average pooled feature map into two parts along the channel dimension, denoted as X1 and X2 respectively. The number of channels in each part is C / 2, that is, the shape of X1 and X2 is B×C / 2×H×W. This splitting method allows for differentiated processing of different channel subsets to extract richer feature information.
[0034] Specifically, the process of inputting the first average pooling feature map into the first convolutional layer for feature extraction to obtain the first downsampled feature map includes: The first average pooling feature map is input into a specific processing path. First, the first average pooling feature map passes through a convolutional layer using a 3×3 kernel and a stride of 2. This convolutional layer downsamples the spatial dimensions of the first average pooling feature map, halving both its height and width. Setting the kernel size to 3×3 allows for local feature extraction from the input feature map, capturing texture, edges, and other information through convolution. After processing by this convolutional layer, the shape of X1 becomes X11 = B×C×H / 2×W / 2, achieving channel number adjustment and spatial dimension downsampling.
[0035] Specifically, the process of inputting the second downsampled feature map into the second convolutional layer for feature extraction includes: inputting the second downsampled feature map into a max pooling layer using a 3×3 kernel with a stride of 2. Max pooling selects the maximum value within each 3×3 local region as the output. This operation highlights salient features in the feature map while also achieving downsampling, halving the height and width of the feature map. After max pooling, the shape becomes B×C / 2×H / 2×W / 2. Next, it enters another convolutional layer using a 1×1 kernel. This layer primarily adjusts the number of channels, changing it from C / 2 to C. After processing by this convolutional layer, the shape of X2 becomes X21 = B×C×H / 2×W / 2.
[0036] Specifically, the process of concatenating the first and second downsampled feature maps to obtain a fused feature map includes: concatenating X11 and X21, which have been processed through the two different paths mentioned above, along the channel dimension. Since the shapes of X11 and X12 are both B×C×H / 2×W / 2, the number of channels after concatenation becomes 2C, and the final output feature map has the shape of B×2C×H / 2×W / 2.
[0037] In summary, this invention replaces the downsampling layer with the Adown layer, allowing the YOLOv8n_ASM model to fully leverage the advantages of Adown. This not only extracts richer and more representative feature information, enhancing target perception and feature representation, but also effectively balances computational cost and feature extraction performance through Adown channel splitting and path design advantages. The multi-scale feature fusion capability of the Adown layer enables the YOLOv8n_ASM model to better adapt to targets of different sizes and shapes, thereby improving the accuracy and robustness of target detection.
[0038] In addition, considering that the dataset used in this invention still inevitably contains a large number of tiny defects, and that some tiles have diverse backgrounds and patterns, this invention improves the initial YOLOv8n model and builds the YOLOv8n_ASM model, which can reduce the probability of missed detections and false detections and achieve fast and accurate detection results.
[0039] Step S3: Input the target dataset into the YOLOv8n_ASM model to obtain the surface defect results of the tiles.
[0040] The process of generating tile surface defect results in this invention is as follows: Based on the backbone network of the YOLOv8n_ASM model, the input tile image is processed to generate multiple backbone feature maps, each with a different scale; based on the Neck layer, the multiple backbone feature maps are processed to generate multiple Neck layer output feature maps, each with a different scale; based on multiple YOLO classification heads in the detection head layer, the output feature maps of the multiple Neck layers are classified to generate tile surface defect results.
[0041] Specifically, the small-scale feature map is input into the Adown layer for downsampling to obtain a sampled small-scale feature map (40×40 resolution). The height and width of the sampled small-scale feature map are equal to those of the medium-scale feature map. The large-scale feature map is upsampled using bilinear interpolation and then calibrated using the first CBS layer (1×1 convolution) to obtain a calibrated large-scale feature map. The sampled small-scale feature map, the calibrated large-scale feature map, and the medium-scale feature map are concatenated and input into a multi-scale perceptual unit composed of 5×5, 7×7, and 9×9 depthwise separable convolutions. Local details, component relationships, and global context information are captured through parallel computation. After element-wise addition and fusion, residual connections are performed to form a first fusion feature that combines detail preservation and semantic enhancement, thereby achieving feature fusion of medium-scale features with large and small-scale features. The first AFusion feature aggregation layer... The output of the first AFusion feature aggregation layer is input to the second CBS layer for downsampling, then concatenated with the large-scale feature map and input to the first C2f layer to obtain the second fusion feature, achieving feature fusion of small-scale features with medium and large-scale features. The output of the first AFusion feature aggregation layer is input to the second AFusion feature aggregation layer, and feature aggregation is performed with the outputs of the first and second C2f layers to obtain the second fusion feature, achieving feature fusion of medium-scale features. The output of the first AFusion feature aggregation layer is subjected to bilinear interpolation upsampling, concatenated with the small-scale feature map, and input to the first C2f layer to obtain the third fusion feature, achieving feature fusion of large-scale features with medium and small-scale features. Based on the first, second, and third fusion features, a multi-scale feature fusion map is obtained. The multi-scale feature fusion map is input to the head layer for classification processing to obtain the surface defect result of the tile. The sampled small-scale feature map and medium-scale feature map have equal height and width, and the first CBS layer has equal height and width.
[0042] Figure 5 This diagram illustrates the internal structure of the AFusion feature aggregation layer provided by the present invention. The AFusion feature aggregation layer of the present invention consists of the following three parts: 1) Multi-branch feature adaptation layer; The multi-branch feature adaptation layer is used to process input feature maps at multiple different levels to obtain output feature maps from multiple branches. The upsampling branch improves the feature map resolution through nearest neighbor interpolation and completes channel dimension alignment with 1×1 convolution (CBS layer); the sibling feature preservation branch uses lightweight 1×1 convolution (CBS layer) to maintain the original feature expressiveness; the downsampling branch uses the downsampling layer Adown to extract global contextual information of high-level features.
[0043] 2) Dynamic receptive field fusion layer; The dynamic receptive field fusion layer is used to concatenate the output feature maps of multiple branches to obtain a fused feature map. After the three-way feature concatenation, feature fusion is achieved through multi-scale deep convolutional layers. Four types of convolutional kernels, namely 5×5, 7×7, 9×9, and 11×11, are used in parallel to capture local details, component associations, and global context features, respectively. The multi-scale convolutional output features are added element by element to achieve cross-receptive field information fusion. The information interaction between channels is enhanced through 1×1 convolution (CBS layer) to form a unified feature representation.
[0044] 3) Residual reinforcement layer; The residual enhancement layer is used to perform residual connections on the fused feature map to obtain the aggregated feature map, forming a closed-loop structure of "feature extraction-fusion-compensation", which preserves the original spatial distribution characteristics and avoids information loss.
[0045] The AFusion feature aggregation layer proposed in this invention is an adaptive fusion unit designed to address the semantic information mismatch problem in multi-scale feature fusion. Its core structure achieves efficient interaction of cross-level features through multi-branch feature adaptation, dynamic receptive field fusion, and residual enhancement mechanisms. The AFusion feature aggregation layer, through the collaborative design of three branches, can fuse shallow localization information, mid-level semantic features, and high-level abstract expressions, improving the robustness of detecting targets with varying scales. Employing deep convolution and channel compression strategies, it significantly reduces computational resource consumption while maintaining fusion performance, meeting the deployment requirements of edge computing devices. Multi-scale convolutional kernel groups endow the layers with adaptive receptive field adjustment capabilities, automatically optimizing feature fusion weights according to target scale and scene complexity. Through a hierarchical feature interaction mechanism, it achieves adaptive fusion of cross-scale features, providing more discriminative multi-dimensional feature representations for detection tasks.
[0046] Please see Figure 2 This is a diagram of the internal structure of the YOLOv8n_ASM model proposed in this invention. The backbone network consists of two sequentially connected CBS layers (k=3, s=2), followed by three sets of C2f layers and one Adown layer, then another C2f layer and one SPPF_LSKA layer. The backbone network layers generate a small-scale feature map P3 (80...). ), mesoscale feature map P4 (40) 40) and large-scale feature map P5 (20) 20) P3, P4, and P5 are input into the AFMFN layer for processing. Then, the P3, P4, and P5 feature maps are input into the head layer for classification to generate the tile surface defect results. The head layer specifically includes three YOLO classification heads. Please see Figure 6 The diagram illustrates the internal structure of the AFMFN layer provided by this invention. Specifically, the AFMFN layer comprises two AFusion layers, two CBS layers (k=3, s=2), four C2f layers, two upsampling layers, and four fully connected (concat) operations. The P3 feature map has a high resolution and contains more detailed information, making it suitable for detecting smaller targets. The P4 feature map is at an intermediate level in terms of resolution and semantic information. The P5 feature map has a lower resolution but stronger semantic information, making it more suitable for detecting larger targets.
[0047] The SPPF_LSKA layer operates as follows: First, the input feature map undergoes multi-scale pooling and concatenation operations in the original SPPF layer to obtain a fused multi-scale feature map. Then, this feature map enters the LSKA layer. In the LSKA layer, the multi-scale feature map first undergoes a series of 1D convolution operations, including horizontal and vertical convolutions, to capture long-range dependencies and spatial information. Next, attention weights are generated through 1×1 convolutions to weight the input feature map, highlighting important features. Finally, the final feature map processed by LSKA is output. In the SPPF_LSKA layer, the input image is first pooled by the SPPF layer, and then the introduced LSKA layer processes the pooled feature maps at different scales. Through the separable convolution operation of LSKA, the spatial and channel dimensions of the feature map are adaptively adjusted, enhancing the feature representation of important regions and suppressing irrelevant information. Simultaneously, by leveraging its long-range dependency capture capability, it better integrates the relationships between multi-scale features, enabling the SPPF_LSKA layer to more accurately focus on the target object and improve the detection performance of targets at different scales. Figure 3 This diagram illustrates the internal structure of the SPPF_LSKA layer provided by this invention.
[0048] To verify the feasibility of the present invention, simulation verification was conducted. First, the performance data of the YOLOv8n_ASM model was verified. Table 1 shows the experimental parameter settings.
[0049] Table 1 Experimental Parameter Settings In object detection tasks, common metrics for evaluating model detection performance include: precision (P), recall (R), average precision (AP), and mean average precision (mAP). When calculating mAP, the IoU threshold is usually set to 0.5.
[0050] To verify the effectiveness of replacing the downsampling layer with Adown, comparative experiments were conducted using SPD-Conv to replace the downsampling layer, v7DS to replace the downsampling layer, and the original downsampling layer. The comparison results are shown in Table 2. Table 2 Comparative Experiment Table As shown in Table 2, compared to the original YOLOv8n model and models with added layers, the Adown layer provided by this invention improves precision, recall, and mAP@0.5, reaching 82.5%, 81%, and 85.4%, respectively. Meanwhile, its parameter count is 2.73M and its GFLOPS is 7.6G, which is lower than YOLOv8n and YOLOv8n_SPD-Conv models in terms of parameter count and computational cost, making it more lightweight. Therefore, considering both detection performance and resource consumption, this invention ultimately chooses the Adown layer to replace the downsampling layer of the YOLOv8n backbone network.
[0051] To more intuitively explore the optimization effect of each layer on the original YOLOv8n network structure, multiple ablation experiments were designed. Specific experimental setups and results are detailed in Table 3. Table 3 Ablation Experiment Table As can be seen from the ablation experiment table in Table 3, when only Adown, LSKA, or AFMFN is added, precision, recall, mAP@0.5, and mAP@[0.5:0.95] are all improved (especially AFMFN, which greatly improves precision). This shows that the introduction of each single layer has a positive effect on improving model performance. When the layers are combined in pairs, the indicators also increase and are generally higher than those of the single layers. When all three layers are introduced at the same time, the precision reaches 84.6%, the recall reaches 85.2%, mAP@0.5 reaches 86.8%, and mAP@[0.5:0.95] reaches 55.9%, which are all improved compared to the original model and the introduction of single layers or the combination of pairs. This further shows that Adown, LSKA, and AFMFN are not only effective individually, but also produce a synergistic effect when used in combination.
[0052] The YOLOv8n_ASM model achieved significant improvements in the mean precision (AP) for various defect detection methods: AP for edge anomalies increased by 3.3%, corner anomalies by 3.5%, white dot defects by 4.6%, light-colored patch defects by 2.8%, and dark-colored dot defects by 4.2%. Although there was a slight decrease in AP for aperture defect detection, overall, the YOLOv8n_ASM model represents a substantial improvement over the YOLOv8n model in terms of accuracy for detecting surface defects in tiles. Please refer to the comparison chart. Figure 7 and Figure 8 As shown.
[0053] Example 2 Please see Figure 9 The diagram shows a schematic of a tile surface defect detection system based on an improved YOLOv8n proposed in the second embodiment of the present invention. The system includes: The target dataset creation module 100 is used to obtain the target dataset of surface defects in tiles. The model building module 200 is used to improve the initial YOLOv8n model based on the preset Adown layer and Neck layer to build the YOLOv8n_ASM model; The tile surface defect result generation module 300 is used to input the target dataset into the YOLOv8n_ASM model to obtain the tile surface defect results.
[0054] The beneficial effects of the improved YOLOv8n-based tile surface defect detection system provided by this invention are as follows: First, through the target dataset establishment module 100, the data labels of the original general tile surface defect dataset are converted from JSON format to YOLO format. In particular, the target box information in the original labels is normalized to the [0, 1] interval through corresponding conversion and normalization methods. The corresponding data items obtained after conversion are written into a TXT file in YOLO format, which can improve the generalization ability and recognition efficiency of model training. Second, through the model building module 200, the YOLOv8n_ASM model of this invention is built, which can solve the problem of background and pattern diversity in some tiles and reduce the probability of false negatives and false positives in the YOLOv8n_ASM model.
[0055] The tile surface defect detection system based on the improved YOLOv8n in this embodiment of the invention can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network-attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This embodiment of the invention does not impose specific limitations.
[0056] The tile surface defect detection system based on the improved YOLOv8n in this embodiment of the invention can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this embodiment of the invention does not impose specific limitations.
[0057] The tile surface defect detection system based on the improved YOLOv8n provided in this embodiment of the invention can achieve... Figures 1 to 8 The various processes implemented in the method embodiment based on the improved YOLOv8n tile surface defect detection method will not be described again here to avoid repetition.
[0058] Optionally, embodiments of the present invention also provide an electronic device, including a processor, a memory, and a program or instructions stored in the memory and executable on the processor. When the program or instructions are executed by the processor, they implement the various processes of the above-described embodiments of the tile surface defect detection method based on the improved YOLOv8n, and can achieve the same technical effect. To avoid repetition, they will not be described again here.
[0059] This invention also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described embodiment of the tile surface defect detection method based on the improved YOLOv8n, and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0060] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0061] It should be noted that, in this invention, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this invention is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0062] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods of the various embodiments of the present invention.
[0063] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of the present invention.
Claims
1. A method for detecting surface defects in ceramic tiles based on an improved YOLOv8n, characterized in that, include: Obtain the target dataset of surface defects on tiles; The initial YOLOv8n model is improved to build the YOLOv8n_ASM model. The improvement process includes: replacing the downsampling layer of the initial YOLOv8n model backbone network with an Adown layer; adding an SPPF_LSKA layer to the backbone network layer within the YOLOv8n model; constructing an AFMFN layer in the Neck layer connecting the YOLOv8n model backbone network and the detection head layer. The AFMFN layer includes a first AFusion feature aggregation layer and a second AFusion feature aggregation layer connected in sequence. The small-scale feature map P3, medium-scale feature map P4, and large-scale feature map P5 output from the backbone network are input to the first AFusion feature aggregation layer for cross-scale fusion to obtain a first fused feature. The first fused feature is downsampled and concatenated with the large-scale feature map P5 before being input to the C2f layer to generate a second fused feature. The first fused feature is upsampled and concatenated with the small-scale feature map P3 before being input to the C2f layer. The f-layer generates the third fusion feature. The second AFusion feature aggregation layer performs secondary feature aggregation on the second and third fusion features to obtain a multi-scale fusion feature map, which is then input into the detection head layer. The AFusion feature aggregation layer includes a multi-branch feature adaptation layer, a dynamic receptive field fusion layer, and a residual enhancement layer. The multi-branch feature adaptation layer consists of an Adown layer, an upsampling layer, and multiple CBS layers. The stride and width / height of the convolutional kernels in the multiple CBS layers are equal. The dynamic receptive field fusion layer includes multiple parallel-connected depthwise separable convolutional layers and a CBS layer. The sizes of the convolutional kernels in the multiple depthwise separable convolutional layers are 5×5, 7×7, 9×9, and 11×11, respectively. The multi-branch feature adaptation layer is used to align the spatial dimensions of the input features at different scales. The dynamic receptive field fusion layer is used to extract multi-scale contextual features. The residual enhancement layer is used to perform residual connections on the fusion feature map output by the dynamic receptive field fusion layer to preserve the original spatial distribution characteristics. Based on the YOLOv8n_ASM model, the target dataset is processed to generate results of surface defects in the tiles.
2. The method for detecting surface defects of ceramic tiles based on the improved YOLOv8n according to claim 1, characterized in that, In the backbone network layer, a C2f layer is connected between every two Adown layers.
3. The method for detecting surface defects of ceramic tiles based on the improved YOLOv8n according to claim 2, characterized in that, The Neck layer includes: multiple C2f layers, multiple CBS layers, multiple upsampling layers, and multiple AFusion feature aggregation layers.
4. The method for detecting surface defects of ceramic tiles based on the improved YOLOv8n according to claim 3, characterized in that, The workflow of the Adown layer is as follows: The input feature map is subjected to average pooling to obtain the average pooled feature map. The average pooled feature map is split along the channel dimension to obtain a first average pooled feature map and a second average pooled feature map. The batch size, number of channels, width and height of the first average pooled feature map are the same as those of the second average pooled feature map. The first average pooling feature map is input into the first convolutional layer for feature extraction to obtain the first downsampled feature map. The number of channels of the first downsampled feature map is twice that of the first average pooling feature map, and the width and height are half of the first average pooling feature map. The second average pooling feature map is input into the max pooling layer for max pooling processing to obtain the second downsampled feature map. The number of channels, height and width of the second downsampled feature map are all half of the first average pooling feature map. The second downsampled feature map is input into the second convolutional layer for feature extraction to obtain the second downsampled feature map. The kernel size of the first convolutional layer is different from that of the second convolutional layer. The height and width of the second downsampled feature map are both half of the first average pooling feature map. The batch size and number of channels are the same as those of the first average pooling feature map. The first downsampled feature map and the second downsampled feature map are concatenated by channels to obtain a fused feature map.
5. The method for detecting surface defects of ceramic tiles based on the improved YOLOv8n according to claim 1, characterized in that, The process of generating the result of surface defects in tiles includes: Based on the backbone network of the YOLOv8n_ASM model, the input tile image is processed to generate multiple backbone feature maps; Based on the Neck layer, the multiple backbone feature maps are processed to generate multiple output feature maps of the Neck layer; Based on multiple YOLO classification heads within the detection head layer, the output feature maps of multiple Neck layers are classified to generate results for surface defects in the tiles.
6. The method for detecting surface defects of ceramic tiles based on the improved YOLOv8n according to claim 5, characterized in that, Each of the backbone feature maps has a different scale, and the output feature maps of the Neck layer also have different scales.
7. A ceramic tile surface defect detection system based on an improved YOLOv8n, characterized in that, The system includes: The target dataset creation module is used to obtain a target dataset of surface defects on tiles. The model building module is used to improve the initial YOLOv8n model based on preset Adown and Neck layers to build the YOLOv8n_ASM model. The improvement process includes: replacing the downsampling layer of the initial YOLOv8n model backbone network with an Adown layer; adding an SPPF_LSKA layer to the backbone network layer within the YOLOv8n model; constructing an AFMFN layer in the Neck layer connecting the YOLOv8n model backbone network and the detection head layer; the AFMFN layer comprising a first AFusion feature aggregation layer and a second AFusion feature aggregation layer connected in sequence; inputting the small-scale feature map P3, medium-scale feature map P4, and large-scale feature map P5 output from the backbone network to the first AFusion feature aggregation layer for cross-scale fusion to obtain a first fused feature; downsampling the first fused feature and concatenating it with the large-scale feature map P5 before inputting it into the C2f layer to generate a second fused feature; and upsampling the first fused feature and concatenating it with the small-scale feature map P5. After channel concatenation in P3, the data is input into the C2f layer to generate the third fusion feature. The second AFusion feature aggregation layer performs secondary feature aggregation on the second and third fusion features to obtain a multi-scale fusion feature map, which is then input into the detection head layer. The AFusion feature aggregation layer includes a multi-branch feature adaptation layer, a dynamic receptive field fusion layer, and a residual enhancement layer. The multi-branch feature adaptation layer consists of an Adown layer, an upsampling layer, and multiple CBS layers. The stride and width / height of the convolutional kernels in the multiple CBS layers are equal. The dynamic receptive field fusion layer includes multiple parallel-connected depthwise separable convolutional layers and a CBS layer. The sizes of the convolutional kernels in the multiple depthwise separable convolutional layers are 5×5, 7×7, 9×9, and 11×11, respectively. The multi-branch feature adaptation layer is used to align the spatial dimensions of the input features at different scales. The dynamic receptive field fusion layer is used to extract multi-scale contextual features. The residual enhancement layer is used to perform residual connections on the fusion feature map output by the dynamic receptive field fusion layer to preserve the original spatial distribution characteristics. The tile surface defect result generation module is used to process the target dataset based on the YOLOv8n_ASM model to generate tile surface defect results.
8. An electronic device, characterized in that, It includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the tile surface defect detection method based on any one of claims 1-6.
9. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the tile surface defect detection method based on any one of claims 1-6.
Citation Information
Patent Citations
Complex scene pavement marker line detection method based on multi-module adaptive fusion
CN120853128A