A method for ancient book defect detection based on improved YOLOv8

By introducing attention mechanism and sliding window detection strategy in the YOLOv8 model, the efficiency and accuracy of traditional ancient book defect detection methods in the coexistence of complex backgrounds and multiple defects is solved, and more efficient and accurate ancient book defect detection is achieved.

CN119763083APending Publication Date: 2025-04-04Shanxi Taihang Laboratory Co., Ltd.
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411813497.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

Traditional ancient book defect detection methods are inefficient and cannot guarantee accuracy. Especially in the face of complex backgrounds and multiple types of defects coexist, it is difficult to effectively deal with small defects in ancient book images.

Method used

Based on the improved YOLOv8's ancient book defect detection method, an attention mechanism is introduced and combined with the sliding window detection strategy is improved to improve the performance of the detection model in detecting small defects and processing high-resolution ancient book images.

Benefits of technology

The improved YOLOv8 model shows stronger robustness when detecting subtle defects and complex background images, and can detect defects in ancient books more efficiently and accurately, especially when dealing with small defects such as creases and debris.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119763083A_ABST
    Figure CN119763083A_ABST
Patent Text Reader

Abstract

The invention discloses an ancient book defect detection method based on improved YOLOv8, which relates to the field of image processing and target detection, including: collecting images containing six types of ancient book defects and annotating them to obtain a special data set for ancient book defects; adding an attention mechanism module to a YOLOv8 model to obtain an improved YOLOv8 model; using the special data set for ancient book defects, training and verifying the improved YOLOv8 model to obtain an ancient book defect detection model; obtaining an ancient book image to be detected and performing sliding window division to obtain a number of windows of fixed size, using the ancient book defect detection model to detect defects in each of the windows, merging the detection results of each window into the ancient book image to be detected, and eliminating redundant detection results in the ancient book image to be detected to obtain a final detection result. The improved YOLOv8 model of the invention can efficiently and accurately detect defects in ancient books.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing and target detection, and more specifically to an ancient book defect detection method based on improved YOLOv8. Background Art

[0002] In the process of cultural heritage protection and digitization of ancient books and documents, the preservation and restoration of ancient books is an extremely important link. As important cultural and historical carriers, ancient books and documents are prone to defects such as incompleteness, stains, folds, repairs, stamps and ink marks due to their long-term exposure to adverse environments. These defects not only affect the preservation and restoration of ancient books, but also bring great challenges to their digitization.

[0003] However, traditional ancient book defect detection mainly relies on manual experience. Due to the large number of ancient books and the variety of defect types, manual detection is inefficient and its accuracy cannot be guaranteed. Existing image processing technologies, such as edge detection and threshold segmentation, can detect defects in images to a certain extent, but in the face of complex ancient book backgrounds and the coexistence of multiple types of defects, these traditional methods often cannot effectively handle them, especially small defects in ancient book images are easily ignored or misclassified in complex backgrounds.

[0004] Therefore, how to detect defects in ancient books more efficiently and accurately is a problem that technical personnel in this field need to solve urgently. Summary of the invention

[0005] In view of this, the present invention provides an ancient book defect detection method based on improved YOLOv8, which improves the performance of the detection model in detecting small defects and processing high-resolution ancient book images by introducing an attention mechanism and combining it with a sliding window detection strategy.

[0006] In order to achieve the above object, the present invention provides the following technical solutions:

[0007] The present invention discloses an ancient book defect detection method based on improved YOLOv8, and the specific steps are as follows:

[0008] Collect and annotate images containing six types of ancient book defects to obtain a special dataset for ancient book defects;

[0009] Add an attention mechanism module to the YOLOv8 model to obtain an improved YOLOv8 model;

[0010] Using the ancient book defect-specific dataset, the improved YOLOv8 model is trained and verified to obtain an ancient book defect detection model;

[0011] The image of the ancient book to be detected is obtained and divided into sliding windows to obtain a number of windows of fixed sizes. The defects in each of the windows are detected using the ancient book defect detection model. The detection results of each window are merged into the image of the ancient book to be detected, and the redundant detection results in the image of the ancient book to be detected are eliminated to obtain the final detection result.

[0012] Furthermore, the YOLOv8 model includes three parts: a backbone network, a neck network and a head network; the backbone network extracts features of the input image, the neck network performs multi-scale feature fusion on the features extracted by the backbone network, and the head network outputs image recognition results according to the features fused by the neck network;

[0013] The backbone network is composed of two layers of CBS modules, C2f modules, CBS modules, C2f modules, CBS modules, C2f modules, CBS modules, C2f modules, and SPPF modules connected in sequence;

[0014] The neck network is composed of two layers of C2f modules, CBS modules, C2f modules, CBS modules, and C2f modules connected in sequence;

[0015] The head network consists of three independent Detect modules;

[0016] The third layer CBS module in the backbone network is also connected to the second layer C2f module of the neck network, and the result is input into the C2f module; the output of the SPPF module is spliced ​​with the output of the third layer C2f module in the backbone network after upsampling, and input into the first layer C2f module of the neck network; the output of the SPPF module is also spliced ​​with the output of the second layer CBS module of the neck network, and input into the fourth layer C2f module of the neck network;

[0017] The second, third and fourth C2f modules of the neck network are also connected to the Detect module corresponding to the head network. The Detect module maps the high-dimensional features input by the C2f module to obtain the final detection result.

[0018] Furthermore, the CBS module includes a convolutional layer, a batch normalization layer and an activation function connected in sequence; the activation function is: f(x)=x·σ(x); wherein f(x) represents the activation function, x represents the input, and σ(x) is the Sigmoid function;

[0019] The SPPF module includes a CBS module, three pooling layers, and a CBS module connected in sequence; by applying pooling windows of different sizes on the input feature map, multi-scale features are extracted and spliced ​​into a feature map that integrates multi-scale information.

[0020] Further, the adding of the attention mechanism module comprises: adding the attention mechanism module before the multi-scale features extracted by the backbone network are output to the neck network;

[0021] Alternatively, an attention mechanism module is added to the C2f module of the backbone network.

[0022] Furthermore, an attention mechanism module is added before the multi-scale features extracted by the backbone network are output to the neck network. Specifically, three independent attention mechanism modules are added to the channels where the third-layer CBS module, the third-layer C2f module and the SPPF module of the backbone network output to the neck network.

[0023] Furthermore, the attention mechanism module is added to the C2f module of the backbone network, specifically: the attention mechanism module is inserted into the C2f module to obtain the AttC2f module, and the first layer, the second layer, and the third layer C2f modules in the backbone network are replaced by the AttC2f module;

[0024] The AttC2f module includes a CBS module, a Split module, several Bottleneck modules, a Concat module, an attention mechanism module, and a CBS module connected in sequence.

[0025] Furthermore, the attention mechanism module is a CBAM module, a SEBlock module or an ECA module.

[0026] Furthermore, the CBAM module includes a channel attention module and a spatial attention module; the input features in the CBAM module are processed by the channel attention module and then dot-producted with the original input features as the output of the channel attention module; the output of the channel attention module is processed by the spatial attention module and then dot-producted with the original output of the channel attention module to obtain the final output of the CBAM module.

[0027] Furthermore, in the SEBlock module, a global average pooling operation is first performed on the input feature map; then an excitation operation is performed to generate the weight of each channel through a fully connected layer; finally, a multiplication operation is performed to multiply the weight vector obtained after the excitation operation by the original input feature map channel by channel to obtain a re-weighted feature map.

[0028] Furthermore, in the ECA module, a global average pooling operation is first performed on the input feature map; then a convolution operation is performed using a convolution layer; finally, after a nonlinear transformation is performed using an activation function, a dot product operation is performed with the original input feature map to obtain the final output.

[0029] Through the above technical solutions, it can be known that compared with the prior art, the present invention discloses a method for detecting defects in ancient books based on improved YOLOv8. The introduced attention mechanism effectively enhances the model's ability to focus on key information and reduces missed detections and false detections. Through the sliding window detection strategy, the model can still maintain a relatively fast detection speed when processing high-resolution images. The improved YOLOv8 model has higher detection accuracy, especially when detecting subtle defects and complex background images, showing stronger robustness; it can cope with the complex background and coexistence of multiple defects in ancient book images, especially when dealing with small defects such as creases and stains, the effect is particularly significant, thereby more efficiently and accurately detecting defects in ancient books. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0031] Figure 1 It is a schematic diagram of the overall process of an embodiment of the present invention.

[0032] Figure 2 Schematic diagram of the network structure of the YOLOv8 model according to an embodiment of the present invention.

[0033] Figure 3 This is a schematic diagram of the network structure of the first improved YOLOv8 model according to an embodiment of the present invention.

[0034] Figure 4 This is a schematic diagram of the network structure of the second improved YOLOv8 model according to an embodiment of the present invention.

[0035] Figure 5 Schematic diagram of the AttC2f module structure of an embodiment of the present invention.

[0036] Figure 6 The figure is a schematic diagram of the working principle of the CBAM module according to an embodiment of the present invention.

[0037] Figure 7 Schematic diagram of the working principle of the SEBlock module according to an embodiment of the present invention.

[0038] Figure 8 Schematic diagram of the working principle of the ECA module according to an embodiment of the present invention. DETAILED DESCRIPTION

[0039] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0040] The embodiment of the present invention discloses a method for detecting defects in ancient books based on improved YOLOv8. Figure 1 As shown, the specific steps are as follows:

[0041] Collect and annotate images containing six types of ancient book defects to obtain a special dataset for ancient book defects;

[0042] Add an attention mechanism module to the YOLOv8 model to obtain an improved YOLOv8 model;

[0043] Using the special dataset of ancient book defects, the improved YOLOv8 model was trained and verified to obtain the ancient book defect detection model;

[0044] The image of the ancient book to be detected is obtained and divided into sliding windows to obtain several windows of fixed sizes. The defects in each window are detected using the ancient book defect detection model. The detection results of each window are merged into the image of the ancient book to be detected, and the redundant detection results in the image of the ancient book to be detected are eliminated to obtain the final detection result.

[0045] Specifically, ancient book images usually have high resolution, and directly scaling them to the input size required by YOLOv8 (such as 640×640 pixels) may result in loss of detail information. To avoid this, the present invention introduces a sliding window detection strategy, which divides the high-resolution image into multiple 640×640 small windows and performs detection separately to ensure that the model can capture every small defect; at the same time, a certain overlap is maintained between the windows to ensure that defects across windows are not missed, thereby further improving the accuracy of ancient book defect detection based on improved YOLOv8.

[0046] In a specific embodiment, Figure 2 As shown in the figure, the YOLOv8 model consists of three parts: backbone network, neck network and head network; the backbone network extracts features from the input image, the neck network performs multi-scale feature fusion on the features extracted by the backbone network, and the head network outputs the image recognition result based on the features fused by the neck network;

[0047] The backbone network is composed of two layers of CBS modules, C2f modules, CBS modules, C2f modules, CBS modules, C2f modules, CBS modules, C2f modules, CBS modules, C2f modules, and SPPF modules connected in sequence;

[0048] The neck network is composed of two layers of C2f module, CBS module, C2f module, CBS module, and C2f module connected in sequence;

[0049] The head network consists of three independent Detect modules;

[0050] The third layer CBS module in the backbone network is also connected to the second layer C2f module in the neck network, and the result is input into the C2f module; the output of the SPPF module is spliced ​​with the output of the third layer C2f module in the backbone network after upsampling, and input into the first layer C2f module of the neck network; the output of the SPPF module is also spliced ​​with the output of the second layer CBS module in the neck network, and input into the fourth layer C2f module of the neck network;

[0051] The second, third and fourth C2f modules of the neck network are also connected to the Detect modules corresponding to the head network. The Detect modules map the high-dimensional features input by the C2f modules to obtain the final detection results.

[0052] In a specific embodiment, the CBS module includes a convolutional layer, a batch normalization layer and an activation function connected in sequence; the activation function is: f(x)=x·σ(x); wherein f(x) represents the activation function, x represents the input, and σ(x) is the Sigmoid function;

[0053] The SPPF module includes a CBS module, three pooling layers, and a CBS module connected in sequence; by applying pooling windows of different sizes on the input feature map, multi-scale features are extracted and spliced ​​into a feature map that integrates multi-scale information.

[0054] Specifically, in YOLOv8, CBS is a combined module that combines convolutional layers (Conv2d), batch normalization layers (BatchNorm2d), and SiLU activation functions. First, the convolutional layer is used to extract feature maps from the input data and learn local patterns in space; then, BatchNorm2d batch normalizes the convolution results, standardizes the input features of each channel, reduces internal covariance shift, helps accelerate training and improves the generalization ability of the model. Finally, the SiLU activation function is applied to the normalized feature map to nonlinearly map the data to the new space. The SiLU function achieves smoother activation than the traditional ReLU by applying the Sigmoid function to the input and multiplying it with the input itself, which helps improve the gradient propagation of deep networks. Overall, the CBS module plays the role of feature extraction and nonlinear transformation in YOLOv8, enhancing the learning ability of the network.

[0055] SPPF is an efficient spatial pyramid pooling module in YOLOv8. It improves the multi-scale perception ability of the model by performing pooling operations at different scales. SPPF mainly extracts multi-scale features by applying pooling windows of different sizes (such as 1×1, 5×5, 9×9, etc.) on the input feature map, and splices them together to form a feature map that integrates information of multiple scales. This method can enhance the model's detection ability for objects of different sizes, especially in scenes with large differences in target scales. Compared with traditional spatial pyramid pooling, SPPF reduces the amount of calculation through efficient implementation methods and can quickly integrate multi-scale information, so it can improve detection efficiency without sacrificing performance. SPPF in YOLOv8 helps the model better capture the features of targets of different sizes and improves the expressiveness and robustness of the network.

[0056] Conv2d is a basic operation in convolutional neural networks, responsible for performing convolution calculations on input images or feature maps. In YOLOv8, Conv2d is used to extract local spatial features from the original image. The convolution layer slides the convolution kernel on the input feature map, calculates the weighted sum of each local area, and generates a new feature map. The main function of the convolution operation is to capture low-level features in the image, such as edges, corners, and textures. The size of the convolution kernel (such as 3×3 or 5×5) determines the range of the receptive field, while the stride and padding affect the size of the output feature map. The Conv2d operation in YOLOv8 is widely used at all levels of the network, both for feature extraction and for dimensionality reduction and enhanced feature representation capabilities. Through multiple convolutions, the network can gradually extract more and more complex features and pass them to subsequent modules for processing.

[0057] BatchNorm2d is a normalization technique used in YOLOv8 to accelerate training and improve the stability of the model. Its basic operation is to standardize the input of each channel so that the output of each channel has zero mean and unit variance. BatchNorm2d calculates the mean and variance of each channel in each batch, and then uses these statistics to normalize the input, thereby reducing the internal covariance shift during training, allowing the model to converge faster during training, while also reducing the difficulty of hyperparameter adjustment; the normalized feature map is usually multiplied by a scaling factor (gamma) and an offset term (beta) is added to restore the representation ability of the data. BatchNorm2d is widely used in YOLOv8 after convolution operations to help maintain the stability of each layer's output and effectively avoid the problem of gradient vanishing or gradient exploding.

[0058] SiLU (SigmoidLinearUnit) is the activation function used in YOLOv8. The characteristic of SiLU activation function is to multiply the input value with its corresponding Sigmoid function value to generate a smooth nonlinear transformation. Compared with the traditional ReLU activation function, SiLU can provide better performance in some tasks, especially in deep neural networks. The smoothness and continuity of SiLU activation function help reduce the gradient vanishing problem and improve the propagation effect of gradient. It is usually used in feature extraction modules in YOLOv8, such as CBS and convolutional layers, to help the network better model complex nonlinear relationships and improve the network's expression ability and training stability.

[0059] The Detect module is the last module in YOLOv8, which is responsible for mapping the high-dimensional features extracted from the network to the final target detection results. The Detect module performs bounding box regression, target category prediction, and confidence prediction based on the feature map of the last layer of the network. Specifically, the Detect module predicts multiple candidate boxes at each position, calculates the center coordinates, width, height, and target category and confidence corresponding to each box. The confidence prediction indicates whether the target exists in the box and the accuracy of the target, while the category prediction specifies the specific category of the target in the box. In YOLOv8, the Detect module generates the final result of target detection through a specific output format (usually four coordinates of each box and a category probability distribution). The detection results are removed through post-processing steps such as non-maximum suppression (NMS) to remove overlapping redundant boxes, and finally output accurate detection results. The Detect module is one of the core modules of YOLOv8, which directly affects the model's target detection accuracy and efficiency.

[0060] In a specific embodiment, adding an attention mechanism module includes: adding an attention mechanism module before the multi-scale features extracted by the backbone network are output to the neck network to obtain a first improved YOLOv8 model;

[0061] Alternatively, an attention mechanism module is added to the C2f module of the backbone network to obtain the second improved YOLOv8 model.

[0062] In a specific embodiment, an attention mechanism module is added before the multi-scale features extracted by the backbone network are output to the neck network. Specifically, three independent attention mechanism modules are added to the channels where the third-layer CBS module, the third-layer C2f module and the SPPF module of the backbone network output to the neck network.

[0063] Add an attention mechanism module to the C2f module of the backbone network. Specifically, insert the attention mechanism module into the C2f module to obtain the AttC2f module, and replace the first, second, and third layer C2f modules in the backbone network with the AttC2f modules.

[0064] Specifically, in the first improvement, after the backbone network (Backbone) of YOLOv8 is output, that is, before the multi-scale features extracted by the C2f module are sent to the neck network (Neck), an attention mechanism module (CBAM, SEBlock or ECA) is added. The position of the attention mechanism module is as follows: Figure 3 In the second improvement, the three attention mechanisms are inserted into the C2f structure in Backbone. The location of the attention mechanism module is as follows Figure 4 As shown in the figure. The C2f module is the core unit of Backbone, which extracts local and global features through parallel gradient flow branches. However, after the Concat operation, the feature branches in C2f simply stack the features of each branch, lacking the weight distribution of the importance of different features, which may cause redundant information to interfere with network performance. Inserting the attention mechanism after the Concat operation of C2f can dynamically weight the stacked features, allowing the network to automatically focus on important local and global information, and further refine the feature extraction process.

[0065] like Figure 5 As shown in the figure, the AttC2f module includes a CBS module, a Split module, several Bottleneck modules, a Concat module, an attention mechanism module, and a CBS module connected in sequence. In the YOLOv8 network structure, the C2F module (CSPBottleneckwith 2Convolutions) is a key component used to achieve cross-stage partial fusion; the input feature map is first processed by a convolution layer (usually 1x1 convolution), and the number of channels of the output feature map is doubled. The purpose of this step is to increase the feature expression ability of the model. Next are multiple Bottleneck modules for step-by-step feature extraction. Each Bottleneck module contains multiple convolution layers, and you can configure whether to use Shortcut connections (residual connections). The Shortcut part avoids gradient disappearance, improves the flow of information, and reduces computational complexity through jump connections, thereby improving the training and reasoning efficiency of the model. The output feature maps of multiple Bottleneck modules are concatenated with the original feature map and passed through the attention mechanism module; finally, the concatenated feature map is compressed again through a convolution to output the feature map of the target number of channels.

[0066] In a specific embodiment, the attention mechanism module is a CBAM module, a SEBlock module or an ECA module.

[0067] In a specific embodiment, Figure 6 As shown in the figure, the CBAM module includes a channel attention module and a spatial attention module; the input features in the CBAM module are processed by the channel attention module and then dot-producted with the original input features as the output of the channel attention module; the output of the channel attention module is processed by the spatial attention module and then dot-producted with the original output of the channel attention module to obtain the final output of the CBAM module.

[0068] In a specific embodiment, in the SEBlock module, a global average pooling operation is first performed on the input feature map; then an excitation operation is performed to generate the weight of each channel through a fully connected layer; finally, a multiplication operation is performed to multiply the weight vector obtained after the excitation operation by the original input feature map channel by channel to obtain a re-weighted feature map.

[0069] Specifically, Figure 7 As shown, X and Represent the input features and output features respectively, where The shape is H×W×C (H is the height, W is the width, and C is the number of channels). sq (.) represents the Squeeze operation, i.e., the global average pooling operation, which generates a global distribution embedding of the channel feature response so that the information in the global receptive field of the network can be used by all layers of the network. ex (.,w) represents the excitation operation, that is, the compressed vector passes through a pair of fully connected layers to generate the weight of each channel. scale (.,.) represents a multiplication operation, which multiplies the weight vector obtained in the excitation step by the original input feature map channel by channel to achieve re-weighting of the original feature map.

[0070] In a specific embodiment, in the ECA module, a global average pooling operation is first performed on the input feature map; then a convolution operation is performed using a convolution layer; finally, after a nonlinear transformation using an activation function, a dot product operation is performed with the original input feature map to obtain the final output.

[0071] Specifically, Figure 8 As shown, The shape is H×W×C (H is height, W is width, and C is the number of channels), GAP represents global average pooling, 1x1xC represents 1D convolution, k=5 is the convolution kernel size, and σ represents the sigmoid activation function.

[0072] In a specific embodiment, it also includes testing and evaluating a variety of different improved YOLOv8 models, using the training set to train the improved YOLOv8 model, the validation set to monitor the model performance, and the test set for the final evaluation. The evaluation indicators include mAP, detection speed and parameter quantity to ensure the balance between the detection performance and real-time performance of the model. The final improved YOLOv8 model is selected according to the detection performance and real-time requirements. The experimental results are shown in Table 1.

[0073] Table 1 Experimental results

[0074]

[0075]

[0076] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0077] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for detecting defects in ancient books based on improved YOLOv8, characterized in that: The specific steps are as follows: Collect and annotate images containing six types of ancient book defects to obtain a special dataset for ancient book defects; Add an attention mechanism module to the YOLOv8 model to obtain an improved YOLOv8 model; Using the ancient book defect-specific dataset, the improved YOLOv8 model is trained and verified to obtain an ancient book defect detection model; The image of the ancient book to be detected is obtained and divided into sliding windows to obtain a number of windows of fixed sizes. The defects in each of the windows are detected using the ancient book defect detection model. The detection results of each window are merged into the image of the ancient book to be detected, and the redundant detection results in the image of the ancient book to be detected are eliminated to obtain the final detection result.

2. According to the ancient book defect detection method based on improved YOLOv8 according to claim 1, it is characterized in that: The YOLOv8 model includes three parts: a backbone network, a neck network and a head network; the backbone network extracts features from an input image, the neck network performs multi-scale feature fusion on the features extracted by the backbone network, and the head network outputs an image recognition result based on the features fused by the neck network; The backbone network is composed of two layers of CBS modules, C2f modules, CBS modules, C2f modules, CBS modules, C2f modules, CBS modules, C2f modules, and SPPF modules connected in sequence; The neck network is composed of two layers of C2f modules, CBS modules, C2f modules, CBS modules, and C2f modules connected in sequence; The head network consists of three independent Detect modules; The third layer CBS module in the backbone network is also connected to the second layer C2f module of the neck network, and the result is input into the C2f module; the output of the SPPF module is spliced ​​with the output of the third layer C2f module in the backbone network after upsampling, and input into the first layer C2f module of the neck network; the output of the SPPF module is also spliced ​​with the output of the second layer CBS module of the neck network, and input into the fourth layer C2f module of the neck network; The second, third and fourth C2f modules of the neck network are also connected to the Detect module corresponding to the head network. The Detect module maps the high-dimensional features input by the C2f module to obtain the final detection result.

3. The ancient book defect detection method based on improved YOLOv8 according to claim 2 is characterized in that: The CBS module includes a convolutional layer, a batch normalization layer and an activation function connected in sequence; the activation function is: f(x)=x·σ(x); wherein f(x) represents the activation function, x represents the input, and σ(x) is the Sigmoid function; The SPPF module includes a CBS module, three pooling layers, and a CBS module connected in sequence; by applying pooling windows of different sizes on the input feature map, multi-scale features are extracted and spliced ​​into a feature map that integrates multi-scale information.

4. The ancient book defect detection method based on improved YOLOv8 according to claim 2 is characterized in that: The adding of the attention mechanism module comprises: adding an attention mechanism module before the multi-scale features extracted by the backbone network are output to the neck network; Alternatively, an attention mechanism module is added to the C2f module of the backbone network.

5. The ancient book defect detection method based on improved YOLOv8 according to claim 4 is characterized in that: The attention mechanism module is added before the multi-scale features extracted from the backbone network are output to the neck network, specifically: three independent attention mechanism modules are added to the channels where the third-layer CBS module, the third-layer C2f module and the SPPF module of the backbone network output to the neck network.

6. The ancient book defect detection method based on improved YOLOv8 according to claim 4 is characterized in that: The adding of the attention mechanism module into the C2f module of the backbone network is specifically as follows: inserting the attention mechanism module into the C2f module to obtain the AttC2f module, and replacing the first layer, the second layer, and the third layer C2f modules in the backbone network with the AttC2f module; The AttC2f module includes a CBS module, a Split module, several Bottleneck modules, a Concat module, an attention mechanism module, and a CBS module connected in sequence.

7. The ancient book defect detection method based on improved YOLOv8 according to claim 1 is characterized in that: The attention mechanism module is a CBAM module, a SEBlock module or an ECA module.

8. The ancient book defect detection method based on improved YOLOv8 according to claim 7 is characterized in that: The CBAM module includes a channel attention module and a spatial attention module; the input features in the CBAM module are processed by the channel attention module and then dot-producted with the original input features as the output of the channel attention module; the output of the channel attention module is processed by the spatial attention module and then dot-producted with the original output of the channel attention module to obtain the final output of the CBAM module.

9. The ancient book defect detection method based on improved YOLOv8 according to claim 7 is characterized in that: In the SEBlock module, a global average pooling operation is first performed on the input feature map; then an excitation operation is performed to generate the weight of each channel through a fully connected layer; finally, a multiplication operation is performed to multiply the weight vector obtained after the excitation operation by the original input feature map channel by channel to obtain a re-weighted feature map.

10. The ancient book defect detection method based on improved YOLOv8 according to claim 7, characterized in that: In the ECA module, firstly, a global average pooling operation is performed on the input feature map; then a convolution operation is performed using a convolution layer; finally, after a nonlinear transformation is performed using an activation function, a dot product operation is performed with the original input feature map to obtain the final output.