Paper product package surface flaw detection and analysis method based on machine vision

By introducing a cascaded attention mechanism and a semantic rule mapping module into the paper product defect detection system, heatmaps and semantic interpretations are generated, solving the "black box" problem of deep learning models, achieving efficient and transparent defect detection and interpretation, and enhancing the understanding of quality inspectors and the system's debugging friendliness.

CN121921272AInactive Publication Date: 2026-04-24ZHONGSHAN LIANFU PACKAGING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHONGSHAN LIANFU PACKAGING CO LTD
Filing Date
2025-12-29
Publication Date
2026-04-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing deep learning-based paper product defect detection systems have a "black box" structure, making it difficult to provide intuitive and structured visual and semantic explanations. They also lack process support, affecting the understanding and judgment of quality inspectors.

Method used

By constructing a machine vision-based method for detecting and analyzing surface defects in paper product packaging, a cascaded attention-guided mechanism is introduced to generate heatmap sequences. Combined with a semantic rule mapping module, a visual evidence chain and semantic explanation are output, and an interactive backtracking interface is provided for model interpretation and optimization.

Benefits of technology

Without compromising detection accuracy, it significantly improves the interpretability and transparency of model decisions, enhances the understanding of quality inspectors, supports quality traceability and accountability, and boasts high compatibility and lightweight advantages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121921272A_ABST
    Figure CN121921272A_ABST
Patent Text Reader

Abstract

The invention provides a paper product package surface flaw detection and analysis method based on machine vision, which comprises the steps of high-resolution industrial vision acquisition, structured working condition and space label data set establishment, multi-stage image preprocessing, multi-level feature extraction and thermodynamic diagram generation, and after a key flaw area is focused through a cascade attention mechanism, a detection result is obtained. Based on a feature response-semantic description mapping table, a model judgment process is converted into natural language interpretation with a physical feature basis, and multi-modal report output and interactive backtracking optimization are realized. And powerful support is provided for industrial quality inspection intelligence, traceability and model credibility.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine vision and deep learning model interpretability technology, and in particular to a machine vision-based method for detecting and analyzing surface defects in paper product packaging. Background Technology

[0002] With the continuous development of intelligent manufacturing and industrial vision inspection technologies, the detection of surface defects in paper product packaging is evolving towards automation, high precision, and high throughput. Currently, machine vision systems are widely used for surface quality monitoring on paper product production lines, achieving real-time detection of typical defects such as wrinkles, stains, scratches, and dents through high-speed linear scan cameras and image processing algorithms. Mainstream technical solutions typically employ deep learning structures such as deep convolutional neural networks (CNN), residual networks (ResNet), and efficient networks (EfficientNet) to achieve end-to-end automatic identification of surface defects, significantly improving detection speed and accuracy, and meeting the basic requirements of large-scale continuous production. However, existing deep learning-based paper product defect detection systems generally suffer from significant technical flaws and application bottlenecks. While deep neural network models achieve high-precision defect recognition, their internal reasoning process is a typical "black box" structure, making the basis for defect judgment and the core areas of focus of the model invisible. Mainstream convolutional neural networks only output the final judgment result and probability score, making it difficult to provide an intuitive and structured visual and semantic interpretation of each detection result. Summary of the Invention

[0003] In order to solve the above-mentioned technical problems, the present invention provides a method for detecting and analyzing surface defects in paper product packaging based on machine vision.

[0004] The technical solution of this invention is implemented as follows: a machine vision-based method for detecting and analyzing surface defects in paper product packaging, comprising: S1: Acquire high-resolution image data of the surface of paper product packaging, and record the production batch, material type and collection location label corresponding to the image to establish an original image dataset containing information on working condition differences; S2: Perform illumination normalization, noise suppression and edge enhancement processing on the images in the original image dataset in sequence to generate preprocessed images with uniform brightness distribution and clear texture structure, which is used to ensure consistency in subsequent feature extraction. S3: Input the preprocessed image into the trained deep convolutional neural network model, and extract multi-level intermediate feature maps from low level to high level layer by layer to form a hierarchical feature representation sequence covering edges, textures and semantic structures; S4: Based on the hierarchical feature representation sequence, the spatial attention weight distribution of each network layer is calculated using a cascaded attention guidance mechanism to generate a heatmap sequence corresponding to each layer, wherein each heatmap reflects the intensity of attention of the current layer to potential defective areas. S5: Based on the location and response intensity change trend of the significantly activated regions in the heatmap sequence, locate the key feature response regions that dominate the decision-making process, and input them into the semantic rule mapping module as the basis for interpretability analysis. S6: In the semantic rule mapping module, a matching operation is performed based on a pre-built 'feature response-semantic description' mapping table, wherein the mapping table is encoded and defined according to the local texture pattern, spatial distribution law and corresponding historical expert annotation knowledge of typical defect types, thereby transforming the key feature response region into explanatory text in natural language form. S7: Integrate the heatmap sequence, the location boxes of key feature response regions, and the generated explanatory text to output a composite detection report containing a visual evidence chain and semantic explanation for quality traceability and user verification. S8: Provides an interactive backtracking interface, allowing quality inspectors to trace the evolution of the feature response of any defect judgment result in the composite inspection report in reverse, and dynamically update the rule weights in the semantic rule mapping table based on the feedback information, so as to continuously optimize the model's interpretability.

[0005] The machine vision-based method for detecting and analyzing surface defects in paper product packaging provided by this invention has the following beneficial effects: (1) This invention constructs a dual-path inference architecture, which, without changing the original high-precision recognition model structure and performance, introduces an auxiliary interpretation path to realize the visualization of the detection basis, significantly improving the interpretability and transparency of the model's decision-making. The main path maintains the efficient inference capability of the original backbone network such as ResNet or EfficientNet, ensuring that the defect classification accuracy is not affected; the auxiliary path simultaneously captures multi-level intermediate feature maps and generates a heat map sequence that focuses layer by layer in combination with a cascaded attention guidance mechanism, clearly showing the evolution process from low-level edge response to high-level semantic structure matching, forming a visual decision chain with temporal logic. This design effectively overcomes the technical defects of traditional single-output confidence scores lacking process support, enabling quality inspectors to intuitively understand why the model judges a certain area as a specific defect type, thereby enhancing the trust basis of human-machine collaborative judgment; (2) This invention introduces a semantic rule mapping module to establish a structured knowledge association table of “feature response - semantic description”, and formally encodes typical defect types (such as wrinkles, stains, scratches) with their corresponding local texture patterns, spatial distribution patterns and intensity contrast characteristics. After the model completes the prediction, the system automatically retrieves the most significantly activated feature region, matches it with the preset semantic rule library, and generates an attribution explanation in natural language form, such as “the reason for judging it as an indentation is that continuous parallel stripes were detected in the central region and the contrast was lower than the threshold.” This kind of explanatory information with process context not only makes it easy for non-algorithm professionals to quickly understand the judgment basis, but also provides auditable data support for quality traceability, responsibility definition and standard compliance. At the same time, with the interactive backtracking interface, users can click on any defect area to trace the response change trend of it in each layer of the network, realizing fine-grained model behavior analysis capabilities, which greatly enhances the debugging friendliness and maintenance flexibility of the system; (3) This method has high compatibility and lightweight advantages at the system integration level. It does not require reconstruction of the existing end-to-end training process, nor does it rely on traditional grayscale comparison or rigid template matching, which are technical means that have been avoided by the industry. This avoids the problem of additional annotation costs and a surge in computational load. While maintaining the inference speed of the original model, it can output a composite detection report containing heatmap sequences, key feature localization boxes, and semantic explanation text with only a small increase in post-processing overhead. This non-intrusive interpretability enhancement strategy not only ensures the real-time and accuracy requirements in industrial scenarios, but also meets the urgent needs of high-end manufacturing fields for transparency and standardization in quality auditing. Attached Figure Description

[0006] Figure 1 This is a flowchart of the machine vision-based method for detecting and analyzing surface defects in paper product packaging according to the present invention. Figure 2 This is a sub-flowchart of the machine vision-based method for detecting and analyzing surface defects in paper product packaging according to the present invention. Figure 3 This is another sub-flowchart of the machine vision-based paper product packaging surface defect detection and analysis method of the present invention. Detailed Implementation

[0007] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0008] The following disclosure provides many different embodiments or examples for implementing different structures of the invention. To simplify the disclosure, specific examples of components and arrangements are described below. Of course, these are merely examples and are not intended to limit the invention. Furthermore, reference numerals and / or letters may be repeated in different examples; such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.

[0009] like Figure 1 As shown, this invention provides a machine vision-based method for detecting and analyzing surface defects in paper product packaging, specifically including: S1: Acquire high-resolution image data of the surface of paper product packaging, and record the production batch, material type and collection location label corresponding to the image to establish an original image dataset containing information on working condition differences; S2: Perform illumination normalization, noise suppression and edge enhancement processing on the images in the original image dataset in sequence to generate preprocessed images with uniform brightness distribution and clear texture structure, which is used to ensure consistency in subsequent feature extraction. S3: Input the preprocessed image into the trained deep convolutional neural network model, and extract multi-level intermediate feature maps from low level to high level layer by layer to form a hierarchical feature representation sequence covering edges, textures and semantic structures; S4: Based on the hierarchical feature representation sequence, the spatial attention weight distribution of each network layer is calculated using a cascaded attention guidance mechanism to generate a heatmap sequence corresponding to each layer, wherein each heatmap reflects the intensity of attention of the current layer to potential defective areas. S5: Based on the location and response intensity change trend of the significantly activated regions in the heatmap sequence, locate the key feature response regions that dominate the decision-making process, and input them into the semantic rule mapping module as the basis for interpretability analysis. S6: In the semantic rule mapping module, a matching operation is performed based on a pre-built 'feature response-semantic description' mapping table, wherein the mapping table is encoded and defined according to the local texture pattern, spatial distribution law and corresponding historical expert annotation knowledge of typical defect types, thereby transforming the key feature response region into explanatory text in natural language form. S7: Integrate the heatmap sequence, the location boxes of key feature response regions, and the generated explanatory text to output a composite detection report containing a visual evidence chain and semantic explanation for quality traceability and user verification. S8: Provides an interactive backtracking interface, allowing quality inspectors to trace the evolution of the feature response of any defect judgment result in the composite inspection report in reverse, and dynamically update the rule weights in the semantic rule mapping table based on the feedback information, so as to continuously optimize the model's interpretability.

[0010] Step S1: Acquire high-resolution image data of the surface of paper product packaging, and record the production batch, material type, and acquisition location label corresponding to the image to establish an original image dataset containing information on differences in working conditions. Specifically, this includes: S1.1: High-resolution image acquisition of paper product packaging surface based on industrial vision imaging system. Continuous distortion-free grayscale or color images are acquired using a line scan camera in conveyor belt synchronous trigger mode to obtain raw image data with spatial resolution of 0.1mm / pixel level, which serves as the input basis for subsequent multi-level feature extraction. The target of high-resolution image acquisition of the surface of paper product packaging is a production line station equipped with an industrial vision imaging system, which includes a line scan camera, a synchronous trigger control unit, and a constant illumination module. A line scan camera scanning imaging method (parameters: 2048 pixels per row, 7μm pixel size) is used to achieve line-by-line scanning acquisition along the direction of conveyor belt movement; Furthermore, a synchronous trigger control algorithm is used (parameter: trigger frequency is calculated based on the conveyor belt speed v and the desired horizontal resolution d, as shown in the following formula):

[0011] in For trigger frequency, For the linear speed of the conveyor belt, (Sampling interval), to achieve time locking of camera exposure and transport motion, and obtain a continuous and distortion-free linear scan raw data stream; Furthermore, through a multi-channel lighting equalization control method (parameter: channel brightness) Based on surface reflectivity Adjustments are made, and the formula is as follows: ,in The brightness of the i-th channel. As the reference brightness, (The reflectance coefficient of the material corresponding to the channel) enables dynamic compensation for the reflection of different material surfaces, generating grayscale or color image frames with uniform illumination. Furthermore, a row-column stitching algorithm (parameters: buffer length N rows, overlap correction threshold δ) is used to achieve two-dimensional stitching of linear array images and generate a complete original image matrix with a spatial resolution of 0.1 mm / pixel. Through the above algorithms or processing methods, the scanning data stream of the previous step is transformed into two-dimensional image data that meets the characteristics of high resolution and low distortion, so as to achieve the expected technical effect of providing high-fidelity visual input for multi-level feature extraction. For example, in an automated packaging production line, the conveyor belt speed is set to 0.5 m / s, and the desired horizontal resolution is set to 0.1 mm / pixel. Then, the trigger frequency... The calculated Hz frequency is 5000Hz. The line scan camera is configured with 2048 pixels per row and a pixel size of 7μm. Uniform material conveying is achieved through mechanical slide table transmission. The lighting module is divided into three channels with a reference brightness. With a reflectivity set to 120 cd / m², and reflectivity coefficients of 0.3, 0.45, and 0.25 respectively, the brightness of each channel is calculated to be approximately 171 cd / m², 218 cd / m², and 160 cd / m², respectively, enabling separate supplemental lighting for wrinkled paper surfaces, smooth coated paper surfaces, and ink-absorbing rough surfaces. During the acquisition process, the buffer length was set to 300 rows, and the overlap threshold δ was set to 2 pixels. An image matrix with a size of 2048×300 was generated through a stitching algorithm, and the spatial resolution was stabilized at 0.1 mm / pixel. Verification showed that the acquired image had no lateral ghosting and the brightness uniformity was significantly improved, meeting the input quality requirements for subsequent feature extraction. S1.2: Add structured metadata tags to the original image data, and read the production batch number, substrate weight, coating type and roller pressure parameters of the current workstation in real time based on the PLC control system. Then, bind and store the above process parameters as working condition identification information with the image data to generate structured image entries with production context. S1.3: Based on the acquisition timestamp and physical location code in the structured image entry, the axial and lateral coordinate positions of each image on the whole roll of material are determined by encoder signal mapping, and acquisition location labels with spatial positioning attributes are generated to characterize the spatial regularity of defect distribution. Based on the acquisition timestamp and physical location encoding in the structured image entries, the encoder pulse counting method (parameters: encoder resolution, conveyor belt linear speed, camera trigger frequency) is used to achieve accurate mapping of image acquisition events to the axial position of the material. Furthermore, by using a dual-encoder differential positioning algorithm (parameters: installation distance between the axial encoder and the transverse encoder, synchronous sampling period), the precise calculation of the image's transverse position is achieved, and transverse coordinate data is obtained. Furthermore, by using a timestamp-location joint interpolation algorithm (parameters: sampling time series, location pulse series, interpolation order), continuous spatial vector positioning of the acquired events is achieved, and a two-dimensional coordinate matrix is ​​generated; Furthermore, by using a coordinate matrix and production batch label binding processing method (parameters: batch number, material type code), the spatial positioning information of each image is synchronously associated with the production condition metadata, and structured label entries with spatial attributes are generated. Furthermore, a location coding normalization algorithm (parameters: total material length, total width) is adopted to convert each coordinate value into a relative proportion representation and generate standardized acquisition location labels for characterizing the spatial regularity analysis of defect distribution; Through the above algorithm or processing method, the result of the previous step is transformed into a collection location label with spatial positioning attributes, so as to realize the accurate positioning of the original image in the dual-axis space of the material surface, and provide reliable basic data for subsequent analysis of the spatial distribution pattern of defects. For example, on a paper product packaging production line equipped with a photoelectric encoder, the encoder resolution is set to 4096 pulses / revolution, the conveyor belt speed is 0.5 m / s, and the camera trigger frequency is 100 Hz. The axial position is calculated using the encoder pulse counting method based on the trigger timestamp of each image frame. The pulses were used to obtain an axial displacement of 12.21 pulses per frame. A dual-encoder differential positioning algorithm was employed, with a lateral encoder resolution of 2048 pulses / revolution and a sampling period of 0.01s, to calculate the lateral displacement and simultaneously generate lateral coordinates. For timestamp-position joint interpolation, a cubic spline interpolation of order 3 was used to obtain a continuous two-dimensional coordinate matrix. This coordinate matrix was then bound to the batch number "B20231108" and the material type "white cardboard 220g / m²" to generate spatial positioning attribute labels, such as "axial position 1.25m, lateral position 0.38m". After position encoding normalization, the position label was represented as "axial 50%, lateral 31.67%" relative to the material's total length of 2.5m and total width of 1.2m, forming the final position label entry. Using this label in the quality inspection system significantly improves the accuracy and visualization of defect location and pattern analysis. S1.4: Based on the set of image entries with working condition labels and spatial coordinates, perform a classification index construction in three dimensions of batch-material-location to generate an original image dataset containing multi-working condition differences to support subsequent interpretability comparison analysis of the model under different production conditions; Based on a structured image entry set with working condition identification information and spatial coordinate attributes, a multi-dimensional classification index construction algorithm (parameters: batch number, material type, acquisition location) is adopted to realize the discretization mapping and unique encoding of input entries in a three-dimensional attribute space; Furthermore, by using a three-dimensional hash mapping method (parameters: hash seed originates from a combination of batch number and material type, and position coordinates are quantized to the millimeter level), a fixed-length index key is generated for each entry, resulting in a key-value pair data structure that can be quickly retrieved under various working conditions. Furthermore, a three-dimensional Cartesian space bucketing algorithm (parameters: number of batch buckets = number of production batches, number of material buckets = number of material categories, number of location buckets = size of roll material coordinate grid division) is used to group and aggregate items and generate a bucketing index matrix that is easy to interpret and compare. Furthermore, a three-dimensional sparse matrix filling algorithm (parameters: bucket matrix dimension = batch × material × position grid, filling value is entry storage pointer) is used to map the classification index data to the physical storage structure and generate an index table of the original image dataset containing full working condition coverage. By constructing an index table, the set of entries from the previous step is transformed into batch-material-location three-dimensional mapping data, enabling efficient and interpretable comparison and retrieval technology under different production conditions. For example, in a paper product packaging production line, the batch number range is set to 1001 to 1010, and the material types include three categories: white cardboard, kraft paper, and coated paper. The collection location coordinates are divided into 500×75 grids with an axial length of 10000mm and a transverse width of 1500mm. A three-dimensional classification index construction algorithm is used. An entry with batch number 1005, material type kraft paper, and collection location coordinates (2500mm, 300mm) is input. A 128-bit index key is generated through hash mapping, corresponding to the following bucket index positions: batch bucket = 5, material bucket = 2, location bucket = (grid rows = 125, grid columns = 15). Using a Cartesian bucketing algorithm, this entry is aggregated into a batch-material-location three-dimensional bucket matrix, forming a sparse matrix set with other entries of the same batch and material at different locations. After matrix filling, the number of entries in the generated index table is consistent with the number of entries in the original dataset, significantly reducing the response time for retrieving the same batch and material. When comparing model interpretability, the heat map and characteristic response of the corresponding item in different working condition groups can be located according to this index table, which greatly improves the comparison efficiency and supports the visualization analysis of the positional regularity within the batch. S1.5: Perform integrity verification and deduplication on the original image dataset, use hash fingerprint algorithm to detect duplicate images, and combine metadata consistency verification mechanism to remove mismatched or missing entries to ensure the accuracy and representativeness of the dataset and provide a reliable data input source for the interpretability enhancement framework.

[0012] Step S2: The images in the original image dataset are sequentially subjected to illumination normalization, noise suppression, and edge enhancement processing to generate preprocessed images with uniform brightness distribution and clear texture structure, ensuring consistency for subsequent feature extraction. Specifically, this includes: S2.1: Based on the high-resolution grayscale or RGB images in the original image dataset, calculate the spatial illuminance distribution map of each image using the illumination field estimation model to separate the low-frequency intensity deviation introduced by non-uniform illumination; use the bilinear interpolation method to downsample and smooth the illuminance distribution map to obtain a standardized illumination field template for subsequent illumination normalization correction. Based on high-resolution grayscale or RGB images in the original image dataset, an illumination field estimation model (parameters: sampling step size p, smoothing kernel size k) is used to calculate the spatial illumination distribution map of each image. Furthermore, a two-dimensional illuminance estimation function is established by using the bidirectional gradient integral method. A weighted average fitting is performed on the illuminance values ​​of the sampling points to obtain an illuminance intensity matrix covering the entire image, and the low-frequency intensity deviation matrix introduced by non-uniform illumination is separated. Furthermore, using the bilinear interpolation method (parameters: row and column interpolation coefficients) , The intensity matrix is ​​downsampled to reduce the matrix size while maintaining the original illumination change trend and minimizing damage to information boundaries. Furthermore, a Gaussian smoothing operation is performed on the downsampling results (parameter: standard deviation). This generates a smoothing matrix for the illumination field with good continuity and reduced texture interference, which is used to weaken high-frequency noise components. The standardized illumination field template is calculated using the following formula:

[0013] in, The original image in coordinates Pixel brightness value at that location For the corresponding coordinates The value of the illuminance field smoothing matrix at that location; By standardizing the processing method, the illuminance distribution results of the previous step are transformed into a unified luminance reference template, so as to achieve the expected technical effect of illuminance normalization correction. For example, in a paper product packaging defect detection scenario, the acquired original RGB image resolution is 4096×2048 pixels, the sampling step size p of the linear scan camera is set to 2 pixels, and the smoothing kernel size k is set to 5 pixels. The illuminance intensity matrix is ​​calculated using an illumination field estimation model, resulting in a two-dimensional matrix with luminance values ​​ranging from 30 to 220. A bilinear interpolation method is used, with row and column interpolation coefficients... =0.5、 =0.5, reducing the matrix size to 2048×1024; then with =1.2 Perform Gaussian smoothing to obtain an illumination field smoothing matrix with no obvious abrupt changes at the boundaries. Use the formula After calculating the standardized illumination field template, the brightness of all pixels is uniformly mapped to the reference range [50, 200]. This significantly improves the brightness consistency of different batches of samples in the subsequent feature extraction and pattern matching process, and reduces the impact of illumination changes on defect identification. S2.2: Perform pixel-by-pixel division on the original image based on a standardized illumination field template to compensate for spatial illuminance differences and generate an intermediate image after illumination normalization; further apply the Gamma correction function to perform nonlinear intensity mapping on the intermediate image so that its overall brightness distribution approximates the standard reference histogram, thereby obtaining a normalized image output with uniform brightness response characteristics. S2.3: For the normalized image sequence, a noise suppression algorithm based on non-local means is used to perform noise suppression processing. By calculating the Euclidean distance similarity weight between image blocks, an adaptive weighted average is performed on the texture regions with repetitive structures in the global range to effectively reduce random noise interference while preserving the fine texture of the paper product surface, and output the denoised image. S2.4: Apply the multi-scale Laplacian-Gaussian (LoG) operator and the Canny edge detector to perform edge enhancement operations on the denoised image. First, use Gaussian kernels with different σ parameters to perform multi-channel convolution on the image to extract multi-scale edge candidate sets. Then, fuse the multi-scale responses through non-maximum suppression and double threshold connection strategies to generate an enhanced edge map with continuous contours and high positioning accuracy. S2.5: The enhanced edge image is linearly fused with the background image after illumination normalization and denoising based on the weight coefficient α, where α is dynamically adjusted according to the paper material type to highlight the boundary information related to key defects without over-amplifying artifacts; finally, a preprocessed image with uniform brightness distribution, low noise level and enhanced texture structure is generated for subsequent deep convolutional neural network to perform hierarchical feature extraction.

[0014] like Figure 2 As shown, step S3 involves inputting the preprocessed image into a trained deep convolutional neural network model, extracting multi-level intermediate feature maps from low to high levels layer by layer to form a hierarchical feature representation sequence covering edges, textures, and semantic structures. Specifically, this includes: S3.1: Obtain the preprocessed image after illumination normalization, noise suppression and edge enhancement processing as the input object; based on the forward propagation mechanism of the deep convolutional neural network model, perform the initial convolution operation on the preprocessed image, use the first-level convolution kernel to extract low-level visual features in the image, and generate a primary feature map containing edges, corners and basic texture structures as the basic input for subsequent hierarchical feature abstraction; The preprocessed image, after illumination normalization, noise suppression, and edge enhancement, is used as the input object for the deep convolutional neural network. Use the initial convolutional layer group of the convolutional neural network (parameter: kernel size) × Step length (with the padding method set to "same"), a two-dimensional convolution operation is performed on the input image to achieve local perception and spatial encoding of low-level visual features; Furthermore, by combining convolution operations with a batch normalization algorithm (parameter: ε= ,momentum This improves the numerical stability of the feature map and suppresses gradient oscillations caused by differences in input distribution, resulting in a normalized low-level feature response. Furthermore, the ReLU (Rectified Linear Unit) nonlinear activation function is applied to perform element-wise nonlinear mapping on the normalized feature response to achieve sparse activation and edge texture enhancement, generating a primary feature map that highlights brightness gradient changes; Furthermore, max pooling (parameter: pooling kernel size) is employed. × Step length The operation performs spatial sampling compression on the primary feature map, realizing spatial structure downsampling of low-level features and retaining the most significant activation response values ​​to reduce subsequent computation and enhance local invariance. Through the above chain of convolution, normalization, activation and pooling processing, the preprocessed image of the previous step is transformed into a primary feature map containing edges, corners and basic texture structures, so as to achieve the expected technical effect of providing spatial localization and texture primitive information for subsequent intermediate feature abstraction. For example, in a paper product defect detection scenario, the input is resolution. × Preprocessed RGB image of pixels. The initial convolutional layer uses... × Convolution kernel, number of channels Step size is The ε value for batch normalization is set to... Momentum is After ReLU activation, weak texture responses in the feature map are suppressed, while the amplitude of signals at significant edges and corners is increased. The max-pooling kernel is set to... × Step size is This reduces the feature map size to × Under this configuration, the feature map after primary feature extraction can significantly improve the perception of low-level structures such as micro-indentations, linear scratches and local wrinkles while maintaining edge continuity and corner distribution, laying a stable and high-resolution feature foundation for subsequent intermediate texture pattern extraction by dilated convolution; S3.2: Using the primary feature map as input, multi-scale receptive field expansion processing is performed through stacked convolutional layers. Dilated convolutional modules with different dilation rates are used to capture medium-complexity texture patterns in the local neighborhood. The activation response intensity of each channel is calculated, and batch normalization and nonlinear activation function transformation are performed to output a spatially selective intermediate feature map that represents typical local structures on the surface of paper products, such as repeating stripes and patch distribution. Using primary feature maps as input, a multi-scale receptive field expansion method (parameter: set of convolution kernel sizes {3×3, 5×5, 7×7}) is adopted. By applying dilated convolution modules with different dilation rates in parallel in the convolutional layer group, medium-complexity texture patterns covering different spatial neighborhoods are captured, thus achieving multi-resolution representation of cross-scale features. Furthermore, by setting the set of dilated convolution dilation rates {1, 2, 3}, the receptive field range is expanded in each convolution branch while keeping the feature map resolution unchanged, so as to enhance the response capability to local structures such as repeating stripes and patch distribution on the surface of paper products. Furthermore, a channel activation intensity calculation method (parameters: channel-wise global average pooling and variance normalization) is employed to calculate the activation response intensity metric for the feature map of each convolutional output channel. The metric is used to evaluate the spatial selectivity of the channel in the current intermediate feature extraction stage; Furthermore, a batch normalization algorithm (parameters: mean and variance are statistically calculated within the current batch) is used to normalize the feature maps of each channel to eliminate feature distribution shifts caused by batch differences and stabilize gradient propagation during network training. Furthermore, the nonlinear activation function ReLU is applied to the batch normalized results to suppress negative feature responses to zero, maintain the linearity of high response regions, and thus output a sequence of intermediate feature maps with spatial selectivity and high discriminative power. Through the above-mentioned multi-scale dilated convolution, activation intensity calculation, batch normalization and nonlinear activation processing chain, the primary feature map is transformed into an intermediate feature map that characterizes the typical local structure of the paper product surface, thereby achieving the technical effect of cross-scale pattern capture and spatial selectivity enhancement. For example, in a paper product surface defect detection task, the input primary feature map size is 256×256×64 channels, the convolutional layer group is configured with three parallel branches, the convolutional kernel sizes are 3×3, 5×5, and 7×7 respectively, and the dilation rate of the dilated convolution is set to 1, 2, and 3. Channel activation response intensity. The calculation process is as follows: for the feature map of each channel First, global average pooling is performed to obtain... Then perform variance normalization. The activation response strength is given by the formula It means that, among them Let be the mean of the features of the c-th channel. The corresponding variance is given. The batch normalization process sets the momentum parameter to 0.9 and the numerical stability factor to [value missing]. After normalization, a ReLU activation function is applied to obtain a final intermediate feature map with a size of 256×256×128 channels. This intermediate feature map significantly enhances the response in repeating stripe and patch regions. The multi-scale characteristics of dilated convolution effectively capture defective structures in different spatial patterns, enabling the subsequent high-level semantic feature extraction stage to improve classification and discrimination capabilities based on stable intermediate-scale information. S3.3: Input the intermediate feature map into the deep residual structure of the network, alleviate the gradient degradation problem based on the cross-layer identity mapping mechanism, and extract semantic features with class discrimination through the high-level convolutional layer before global average pooling; calculate the spatial response distribution of the high-level feature map to obtain a high-level semantic feature map that can represent the overall shape and structural layout of the defect type, which is used to support the final classification decision. The tensor data output from the intermediate feature map is input into the deep residual structure module. A cross-layer identity mapping mechanism is adopted (parameters: skip connection distance = 2 layers, mapping weight initialization method = He Normal) to realize the direct transmission of context information and alleviate the degradation problem of gradient during deep propagation. Furthermore, by configuring multiple sets of convolutional kernels (parameters: kernel size = 3×3, number of channels = 256, stride = 1) and batch normalization layers inside the residual block, the stability of feature distribution is improved while maintaining the feature space structure, and deep activation response results with global context awareness are obtained. Furthermore, global average pooling (parameter: pooling window covers the entire spatial dimension) is inserted at the end of the deep residual structure to compress high-dimensional spatial features into fixed-length category vectors, thereby realizing the convergence of features from different spatial locations for semantic classification and providing input for subsequent calculation of spatial response distribution; Furthermore, based on the high-level convolution output before global average pooling, the response intensity mapping across spatial units is calculated using a response normalization method. Furthermore, based on the normalized response mapping, a two-dimensional spatial distribution fitting analysis is performed (parameters: fitting kernel type = Gaussian, standard deviation σ = 1.5) to generate a high-level semantic feature map that can characterize the overall shape and structural layout of the defect type, and this map is used as supporting data for the final classification decision and input into the classifier. By combining deep residual structures with global pooling, intermediate feature maps are gradually abstracted into high-level feature representations containing complete spatial-semantic information, thereby significantly improving the ability to distinguish defect categories. For example, in a paper product defect detection scenario, the intermediate feature map size is 128×128×256. After deep residual structure processing, three residual blocks are configured. Each residual block contains two layers of 3×3 convolutions and identity mapping skip connections. The convolution weights are initialized using He Normalization, and the batch normalization momentum parameter is set to 0.9. After global average pooling, the feature vector dimension is compressed from 128×128×256 to 1×1×256. When calculating the spatial response distribution, the maximum value of the original response matrix is ​​3.2, and the response value at a certain location is 2.4. After normalization, we get:

[0015] The normalization result is approximately 0.75, and the corresponding highlighted region, fitted with a Gaussian kernel σ=1.5, exhibits an elliptical response peak concentrated in the center of the image. When this high-level semantic feature map is input into the Softmax classifier, it correctly identifies the instance as an "indentation" and demonstrates a clear spatial structure correspondence in the model interpretability test, significantly improving the transparency of the decision-making basis and the credibility of the classification results. S3.4: Based on the temporal synchronization constraints of primary, intermediate and high-level feature maps, spatial alignment and resolution matching processing are performed on the feature map sequences output by each level. Upsampling and skip connections are used to fuse multi-scale information to generate a hierarchical feature representation sequence with consistent resolution and distinct semantic levels, ensuring that each level of feature map can accurately correspond to the spatial position of the original image. The hierarchical feature representation sequence consisting of primary, intermediate, and high-level feature maps is obtained as input, and a time synchronization constraint matrix is ​​constructed to ensure that feature maps from different network layers can maintain consistency on the inference time axis. A spatial alignment algorithm (parameter: bilinear interpolation kernel size of 3×3) is used to perform pixel-by-pixel upsampling on the low-resolution high-level feature map so that its spatial size matches the resolution of the mid-level feature map, providing a consistent spatial benchmark for subsequent multi-scale fusion. Furthermore, through a skip connection mechanism (parameters: connection position selected as primary to intermediate, intermediate to high level), the upsampled high-level feature map is spliced ​​and fused with the low-level feature map of the same spatial resolution in the channel dimension to form a composite feature map containing fine-grained texture and high-level semantic information. Furthermore, a multi-scale convolutional fusion algorithm (parameters: convolutional kernel size is a combination of 1×1 and 3×3) is used to perform convolutional transformation on the stitched composite feature map, extract cross-scale consistent feature responses, and generate a fused feature representation matrix to reduce structural distortion introduced by resolution differences. Furthermore, based on global normalization, the fused feature representation matrix is ​​normalized to a uniform range in both spatial and channel dimensions, achieved through the following normalization formula:

[0016] in, To fuse the feature matrix, The global mean. The global standard deviation is the normalized fusion feature matrix. Ensure that the response amplitudes of different feature levels are within a comparable numerical range; Through the aforementioned spatial alignment, skip connection, and multi-scale fusion algorithms, the primary, intermediate, and high-level feature maps are perfectly matched in resolution and spatial location, generating a hierarchical feature representation sequence with distinct semantic levels and consistent spatial coordinates. This achieves the expected technical effect of the subsequent attention-guided mechanism accurately mapping the original image location. For example, in the application of surface defect detection for paper product packaging, the size of the primary feature map is 256×256×64, the size of the intermediate feature map is 128×128×128, and the size of the advanced feature map is 64×64×256. The advanced feature map is upsampled to 128×128×256 using bilinear interpolation, and then combined with the intermediate feature map via skip connections to form a composite feature map of 128×128×384 in the channel dimension. Parallel convolutions with 1×1 kernels (256 channels) and 3×3 kernels (128 channels) are then performed, followed by concatenation to obtain a 128×128×384 fused feature representation matrix. Global averaging is then applied. and standard deviation The normalization process outputs a hierarchical feature sequence with a uniform scale. This hierarchical feature ensures that the same defect is precisely located on different level feature maps in the subsequent heatmap generation step, significantly improving the spatial localization accuracy and semantic correspondence of interpretability analysis. S3.5: The aligned hierarchical feature representation sequence is used as the output result and is organized into a complete feature chain from edge to semantics according to the network depth order, which can be called by the subsequent cascaded attention guidance mechanism. This sequence not only retains the detailed information of the original image, but also gradually builds a hierarchical representation system for paper product defect types, providing traceable intermediate state data for heat map generation and interpretability analysis.

[0017] like Figure 3 As shown, step S4 involves: based on the hierarchical feature representation sequence, calculating the spatial attention weight distribution of each network layer using a cascaded attention guidance mechanism, and generating a heatmap sequence corresponding to each layer, where each heatmap reflects the intensity of attention paid by the current layer to potential defective regions. Specifically, this includes: S4.1: Obtain the sequence of multi-level intermediate feature maps output layer by layer by the deep convolutional neural network during the forward propagation process. Each feature map corresponds to the two-dimensional feature response tensor extracted from a specific layer in the network (such as the 2nd, 3rd, 4th and 5th stages of ResNet), which serves as the input data source for spatial attention calculation. S4.2: Based on the feature response tensor of each layer in the intermediate feature map sequence, a channel attention vector is generated by channel-dimensional global average pooling operation, and it is reshaped into a weight matrix with consistent spatial dimensions to initially characterize the importance distribution of each spatial position in the current layer feature representation. S4.3: Perform cascaded cross-layer feedback enhancement processing on the initially generated spatial attention weight matrix, that is, use the attention mask of the high-level semantic layer to modulate and optimize the weights of the low-level detail layer, and generate a refined spatial attention weight distribution with context awareness by passing salient region cues back layer by layer. S4.4: Based on the optimized spatial attention weight distribution, it is fused with the original intermediate feature map of the corresponding level element by element to calculate the feature response map of each layer after attention enhancement, and the response map is normalized to the [0,1] interval to generate a single-channel heat map reflecting the attention intensity of potential defect areas. Based on the spatial attention weight distribution matrix obtained by step S4.3, an element-wise weighted fusion method is adopted (parameter: the fusion coefficient depends on the channel normalization ratio set during the model training stage) to achieve attention enhancement processing of the original intermediate feature maps of the corresponding level. Furthermore, by performing element-wise multiplication, the weight value of each position in the spatial attention weight matrix is ​​multiplied by the activation value of the corresponding feature map pixel, so as to adjust the response intensity of each position while maintaining the original feature spatial localization, and thus obtain the attention-weighted feature response matrix. Furthermore, a normalization algorithm (parameters: minimum / maximum value normalization mode) is employed to map all pixel values ​​of the weighted fused feature response matrix to the following formula. Interval:

[0018] in For the normalized result, The weighted and fused response value. and These represent the minimum and maximum values ​​of all response values ​​in this layer, respectively. Furthermore, through single-channel compression, the normalized multi-channel feature response matrix is ​​globally averaged and pooled along the channel dimension to generate a single-channel two-dimensional response map, which centrally displays the comprehensive attention intensity of each spatial location to the potential defect area. Furthermore, a heat map algorithm (parameter: the correspondence between gradient color mapping range and normalized value) is adopted to transform the single-channel response map into a heat map data structure, preserving the continuous intensity distribution between 0 and 1 without introducing color information deviation, thus ensuring the physical consistency of subsequent visualization presentation; Through the above element-wise weighting, normalization and single-channel processing, the optimized spatial attention distribution of the previous step is transformed into a single-channel heatmap that reflects the attention intensity of potential defect areas, realizing a direct mapping from feature response to visualization basis within the model. For example, when performing this step on the image of the paper product packaging surface acquired by the conveyor belt, the original fourth-stage feature map is assumed to be a tensor of size 64×64×256, the optimized spatial attention weight distribution matrix is ​​64×64×1, and the fusion coefficient is fixed at 1.0. After element-wise multiplication, the weighted feature response tensor R is obtained, and its minimum value... It is -0.32, the maximum value. The value is 2.85. Applying the above normalization formula, the normalized response range is obtained as 0.0 to 1.0. After global average pooling of the channels, a single-channel response matrix of size 64×64 is generated, and the corresponding value range is consistent with the normalization result. A gradient mapping from 0 (black) to 1 (white) is established using a linear grayscale color table to generate a 64×64 single-channel heatmap. The area with a value higher than 0.75 in this heatmap completely coincides with the actual scratch location marked by quality inspection, verifying the effectiveness of the attention weighting method and significantly improving the positioning accuracy of the interpretable output. S4.5: Integrate the single-channel heatmaps generated by all network layers to form a heatmap sequence sorted by network depth. Each heatmap corresponds to the model's gradual focusing process from edge texture to high-level semantic structure, serving as the output of the visualized decision evolution path for subsequent key area localization and semantic mapping.

[0019] Step S5: Based on the location and response intensity change trend of significantly activated regions in the heatmap sequence, locate the key feature response regions that dominate the decision-making process, and input them into the semantic rule mapping module as the basis for interpretability analysis. Specifically, this includes: S5.1: Based on the heatmap sequence generated in the previous steps, calculate the spatial significance score of each level heatmap. The spatial significance score is obtained by extracting the mean and variance statistics of the top percentage intensity region after normalizing the heatmap, so as to quantify the difference in the degree of attention of each network layer to potential defect areas. S5.2: Based on the spatial saliency scores of the heatmaps at each level, perform cross-level response trend analysis, use the sliding window method to detect the evolution path of response intensity of significantly activated regions between low-level and high-level network layers, and identify key transition layers that show a continuous enhancement or abrupt growth trend, as a stage basis for decision-making focus; S5.3: Perform adaptive threshold segmentation on the heatmap corresponding to the key transition layer, combine the Otsu algorithm and morphological closing operation to optimize the boundary continuity, and generate a binarized salient activation region mask to accurately identify the candidate defect locations that form stable concerns in the higher layers of the network. Using the heatmap data matrix corresponding to the key transition layer as the input object, a global pixel statistical analysis method (parameters: input matrix size, pixel intensity range) is adopted to model the overall intensity distribution of significantly activated regions. Furthermore, by using an adaptive threshold segmentation method (parameters: mean adaptation coefficient κ, variance correction factor λ), local threshold determination is achieved for different dynamic ranges of heatmaps, and preliminary binarized salient region image data is obtained. Furthermore, the Otsu algorithm (parameter: number of gray levels 256) is used to optimize the global threshold and generate the optimal threshold that distinguishes significantly active and inactive regions. ; Furthermore, by using the morphological closing operation method (parameters: structuring element type is ellipse, radius r), the smoothing of continuous salient region boundaries and the connection of isolated regions are realized, and a binary mask matrix with optimized boundary continuity is generated. Furthermore, a unique identifier for salient regions is obtained through a connected component analysis algorithm (parameter: 8 neighborhood), and a set of spatial labels for candidate defect locations is generated. Through the above algorithm chain, the heat map focus information generated in the previous step is transformed into spatially clear and boundary-complete binary mask data, so as to achieve accurate calibration of the stable interest area of ​​the network's high layer; For example, in a paper product packaging defect detection scenario, the key transition layer heatmap has a resolution of 256×256 and a pixel intensity range of [0,1]. Global pixel statistical analysis yields a mean of 0.62 and a standard deviation of 0.15. The mean adaptation coefficient κ is set to 1.0, and the variance correction factor λ is set to 0.5. An initial binary image is obtained through adaptive threshold segmentation. Applying the Otsu algorithm with 256 grayscale levels, the threshold T for calculating the maximum value of the inter-class variance curve is 0.58, corresponding to the inter-class variance... It is 0.072, of which The salient region mask is generated by calculating the average pixel value within the region under different threshold segmentation and then optimizing it with a global threshold. An elliptical structuring element with a radius r of 3 pixels is used to perform morphological closing operations, removing boundary burrs and connecting broken regions 2 pixels apart. Through 8-neighbor connected component analysis, three candidate defect region labels are obtained, with center coordinates of (120, 85), (200, 165), and (45, 210), respectively. Each region occupies a significantly larger area and has complete boundaries, making it suitable for subsequent back-projection to a hierarchical feature representation sequence for multi-scale feature activation spectrum construction. S5.4: Based on the back projection of the salient activation region mask onto the original hierarchical feature representation sequence, the channel-level feature response amplitudes of the corresponding spatial locations in different convolutional layers are extracted, and a multi-scale feature activation spectrum of the key feature response region is constructed as an intermediate representation connecting visual attention and semantic rule matching. S5.5: Perform spatial-channel joint clustering analysis on the multi-scale feature activation spectra of key feature response regions, use the DBSCAN algorithm to identify highly consistent response pattern clusters, and output the most representative dominant decision feature clusters and their spatial location boxes, which are then passed as the final input to the semantic rule mapping module to support subsequent semantic interpretation generation.

[0020] Step S6: In the semantic rule mapping module, a matching operation is performed based on a pre-built 'feature response-semantic description' mapping table. This mapping table is encoded and defined according to the local texture patterns, spatial distribution rules, and corresponding historical expert annotation knowledge of typical defect types, thereby transforming key feature response regions into explanatory text in natural language form. Specifically, this includes: S6.1: Based on historical expert-annotated datasets and typical defect sample libraries, extract local texture pattern feature parameters and spatial distribution statistics corresponding to various paper product surface defects (such as wrinkles, stains, scratches, and indentations). The local texture pattern feature parameters include gray-level co-occurrence matrix contrast, main direction of directional gradient histogram, and LBP texture entropy value. The spatial distribution statistics include defect region aspect ratio, edge continuity index, and region clustering index to form a set of semantic feature primitives with physical interpretability. Based on the dominant decision feature cluster and its spatial localization box output from the preceding step S5.5, the corresponding multi-scale feature response data and channel activation spectrum are selected as the analysis objects. The local texture analysis method (parameters: window size 5×5, step size 2 pixels) is used to calculate the gray-level co-occurrence matrix in the key feature response region and extract its contrast parameter to characterize the intensity difference characteristics of gray values ​​in space. Furthermore, the distribution of edge directions in this region is statistically analyzed using the directional gradient histogram calculation method (parameters: 8 number of gradient direction bins, gradient magnitude normalization range [0,1]), and the dominant direction angle is obtained to characterize the geometric orientation features of the defect. Furthermore, the Local Binary Pattern (LBP) operator (parameters: 8 sampling points, radius 1 pixel) is used to encode the texture and calculate its texture entropy value to quantify the complexity and randomness level of the local texture pattern; Furthermore, using spatial morphological analysis (parameter: minimum number of connected pixels is 50), the aspect ratio index is calculated based on the binarized defect region within the positioning box to characterize the macroscopic morphological proportion of the defect. The edge continuity index is calculated using the edge chain code compression method to evaluate the smoothness and integrity of the edge curve. Furthermore, a density-based spatial clustering algorithm (parameters: minimum number of samples is 5, neighborhood radius ε=3 pixels) is used to statistically analyze the clustering index of defect areas to reflect the concentration or dispersion characteristics of defects in spatial distribution. Through the above processing method, texture feature parameters and spatial distribution statistics are integrated to form a set of semantic feature primitives with physical meaning, so as to realize the quantitative representation of defects at two scales: local texture and macro distribution. For example, in the inspection of a batch of white cardboard packaging with production batch number A202401, the system has located a dominant decision feature cluster with a spatial positioning box size of 40×25 pixels. When calculating the gray-level co-occurrence matrix contrast within this area, with a window size of 5×5 pixels and a step size of 2 pixels, the resulting contrast value is... It was determined to be a high-contrast mode; the directional gradient histogram method was used, with the number of bins set to 8, to obtain the dominant direction. The degree conforms to the characteristics of vertical linear texture; the texture entropy value is extracted using the LBP operator parameters P=8 and R=1. This indicates that the texture structure is relatively complex; the aspect ratio of the defects extracted by morphology is... ,Right now The edge continuity index is The display edges are relatively smooth and continuous; the spatial clustering calculation yields a regional clustering index of... This data exhibits a highly concentrated distribution. The semantic feature primitive set generated after integration of this batch of data includes: high-contrast vertical linear texture, complex local texture structure, high edge continuity, and concentrated distribution characteristics. These serve as inputs for subsequent S6.2 fuzzy logic rule encoding and semantic description template construction, significantly improving the accuracy and physical verifiability of the interpretation output. S6.2: For each type of feature primitive in the set of semantic feature primitives, an initial semantic description template is constructed using a fuzzy logic rule encoding mechanism. The fuzzy logic rules set the membership function and inference rules based on expert experience, and map the numerical feature response interval to qualitative language variables. For example, 'high contrast' is defined as the contrast of the gray-level co-occurrence matrix is ​​greater than 0.65, and a preliminary 'feature-semantic' association entry is generated. S6.3: Based on the spatial location and channel activation intensity of the key feature response region output by the convolutional neural network, calculate its projection score on each semantic feature primitive. That is, evaluate the similarity between the current feature map and the preset texture pattern through weighted inner product operation, and obtain the matching confidence of each candidate semantic description template as the quantitative basis for semantic selection. S6.4: Based on the matching confidence ranking results, select the semantic description template with the highest confidence and exceeding the preset threshold, and combine it with the prior structural constraints of the defect category (such as 'scratches' should have linear topology and a single dominant direction) to perform consistency verification. If it passes, it is used as the final activated semantic rule entry; otherwise, the progressive backtracking matching process of the suboptimal candidate template is triggered. S6.5: The activated semantic rule entries are converted into explanatory text in natural language form. Specific numerical parameters and spatial positioning information are embedded using the template filling mechanism to generate compound statements such as "The reason for determining it as a scratch is that a long, thin, low-brightness area with a length greater than 5mm and a directional consistency greater than 85% was detected." This is output to the result integration module as a highly readable decision basis.

[0021] Step S7: Integrate the heatmap sequence, the location boxes of key feature response regions, and the generated explanatory text to output a composite detection report containing a visual evidence chain and semantic explanation for quality traceability and user verification. Specifically, this includes: S7.1: Obtain the heatmap sequence output by step S4, wherein the heatmap sequence is a set of spatial attention weight distributions calculated based on the hierarchical feature representation sequence through a cascaded attention guidance mechanism, and each level corresponds to a heatmap reflecting the attention intensity of potential defect areas; normalize and pseudo-color render the heatmap sequence to generate a multi-level attention visualization image with visual readability, which serves as the visual evidence chain input for the pattern matching process; S7.2: Receive the location bounding box data of the key feature response region determined by step S5, wherein the location bounding box is the dominant decision region located according to the location coordinates of the significantly activated region in the heatmap sequence and the trend of response intensity change; based on the mapping relationship of the location bounding box in the original image space, perform boundary alignment and scale adaptation operations to generate a highlight annotation box that accurately covers the defect instance, and superimpose it onto the preprocessed original image to form a defect schematic diagram with spatial positioning information; S7.3: Obtain the explanatory text in natural language form output from step S6, wherein the text is a semantic description generated by matching the texture pattern and spatial distribution characteristics of key feature response regions with historical expert annotation knowledge through a 'feature response-semantic description' mapping table; perform grammatical normalization and terminology consistency verification on the text to extract standard explanatory statements containing defect types, judgment criteria keywords and confidence indicators, and integrate them into the final report as readability support information; Obtain the natural language form of the explanatory text output by step S6, and use a method based on regularized syntax tree parsing (parameters: including a set of syntax rules and a dictionary of syntactic structures) to perform syntactic structure analysis and tagging of the explanatory text; Furthermore, through a terminology mapping verification algorithm (parameters: industry standard terminology library, synonym replacement table, context relevance coefficient threshold), the standardized replacement of defect type words, judgment criteria keywords and technical feature descriptions in the explanatory text is achieved, and intermediate text that passes the terminology consistency verification is obtained; Furthermore, a confidence indicator generation algorithm (parameters: matching confidence value, prior confidence mapping table, confidence interval boundary setting) is adopted to map the matching confidence value from step S6 into level identifier text and generate a confidence description bound to the defect judgment result, forming a structured description item containing judgment category + keyword + confidence. Furthermore, by using a template-based filling method (parameters: standard explanation statement template, numerical parameter calling interface, spatial positioning formatter), standardized statements, confidence level descriptions, and spatial positioning data are combined into explanation sentences that conform to industry report specifications, and the final standard explanation statement that meets length and readability constraints is output. By using text normalization processing, the semantic description of the previous step is transformed into a structured standard explanation statement that has undergone double verification of syntax and terminology, so as to achieve consistency and traceability of readability support information and visual evidence chain in the detection report. For example, in a batch of paper product surface defect detection instance, the input explanatory text is "The reason for determining it as an indentation is the detection of continuous parallel stripes in the central area with a contrast ratio below 0.45," where the indentation category is obtained by matching a semantic rule mapping table with a confidence value of 0.82. During implementation, the syntax tree parser loads a pre-defined syntactic structure dictionary, segments the original text, and annotates dependencies, identifying the subject "determined as an indentation," the predicate "the reason is the detection of," and the object "continuous parallel stripes in the central area with a contrast ratio below 0.45." It then compares the stem of "indentation" with the terminology database to confirm it belongs to the standard category label. The terminology mapping verification algorithm retrieves and determines the keywords "continuous parallel stripes" and "contrast ratio" based on these keywords, replacing them with the standard terms "parallel texture structure" and "brightness contrast," forming the intermediate text "The reason for determining it as an indentation is the detection of a parallel texture structure in the central area with a brightness contrast ratio below 0.45." The confidence indicator generation algorithm reads the matching confidence value of 0.82, classifies it as "high confidence" according to the prior mapping table, and appends it to the end of the explanation. The template-based filling method calls the spatial positioning interface to map the defect area to "image coordinates (125, 340) - (175, 400)", and generates a standard explanation statement according to the template: "Determined as an indentation [high confidence], because parallel texture structure was detected in the central area and the brightness contrast is lower than 0.45, with location coordinates (125, 340) - (175, 400)". The final generated standard explanation statement in the report presentation achieves consistent terminology, standardized structure, and includes spatial positioning, significantly improving the efficiency of quality audit and client communication; S7.4: Based on the above-processed multi-level attention visualization image, defect diagram with highlighted annotation box, and standardized explanation statement, perform multimodal information spatiotemporal alignment operation, and establish the association index between each component using a unified timestamp and image coordinate system; construct a three-layer structured report template containing an image evidence layer, a spatial annotation layer, and a semantic interpretation layer to achieve the synchronous presentation of visual evidence and logical basis; S7.5: Encapsulate the three-layer structured report template into a serializable composite test report file, wherein the file format adopts an industry standard container format that supports embedded images, vector annotations and text annotations; output the composite test report to a local storage unit or a cloud quality audit system for use in downstream quality traceability processes, customer communication scenarios and model credibility assessments, ensuring that the pattern matching results have complete interpretable output capabilities.

[0022] Step S8: Provide an interactive backtracking interface, allowing quality inspectors to trace the evolution of feature responses at each network layer by clicking on any defect judgment result in the composite inspection report, and dynamically update the rule weights in the semantic rule mapping table based on feedback information, thereby continuously optimizing the model's interpretability. Specifically, this includes: S8.1: Based on the heat map sequence and key feature response area location boxes output in the composite inspection report, construct an interactive visual interface element index table, where each index item is associated with a defect judgment result and its corresponding multi-level feature map identifier, spatial coordinate range and semantic explanation text, to support users to click and trigger operations on any judgment result; S8.2: Perform localization analysis on the defect judgment results clicked by the user in the visualization interface, extract the associated hierarchical feature representation sequence and the heat map sequence generated by the cascaded attention guidance mechanism, and use them as input data to reverse track the feature response evolution process in order to reconstruct the multi-stage neural response path of the judgment decision. S8.3: Based on the extracted hierarchical feature representation sequence and heatmap sequence, calculate the activation intensity gradient change curve of key feature response regions in each network layer, generate feature response evolution trajectory map along the network depth direction, and visualize it in a time-axis aligned manner to reveal the step-by-step reasoning process from low-level edge response to high-level semantic matching. S8.4: Receive expert feedback information submitted by quality inspectors for specific judgment results, including confirmation or correction suggestions on the accuracy of semantic interpretation, and input the feedback information as a supervision signal into the semantic rule mapping module to evaluate the confidence level of relevant rules in the current 'feature response-semantic description' mapping table; S8.5: Based on expert feedback, the rule weights in the 'feature response-semantic description' mapping table are incrementally optimized. Online learning algorithms are used to adjust the matching threshold and priority parameters of each semantic rule to improve the consistency and accuracy of semantic interpretation under subsequent identical or similar feature response patterns, thereby achieving continuous evolution of the model's interpretability.

[0023] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will all fall within the scope of protection of the present invention.

[0024] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and rules of the present invention should be included within the scope of protection of the present invention.

Claims

1. A machine vision-based method for detecting and analyzing surface defects in paper product packaging, characterized in that, Includes the following steps: S1: Acquire high-resolution image data of the surface of paper product packaging, and record the production batch, material type and acquisition location label corresponding to the high-resolution image data to establish an original image dataset; S2: Preprocess the images in the original image dataset to generate preprocessed images; S3: Input the preprocessed image into the trained deep convolutional neural network model, and extract multi-level intermediate feature maps from low level to high level layer by layer to form a hierarchical feature representation sequence; S4: Based on the hierarchical feature representation sequence, calculate the spatial attention weight distribution of each network layer and generate a heatmap sequence corresponding to each layer; S5: Based on the location and response intensity change trend of the significantly activated regions in the heatmap sequence, locate the key feature response regions that dominate the decision-making process, and input them into the semantic rule mapping module as the basis for interpretability analysis. S6: In the semantic rule mapping module, a matching operation is performed based on the pre-built feature response-semantic description mapping table to convert the key feature response region into explanatory text in natural language form; S7: Integrate the heatmap sequence, the location boxes of the key feature response regions, and the explanatory text to output a composite detection report.

2. The method for detecting and analyzing surface defects in paper product packaging based on machine vision according to claim 1, characterized in that, The process following step S7 also includes: S8: Provides an interactive backtracking interface, allowing quality inspectors to trace the evolution of the feature response at each network layer by clicking on any defect judgment result in the composite inspection report, and dynamically update the rule weights in the semantic rule mapping table based on the feedback information.

3. The method for detecting and analyzing surface defects in paper product packaging based on machine vision according to claim 1, characterized in that, Step S1 specifically includes: High-resolution images of paper product packaging surfaces are acquired using an industrial vision imaging system to obtain raw image data. The original image data is tagged with structured metadata. The production batch number, substrate weight, coating type and roller pressure parameters of the current workstation are read in real time by the PLC control system and stored as working condition identification information bound to the image data to generate structured image entries. Based on the acquisition timestamp and physical location code in the structured image entries, the axial and lateral coordinate positions of each image on the entire roll of material are determined using encoder signal mapping, and acquisition location labels are generated. Based on a set of image entries with working condition labels and spatial coordinates, a classification index is constructed in three dimensions: batch, material, and location, to generate an original image dataset that covers the differences in multiple working conditions. The original image dataset containing multi-condition differences is subjected to integrity verification and deduplication. The hash fingerprint algorithm is used to detect duplicate images, and the metadata consistency verification mechanism is combined to remove mismatched or missing entries.

4. The method for detecting and analyzing surface defects in paper product packaging based on machine vision according to claim 3, characterized in that, The industrial vision imaging system includes a line scan camera, a synchronous trigger control unit, and a constant illumination module.

5. The method for detecting and analyzing surface defects in paper product packaging based on machine vision according to claim 1, characterized in that, Step S2 specifically includes: Based on the high-resolution grayscale or RGB images in the original image dataset, calculate the spatial illumination distribution map of each image, and perform downsampling and smoothing on the spatial illumination distribution map to obtain a standardized illumination field template. A pixel-by-pixel division operation is performed on the original image set based on the standardized illumination field template to generate an intermediate image after illumination normalization. The intermediate image is then subjected to nonlinear intensity mapping to obtain a normalized image sequence. For the normalized image sequence, a noise suppression processing is performed using a non-local mean-based denoising algorithm, and the denoised image is output. An edge enhancement operation is performed on the denoised image to generate an enhanced edge map; The enhanced edge map is linearly fused with the background image after illumination normalization and denoising based on weight coefficients to generate a preprocessed image.

6. The method for detecting and analyzing surface defects in paper product packaging based on machine vision according to claim 1, characterized in that, Step S3 specifically includes: A preprocessed image is obtained as the input object. Based on the forward propagation mechanism of the deep convolutional neural network model, an initial convolution operation is performed on the preprocessed image. The low-level visual features in the image are extracted using the first-level convolutional kernel to generate a primary feature map. Using the primary feature map as input, multi-scale receptive field expansion processing is performed, and dilated convolution modules with different dilation rates are used to capture medium-complexity texture patterns in the local neighborhood; the activation response intensity of each channel is calculated, and batch normalization and nonlinear activation function transformation are performed to output the intermediate feature map. The intermediate feature map is input into the deep residual structure of the network. The gradient degradation problem is alleviated based on the cross-layer identity mapping mechanism. At the same time, semantic features with class discrimination are extracted through the high-level convolutional layer before global average pooling. The spatial response distribution of the high-level feature map is calculated to obtain the high-level semantic feature map. Based on the time synchronization constraints of the primary feature map, the intermediate feature map, and the high-level feature map, spatial alignment and resolution matching processing are performed on the feature map sequences output from each level. Multi-scale information is fused using upsampling and skip connections to generate a hierarchical feature representation sequence.

7. The method for detecting and analyzing surface defects in paper product packaging based on machine vision according to claim 6, characterized in that, The primary feature map contains edges, corners, and basic texture structures.

8. The method for detecting and analyzing surface defects in paper product packaging based on machine vision according to claim 1, characterized in that, Step S4 specifically includes: The sequence of multi-level intermediate feature maps output layer by layer by the deep convolutional neural network during the forward propagation process is obtained as the input data source for spatial attention calculation. Based on the feature response tensor of each layer in the intermediate feature map sequence, a corresponding channel attention vector is generated by channel-dimensional global average pooling operation, and then reshaped into a spatial attention weight matrix with consistent spatial dimensions. A cascaded cross-layer feedback enhancement process is performed on the spatial attention weight matrix. The attention mask of the high-level semantic layer is used to modulate and optimize the weights of the low-level detail layer. By passing salient region cues back layer by layer, a refined spatial attention weight distribution is generated. Based on the refined spatial attention weight distribution, it is fused with the original intermediate feature map of the corresponding level element by element to calculate the feature response map of each level after attention enhancement, and the feature response map is normalized to a unified interval to generate a single-channel heat map. Integrate the single-channel heatmaps generated from all network levels to form a heatmap sequence sorted by network depth.

9. The method for detecting and analyzing surface defects in paper product packaging based on machine vision according to claim 8, characterized in that, In the multi-level intermediate feature map sequence, each feature map corresponds to a two-dimensional feature response tensor extracted from a specific layer in the network.

10. The method for detecting and analyzing surface defects in paper product packaging based on machine vision according to claim 1, characterized in that, Step S5 specifically includes: Based on the generated heatmap sequence, calculate the spatial saliency score of each level of heatmap; Based on the spatial saliency scores of heatmaps at each level, cross-level response trend analysis is performed. The sliding window method is used to detect the evolution path of response intensity of significantly activated regions between low-level and high-level network layers, and key transition layers that show a continuous enhancement or abrupt growth trend are identified. An adaptive threshold segmentation process is performed on the heatmap corresponding to the key transition layer to generate a binarized mask of significant activation regions. Based on the back projection of the salient activation region mask onto the original hierarchical feature representation sequence, the channel-level feature response amplitudes of the corresponding spatial locations in different convolutional layers are extracted to construct the multi-scale feature activation spectrum of the key feature response region. Spatial-channel joint clustering analysis is performed on the multi-scale feature activation spectra of the key feature response regions to identify highly consistent response pattern clusters and output the most representative dominant decision feature clusters and their spatial positioning boxes.