Bamboo strip defect detection method based on PINet network
By constructing feature extraction, fusion, and detection modules of the PINet network, and combining Triplet Attention and adaptive channel allocation convolutional units, the problem of fine-grained feature extraction and multi-scale fusion in bamboo strip surface defect detection is solved, achieving a combination of high accuracy and real-time performance to meet industrial inspection needs.
Patent Information
- Application Number
- CN202511685078.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-17
- Publication Date
- 2026-02-27
AI Technical Summary
Existing technologies for detecting surface defects in bamboo strips suffer from insufficient extraction of fine-grained defect features, weak discriminative ability of multi-scale feature fusion, and inaccurate localization of small defects in complex backgrounds. This makes it difficult to balance detection accuracy and real-time performance, and fails to meet the high requirements of industrial real-time detection.
A detection method based on the PINet network is adopted. By constructing a network architecture that includes a feature extraction module, a feature fusion module and a detection head module, the EfficientViT structure with the Triplet Attention mechanism is used to extract multi-scale defect features. In addition, feature enhancement and spatial weight enhancement are achieved by combining adaptive channel allocation convolutional units and localization-aware attention units. Finally, defect category information and location coordinate information are output.
It significantly enhances the ability to characterize fine-grained defects on the surface of bamboo strips, improves the discriminative power of multi-scale feature fusion and the positioning accuracy of small defects in complex backgrounds, and meets the performance requirements of real-time industrial detection.
Smart Images

Figure CN121582167A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer technology, and in particular to a bamboo strip defect detection method based on a PINet network. BACKGROUND
[0002] As an important green renewable material, the accurate detection of surface defects of bamboo material is a key link to ensure the quality of bamboo products. At present, bamboo processing enterprises mostly use manual visual inspection for defect recognition, which is low in efficiency and easily affected by subjective factors. Although researchers have tried to introduce detection methods based on traditional machine learning or general deep learning models (such as the YOLO series) to improve the level of automation, traditional methods rely on manually designed features and have insufficient generalization ability. Existing deep learning models generally have problems such as insufficient extraction of fine-grained defect features, weak discrimination of multi-scale feature fusion, and inaccurate positioning of small defects in complex backgrounds, which makes it difficult to balance detection accuracy and real-time performance and cannot meet the high requirements of industrial real-time detection. SUMMARY
[0003] Therefore, the purpose of the present application is to provide a bamboo strip defect detection method based on a PINet network.
[0004] In order to achieve the above technical purpose, the technical scheme adopted by the present application is: A bamboo strip defect detection method based on a PINet network, comprising: Collecting sample bamboo strip surface image data to construct a training sample set containing multiple defect types; Constructing a PINet detection network, which includes a feature extraction module, a feature fusion module and a detection head module connected in turn; The feature extraction module adopts an EfficientViT structure with a fusion Triplet Attention mechanism, extracts multi-scale defect features on the surface of the bamboo strip through cross-dimension interaction, and outputs a primary feature map; The feature fusion module receives the primary feature map, dynamically weights and allocates the feature channels through an adaptive channel allocation convolution unit, generates an enhanced feature representation, and simultaneously strengthens the spatial weight of the defect area through a positioning perception attention unit, and outputs an optimized feature map that fuses multi-scale context information; The detection head module receives the optimized feature map, processes it through a convolution layer and a classification regression layer, and outputs a detection result containing defect class probability and bounding box coordinates; The training sample set is input into the PINet detection network for end-to-end training to obtain a trained bamboo strip defect detection model; Input the image of the bamboo strip to be detected into the trained bamboo strip defect detection model, and output the defect category information and the position coordinate information; Generate a bamboo strip surface defect detection report based on the defect category information and the position coordinate information.
[0005] In some embodiments, the feature extraction module adopts an EfficientViT structure with a fused Triplet Attention mechanism, extracts multi-scale defect features of the bamboo strip surface through cross-dimensional interaction, and outputs a primary feature map, including: The input sample bamboo strip surface image is compressed in spatial dimension and expanded in channel dimension through the downsampling module to obtain an initial feature representation; The initial feature representation is input into the cascaded group attention module with a sandwich layout to optimize the calculation efficiency by reducing the proportion of memory access intensive attention layers and increasing the proportion of feedforward network layers; In the cascaded group attention module, the feature channels are divided into multiple attention calculation groups, and each group generates a query matrix, a key matrix, and a value matrix respectively; The attention calculation groups are adaptively selected according to the feature map size of the initial feature representation, including: When the feature map size of the initial feature representation is smaller than a preset window size, a global attention calculation group is adopted to model the dependency relationship in the whole image; When the feature map size of the initial feature representation is greater than the preset window size, a local attention calculation group with window division is adopted to perform feature interaction in a local area; The enhanced features after attention calculation group are input into the Triplet Attention module to calculate the attention weights in three orthogonal dimensions of width-height plane, high-channel plane, and wide-channel plane respectively; The maximum pooling and average pooling are simultaneously performed on each dimension through ZPool operation, and the results output from each dimension are spliced; The spliced features are input into a convolution layer for local context relationship extraction, and then a Sigmoid activation function is used to generate the attention output of each dimension; The attention outputs of the three dimensions are fused to obtain enhanced cross-dimensional interaction features; The cross-dimensional interaction features are nonlinearly transformed and feature-regularized through a feedforward network to output a primary feature map containing multi-scale semantic information.
[0006] In some embodiments, the feature fusion module receives the primary feature map, dynamically weights and allocates the feature channels through an adaptive channel allocation convolution unit, and generates an enhanced feature representation, including: The primary feature map is input into the adaptive channel allocation convolution unit, and the channel weights of each convolution branch are generated through a learnable parameter matrix; The channel weights are normalized by a Softmax function to obtain channel attention weights of each branch; The primary feature map is multiplied by the channel attention weights of each branch channel by channel to realize adaptive allocation of feature channels and obtain weighted features; The weighted features are respectively input into two parallel convolution branches, including: The first branch adopts a standard convolution operation to extract local texture features, which are used to capture subtle defects on the surface of bamboo strips to obtain first output features; The second branch adopts a receptive field attention convolution operation to extract global context features, which are used to enhance the defect recognition ability in complex backgrounds to obtain second output features; The first output features and the second output features are spliced in the channel dimension to obtain enhanced feature representations that fuse local details and global semantics.
[0007] In some embodiments, the spatial weight of the defect area is strengthened by positioning perception attention units, and an optimized feature map that fuses multi-scale context information is output, including: The enhanced feature representation is input into the positioning perception attention unit, the feature map is pooled along the horizontal direction to generate horizontal direction perception features; And, the feature map is pooled along the vertical direction to generate vertical direction perception features; The horizontal direction perception features are one-dimensional convolution processed and grouped normalized, and then the horizontal direction spatial attention weights are generated by a Sigmoid function; The vertical direction perception features are one-dimensional convolution processed and grouped normalized, and then the vertical direction spatial attention weights are generated by a Sigmoid function; The horizontal direction spatial attention weights and the vertical direction spatial attention weights are fused to obtain comprehensive spatial attention weights; The comprehensive spatial attention weights are multiplied by the enhanced feature representation element by element to realize the spatial weight strengthening of the defect area, and an optimized feature map containing multi-scale context information and having positioning ability is output.
[0008] In some embodiments, the detection head module receives the optimized feature map, processes it through a convolution layer and a classification regression layer, and outputs a detection result containing defect category probability and bounding box coordinates, including: The optimized feature map is input into a multi-scale feature pyramid structure to realize the fusion of feature maps of different scales through upsampling and downsampling operations; A detection branch is set at each scale level of the feature pyramid, and each detection branch contains a parallel classification convolution layer and a regression convolution layer; The defect category probability distribution of each preset anchor point is generated by a classification convolutional layer, and the defect categories include yellow-black knot, green-black knot, flat yellow, concave yellow and damage; The boundary box coordinate offset and size adjustment parameter of each preset anchor point are generated by a regression convolutional layer; The classification prediction is optimized by using a distribution focal loss function, and the position prediction is optimized by using a boundary box regression loss function; The detection results of each scale level are subjected to non-maximum suppression processing to eliminate overlapping detection boxes; The final defect detection result is output, including defect category confidence, boundary box coordinates and defect size information.
[0009] In some embodiments, the classification prediction is optimized by using a distribution focal loss function, including: A soft label representation of the category probability distribution is constructed, and the smoothing degree of the probability distribution is adjusted by a temperature parameter; The Kullback-Leibler divergence between the predicted probability distribution and the real label distribution is calculated as the classification loss; A focal adjustment factor is introduced, and higher loss weight is given to samples that are difficult to classify; The positioning accuracy of each predicted box is weighted by a boundary box quality evaluation function; The classification loss and the positioning quality loss are jointly optimized to obtain the optimized classification prediction result and output.
[0010] In some embodiments, the training sample set is input into the PINet detection network for end-to-end training to obtain a training complete bamboo strip defect detection model, including: A knowledge distillation training framework is constructed, taking the PINet detection network as the teacher model and taking the lightweight network with half the number of channels as the student model; The same training sample is input into the teacher model and the student model, and the network parameters of the teacher model remain frozen during the training process; The feature distillation loss of the teacher model and the student model on the corresponding intermediate feature layer is calculated by a channel distillation mechanism, and the feature distribution difference between the teacher model and the student model in the channel dimension is minimized; The logical distillation loss of the teacher model and the student model on the output layer is calculated by a balanced collaborative knowledge distillation mechanism, and the logical distillation loss includes a classification distribution difference loss based on Kullback-Leibler divergence and a boundary box prediction difference loss based on binary cross entropy; The feature distillation loss and the logical distillation loss are weighted and fused according to a preset weight coefficient to obtain the total distillation loss; The total distillation loss is combined with a base loss of the detection task, and the base loss of the detection task includes a bounding box regression loss, a classification loss, and a distribution focal loss. The cosine attenuation algorithm is used to dynamically adjust the weight coefficient of the total distillation loss in the combined loss, and a lower weight is set in the early training stage to focus on basic feature learning, and the weight is gradually increased in the later training stage to strengthen distillation supervision. The network parameters of the student model are updated through the gradient back propagation algorithm, and the model is iteratively optimized until it converges, obtaining a bamboo defect detection model.
[0011] In some embodiments, sample bamboo surface image data is collected, and a training sample set containing multiple defect types is constructed, including: The original sample bamboo surface image data is collected under standard industrial lighting conditions, and the original sample bamboo surface image data contains five defect types: yellow-black knot, green-black knot, flat yellow, concave yellow, and damage; The original sample bamboo surface image data is preprocessed, and the preprocessing operation includes image size normalization, illumination equalization, and noise filtering processing; The training sample size is expanded through data augmentation, and the data augmentation includes random rotation, scale transformation, color jittering, and mirror flipping; The enhanced image data is labeled for defect regions using a bounding box labeling tool, and a labeled file containing defect class labels and position coordinates is generated; The labeled image data is divided into a training set, a validation set, and a test set according to a predetermined ratio; The divided data set is converted to generate a standardized training sample set that meets the input requirements of the PINet detection network.
[0012] In some embodiments, the bamboo image to be detected is input into the trained bamboo defect detection model, and the defect class information and position coordinate information are output, including: The bamboo image to be detected is preprocessed, and the preprocessing operation includes image size standardization, illumination consistency correction, and noise elimination processing; The preprocessed bamboo image to be detected is input into the feature extraction module of the bamboo defect detection model, and multi-scale defect features are extracted through the EfficientViT structure with Triplet Attention mechanism fusion; The extracted multi-scale defect features are input into the feature fusion module, and feature enhancement and spatial weight reinforcement are performed through the adaptive channel allocation convolution unit and the positioning perception attention unit, obtaining an optimized defect feature map; The optimized defect feature map is input into the detection head module, and an initial detection result is generated through multi-scale detection branches, and the initial detection result contains defect class probability distribution and bounding box coordinate information; The initial detection result is filtered by a confidence threshold, and the detection result with a confidence higher than a preset threshold is retained; The filtered detection result is subjected to a non-maximum suppression process to eliminate overlapping redundant detection boxes; The final defect category information and position coordinate information are output, the defect category information includes a defect type identifier, and the position coordinate information includes a center point coordinate and a size parameter of a bounding box.
[0013] In some embodiments, a bamboo strip surface defect detection report is generated based on the defect category information and the position coordinate information, including: The defect category information is subjected to statistical analysis to calculate the occurrence frequency and distribution density of each type of defect; A defect spatial distribution map is generated according to the position coordinate information, and the specific position of each type of defect on the bamboo strip surface is marked; Based on the defect size parameter, the detected defects are classified into grades to generate a quality evaluation result; The defect category information, the position coordinate information, the defect size parameter and the quality evaluation result are integrated to generate structured detection data; According to a preset report template, the structured detection data is converted into a visual detection report, and the visual detection report includes defect statistical charts, a spatial distribution diagram and a quality grade evaluation; A complete bamboo strip surface defect final draft bamboo strip surface defect detection report is output, which includes detection time, detection result summary and quality suggestion.
[0014] Compared with the prior art, the technical scheme has the beneficial effects that: Unlike the prior art, the technical scheme constructs a PINet detection network including a feature extraction module, a feature fusion module and a detection head module, and uses an EfficientViT structure with a fusion Triplet Attention mechanism to perform multi-scale defect feature extraction, combines a self-adaptive channel allocation convolution unit and a positioning perception attention unit to realize feature enhancement and spatial weight reinforcement, and finally outputs defect category information and position coordinate information. The technical scheme significantly enhances the feature representation capability of fine-grained defects on the bamboo strip surface through cross-dimension interaction and dynamic channel weighting mechanism, effectively improves the discriminability of multi-scale feature fusion and the positioning accuracy of small defects in complex backgrounds, thereby ensuring high detection accuracy while meeting the efficiency requirements of industrial real-time detection. BRIEF DESCRIPTION OF DRAWINGS
[0015] In order to make the technical solutions in the embodiments of the present application or the prior art clearer, the accompanying drawings needed in the embodiments or prior art description will be briefly introduced below. Obviously, the accompanying drawings in the following description only aim to explain some embodiments of the present application, and all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present application.
[0016] Figure 1 is the first schematic diagram of the bamboo strip detection described in the detailed description; Figure 2 is the second schematic diagram of the bamboo strip detection described in the detailed description. DETAILED DESCRIPTION
[0017] The present application will be further described in detail below in combination with the accompanying drawings and embodiments. It is particularly pointed out that the following embodiments are only used to illustrate the present application, but do not limit the scope of the present application. Similarly, the following embodiments are only some embodiments of the present application, not all embodiments, and all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present application.
[0018] Please refer to Figure 1 and Figure 2 The present embodiment provides a bamboo strip defect detection method based on a PINet network, comprising: S101, collecting sample bamboo strip surface image data, and constructing a training sample set containing multiple defect types; S102, constructing a PINet detection network, the PINet detection network comprising a feature extraction module, a feature fusion module and a detection head module connected in turn; The feature extraction module adopts an EfficientViT structure with a fused Triplet Attention mechanism, extracts multi-scale defect features on the surface of the bamboo strip through cross-dimension interaction, and outputs a primary feature map; The feature fusion module receives the primary feature map, dynamically weights and allocates the feature channels through an adaptive channel allocation convolution unit, generates an enhanced feature representation, and simultaneously strengthens the spatial weight of the defect area through a positioning perception attention unit, and outputs an optimized feature map fused with multi-scale context information; The detection head module receives the optimized feature map, processes it through a convolution layer and a classification regression layer, and outputs a detection result containing defect category probability and bounding box coordinates; S103, inputting the training sample set into the PINet detection network for end-to-end training, and obtaining a trained bamboo strip defect detection model; S104, inputting the bamboo strip image to be detected into the trained bamboo strip defect detection model, and outputting defect category information and position coordinate information; S105, generate a bamboo strip surface defect detection report based on the defect category information and the position coordinate information.
[0019] In step S101, the sample bamboo strip surface image data refers to a digital image of the bamboo strip surface collected by an industrial camera under standard lighting conditions, containing five typical defect types of yellow-black knot, green-black knot, flat yellow, concave yellow and damage. The training sample set is constructed by data enhancement methods, including random rotation, scale transformation and color jittering operations, for expanding sample diversity and improving model generalization ability. By establishing a standardized image data set, sufficient quality supervision signals are provided for subsequent model training.
[0020] In step S102, the PINet detection network adopts a three-module cascading architecture. In the feature extraction module, the EfficientViT structure realizes global feature modeling through cascading group attention mechanism, and the Triplet Attention mechanism calculates attention weights in three orthogonal dimensions to enhance the perception ability of fine-grained defects. In the feature fusion module, the adaptive channel allocation convolution unit dynamically allocates channel weights through a learnable parameter matrix, and the location perception attention unit generates a spatial attention map through directional pooling and one-dimensional convolution. The detection head module generates defect category probability and bounding box coordinates through multi-scale detection branches. Through the cooperative design of feature extraction, fusion and detection, a detection architecture that balances accuracy and efficiency is constructed.
[0021] In step S103, end-to-end training refers to the complete optimization process of directly inputting the training sample set into the PINet detection network for forward propagation and backward propagation. During the training process, a stochastic gradient descent optimizer is used, and a learning rate decay strategy is set to make the model parameters converge through joint optimization of classification loss and regression loss. Preferably, the number of training rounds is set to 300 rounds, and the batch size is set to 32. After the performance of the verification set is stable, a trained bamboo defect detection model is obtained. Through end-to-end supervised learning, the network automatically learns the mapping relationship from the input image to the defect detection.
[0022] In step S104, the bamboo image to be detected needs to go through the same preprocessing procedure as the training sample, including size standardization and illumination correction. The trained bamboo defect detection model performs forward inference on the input image, sequentially passes through feature extraction, feature fusion and detection head processing, and finally outputs defect category information and position coordinate information. Preferably, the detection results are subjected to non-maximum suppression processing to eliminate overlapping detection boxes. The automatic detection of bamboo surface defects is realized, providing reliable data support for quality evaluation.
[0023] In step S105, the bamboo strip surface defect detection report is generated by integrating defect category information and location coordinate information, including defect statistical distribution, spatial positioning diagram and quality grade evaluation. The report generation process is automatically completed based on a preset template, and the output format can be customized according to actual needs. The detection results are converted into intuitive quality evaluation documents to provide direct basis for production decisions.
[0024] The embodiment realizes the automatic and accurate detection of bamboo strip surface defects by constructing a special PINet detection network. The feature extraction module combines the advantages of visual Transformer and attention mechanism to effectively capture fine-grained defect features on the surface of bamboo; the feature fusion module improves the discrimination ability of multi-scale features through adaptive channel allocation and spatial weight enhancement; and the end-to-end training method ensures the stability of the model in actual application.
[0025] In some embodiments, the feature extraction module adopts an EfficientViT structure with a Triplet Attention mechanism, which extracts multi-scale defect features on the surface of bamboo strips through cross-dimension interaction, and outputs primary feature maps, including: The input sample bamboo strip surface image is compressed in spatial dimension and expanded in channel dimension through the downsampling module to obtain an initial feature representation; The initial feature representation is input into the cascaded group attention module with a sandwich layout to optimize the calculation efficiency by reducing the proportion of memory access intensive attention layers and increasing the proportion of feedforward network layers; In the cascaded group attention module, the feature channels are divided into multiple attention calculation groups, and each group generates a query matrix, a key matrix and a value matrix respectively; The attention calculation groups are adaptively selected according to the feature map size of the initial feature representation, including: When the feature map size of the initial feature representation is less than a preset window size, global attention calculation groups are used to model the dependency relationship in the whole image; When the feature map size of the initial feature representation is greater than the preset window size, local attention calculation groups are used to perform feature interaction in local regions through window division; The enhanced features are input into the Triplet Attention module to calculate the attention weights in three orthogonal dimensions: width-height plane, high-channel plane and wide-channel plane; The maximum pooling and average pooling are simultaneously performed on each dimension through ZPool operation, and the results output from each dimension are spliced; The spliced features are input into the convolution layer to extract local context relationships, and then the Sigmoid activation function is used to generate the attention output of each dimension; The three-dimensional attention outputs are fused to obtain enhanced cross-dimension interaction features. The cross-dimension interaction features are non-linearly transformed and reorganized by a feedforward network to output a primary feature map containing multi-scale semantic information.
[0026] In this embodiment, the downsampling module realizes spatial dimension compression and channel dimension expansion through a convolution layer, converts the high-resolution features of the input image into an initial feature representation with rich channel information, and retains key texture information through hierarchical sampling to provide adaptive feature input for subsequent attention calculation. The sandwich layout adopts an inter-layer configuration of feedforward network-attention-feedforward network, and optimizes the calculation efficiency by reducing the proportion of memory access-intensive attention layers. The cascaded group attention module divides the feature channels into multiple attention calculation groups, and each group independently generates a query matrix, a key matrix and a value matrix to realize parallel feature interaction calculation.
[0027] In this embodiment, the adaptive attention selection mechanism dynamically adjusts the calculation strategy according to the feature map size. When the feature map size is smaller than the preset window size, global attention calculation grouping is adopted to establish a dependency relationship in the whole image range; when the feature map size is larger than the preset window size, local attention calculation grouping is adopted through window division to realize feature interaction in local regions while maintaining calculation efficiency. The Triplet Attention module calculates attention weights in three orthogonal dimensions of the width-height plane, the high-channel plane and the wide-channel plane. The ZPool operation simultaneously performs maximum pooling and average pooling in each dimension, concatenates the two pooling results, extracts local context relationships through a convolution layer, and then generates attention outputs in each dimension through a Sigmoid function. The cross-dimension interaction features are obtained by weighted fusion of the attention outputs in the three dimensions, the fused features are non-linearly transformed and reorganized by a feedforward network through a multi-layer perceptron structure, and finally a primary feature map containing multi-scale semantic information is output. The multi-dimensional feature interaction effectively enhances the model's perception ability for the subtle defects on the bamboo strip surface.
[0028] This embodiment combines downsampling, adaptive attention calculation and cross-dimension feature interaction to construct an efficient feature extraction process. The sandwich layout optimizes the allocation of computing resources, and the Triplet Attention mechanism strengthens the multi-dimensional feature representation. The finally output primary feature map provides a feature basis with rich semantic information for subsequent defect detection tasks.
[0029] In some embodiments, the feature fusion module receives the primary feature map, dynamically weights and allocates the feature channels through an adaptive channel allocation convolution unit to generate an enhanced feature representation, including: The primary feature map is input to an adaptive channel allocation convolution unit, and channel weights of each convolution branch are generated through a learnable parameter matrix; The channel weights are normalized by a Softmax function to obtain channel attention weights of each branch; The primary feature map is multiplied with the channel attention weights of each branch in a channel-by-channel manner to achieve adaptive allocation of feature channels, and weighted features are obtained; The weighted features are respectively input to two parallel convolution branches, including: The first branch uses standard convolution operation to extract local texture features, which are used to capture subtle defects on the surface of bamboo strips, and first output features are obtained; The second branch uses a receptive field attention convolution operation to extract global context features, which are used to enhance the defect recognition ability in a complex background, and second output features are obtained; The first output features and the second output features are spliced in the channel dimension to obtain enhanced feature representation that fuses local details and global semantics.
[0030] In this embodiment, the adaptive channel allocation convolution unit dynamically generates channel weights of each convolution branch through a learnable parameter matrix. These weight parameters are automatically optimized through gradient backpropagation during the training process, and can adaptively adjust the importance distribution of different channels according to the content characteristics of the input features, so that the network can automatically identify and strengthen the key feature channels related to defect detection.
[0031] In this embodiment, the Softmax function normalizes the channel weights to ensure that the sum of the weights of each branch is 1, forming a reasonable probability distribution. The channel attention weights are multiplied with the primary feature map in a channel-by-channel manner to achieve adaptive re-labeling of feature channels, so that the network can focus on feature channels with abundant information while suppressing the interference of redundant or noisy channels.
[0032] In this embodiment, the two parallel convolution branches use different convolution strategies. The standard convolution operation of the first branch uses a fixed-size convolution kernel, focusing on extracting local texture features on the surface of bamboo strips, such as subtle cracks and spots; the receptive field attention convolution of the second branch adaptively adjusts the receptive field size through deformable convolution or spatial attention mechanism, effectively capturing global context information on the surface of bamboo strips. The first output features and the second output features are spliced in the channel dimension to achieve complementary features of local details and global semantics. The double-branch structure retains the sensitivity of traditional convolution to local features and introduces the perception ability of receptive field attention to global context, significantly improving the comprehensiveness and discriminability of feature representation.
[0033] The embodiment cooperatively designs adaptive channel allocation and double-branch feature extraction to construct an efficient feature fusion mechanism. Dynamic channel weighting strengthens the representation of key features, and parallel convolution structure realizes the complementarity of local and global features, and finally generates enhanced feature representation to provide a more discriminative feature basis for subsequent defect detection.
[0034] In some embodiments, the spatial weight of the defect area is strengthened by positioning the perception attention unit, and an optimized feature map fused with multi-scale context information is output, including: The enhanced feature representation is input into the positioning perception attention unit, the feature map is pooled along the horizontal direction to generate horizontal direction perception features; And the feature map is pooled along the vertical direction to generate vertical direction perception features; The horizontal direction perception features are one-dimensional convolution processed and grouped normalized, and then the horizontal direction spatial attention weight is generated through the Sigmoid function; The vertical direction perception features are one-dimensional convolution processed and grouped normalized, and then the vertical direction spatial attention weight is generated through the Sigmoid function; The horizontal direction spatial attention weight and the vertical direction spatial attention weight are fused to obtain comprehensive spatial attention weight; The comprehensive spatial attention weight and the enhanced feature representation are multiplied element by element to realize the spatial weight strengthening of the defect area, and an optimized feature map containing multi-scale context information and having positioning ability is output.
[0035] In the embodiment, the positioning perception attention unit generates horizontal direction perception features and vertical direction perception features by pooling the enhanced feature representation along the horizontal direction and the vertical direction respectively. This direction-separated pooling operation can independently capture the statistical characteristics of the feature map in two orthogonal space dimensions, providing a basis for generating direction-sensitive spatial attention subsequently.
[0036] In the embodiment, the horizontal direction perception features and the vertical direction perception features are respectively one-dimensional convolution processed, and the corresponding spatial attention weights are generated through the Sigmoid function after grouping normalization to stabilize the training process. One-dimensional convolution can effectively model the context dependency along a specific direction, and grouping normalization ensures the stability of feature distribution under different batch sizes.
[0037] In the embodiment, the horizontal direction spatial attention weight and the vertical direction spatial attention weight are fused by matrix multiplication to obtain comprehensive spatial attention weight. This fusion method can establish the spatial correlation between the horizontal and vertical directions, form a complete two-dimensional spatial attention map, and accurately reflect the importance of each position in the feature map.
[0038] In this embodiment, the spatial attention weight is multiplied with the enhanced feature representation element by element to realize the spatial weight enhancement of the defect area. This operation can adaptively enhance the feature response of the defect related area while suppressing the background interference, so that the network pays more attention to the potential defect position on the bamboo strip surface.
[0039] In this embodiment, the spatial attention mechanism with direction separation realizes accurate positioning and feature enhancement of the defect area. The dual-path processing preserves the spatial direction information, and the weight fusion ensures the integrity of the attention map. The final output of the optimized feature map has stronger spatial discrimination ability, providing reliable positioning information support for subsequent defect detection.
[0040] In some embodiments, the detection head module receives the optimized feature map, processes it through convolution layers and classification regression layers, and outputs detection results containing defect category probabilities and bounding box coordinates, including: The optimized feature map is input into a multi-scale feature pyramid structure to realize the fusion of feature maps of different scales through upsampling and downsampling operations; A detection branch is set at each scale level of the feature pyramid, and each detection branch contains parallel classification convolution layers and regression convolution layers; The classification convolution layer generates a defect category probability distribution for each preset anchor point, and the defect categories include yellow-black knot, green-black knot, flat yellow, concave yellow, and damage; The regression convolution layer generates a bounding box coordinate offset and a size adjustment parameter for each preset anchor point; A distributed focal loss function is used to optimize classification prediction, and a bounding box regression loss function is used to optimize position prediction; The detection results of each scale level are subjected to non-maximum suppression processing to eliminate overlapping detection boxes; The final defect detection results are output, including defect category confidence, bounding box coordinates, and defect size information.
[0041] In this embodiment, the multi-scale feature pyramid structure realizes the fusion of feature maps of different scales through upsampling and downsampling operations. The upsampling operation expands the feature map size through interpolation or transposed convolution, and the downsampling operation reduces the feature map size through pooling or step convolution, thereby constructing a feature pyramid containing multi-level semantic information and effectively improving the model's detection ability for defects of different sizes.
[0042] In this embodiment, each detection branch contains parallel classification convolution layers and regression convolution layers. The classification convolution layer calculates the probability distribution of each preset anchor point belonging to each defect category through convolution kernels, and the regression convolution layer predicts the coordinate offset and size adjustment parameter of the bounding box relative to the preset anchor point. This parallel structure realizes efficient collaborative processing of classification and positioning tasks.
[0043] In this embodiment, the focal loss function optimizes the classification prediction by adjusting the weight of difficult samples, and the bounding box regression loss function optimizes the position prediction by calculating the position difference between the predicted box and the real box. The cooperative optimization of the two loss functions ensures the balanced performance of the model in classification accuracy and positioning accuracy.
[0044] In this embodiment, the non-maximum suppression process eliminates redundant detection results by calculating the intersection over union between detection boxes, retaining the detection box with the highest confidence, and effectively solving the problem of multiple detections of the same defect, ensuring the simplicity and accuracy of the final output results.
[0045] This embodiment constructs an efficient defect detection output mechanism through multi-scale feature fusion, parallel detection branch and loss function optimization. The feature pyramid ensures effective detection of multi-scale defects, the parallel branch realizes accurate prediction of classification and positioning, and the post-processing operation guarantees the reliability of the output results, ultimately providing a complete technical solution for bamboo strip surface defect detection.
[0046] In some embodiments, the focal loss function is used to optimize the classification prediction, including: A soft label representation of the class probability distribution is constructed, and the smoothness of the probability distribution is adjusted by a temperature parameter; The Kullback-Leibler divergence between the predicted probability distribution and the real label distribution is calculated as the classification loss; A focal adjustment factor is introduced to give higher loss weight to samples that are difficult to classify; The positioning accuracy of each predicted box is weighted by a bounding box quality evaluation function; The classification loss and the positioning quality loss are jointly optimized to obtain the optimized classification prediction result and output.
[0047] In this embodiment, the soft label representation of the class probability distribution adjusts the smoothness of the probability distribution by a temperature parameter. The temperature parameter is used to control the sharpness of the probability distribution. When the temperature parameter is greater than 1, the probability distribution is smoother, which can preserve the similarity information between classes and help the model learn more rich class relationships.
[0048] In this embodiment, the Kullback-Leibler divergence is used to measure the difference between the predicted probability distribution and the real label distribution. This divergence can effectively capture the difference in overall shape between the two probability distributions, and compared with the traditional cross-entropy loss, it can better reflect the subtle differences in probability distribution and improve the accuracy of classification.
[0049] In the embodiment, the focal adjustment factor makes the model pay more attention to the difficult-to-classify samples by reducing the loss weight of the easy-to-classify samples. The factor dynamically adjusts the loss contribution according to the sample classification difficulty, effectively solves the class imbalance problem, and improves the learning ability of the model to difficult example samples.
[0050] In the embodiment, the bounding box quality evaluation function evaluates the positioning accuracy by calculating the intersection over union of the predicted box and the real box, and weights the classification loss accordingly. This mechanism establishes the correlation between the classification and positioning tasks, so that the classification confidence can accurately reflect the positioning quality, and the reliability of the detection result is improved.
[0051] In the embodiment, the classification loss and the positioning quality loss are jointly optimized by weighted summation. This multi-task learning strategy promotes the model to improve the classification accuracy while ensuring the consistency of positioning accuracy and classification confidence, and finally outputs more reliable defect detection results.
[0052] The embodiment builds a more effective classification prediction optimization mechanism through the improved distributed focal loss function. The soft label and temperature parameter enhance the modeling ability of the class relationship, the focal adjustment factor improves the sample imbalance problem, the positioning quality weighting establishes the correlation between classification and positioning, and finally realizes the synchronous improvement of classification accuracy and detection reliability.
[0053] In some embodiments, the training sample set is input into the PINet detection network for end-to-end training to obtain a trained bamboo strip defect detection model, including: A knowledge distillation training framework is constructed, taking the PINet detection network as the teacher model and a lightweight network with half the number of channels as the student model; The same training samples are input into the teacher model and the student model, and the network parameters of the teacher model remain frozen during the training process; The feature distillation loss of the teacher model and the student model on the corresponding intermediate feature layer is calculated through the channel distillation mechanism, and the feature distribution difference between the teacher model and the student model in the channel dimension is minimized; The logical distillation loss of the teacher model and the student model on the output layer is calculated through the balanced collaborative knowledge distillation mechanism, and the logical distillation loss includes the classification distribution difference loss based on Kullback-Leibler divergence and the bounding box prediction difference loss based on binary cross entropy; The feature distillation loss and the logical distillation loss are weighted and fused according to the preset weight coefficient to obtain the total distillation loss; The total distillation loss and the basic loss of the detection task are jointly constructed, and the basic loss of the detection task includes the bounding box regression loss, the classification loss and the distributed focal loss; Cosine decay algorithm is used to dynamically adjust the weight coefficient of the total distillation loss in the joint loss, and the weight is set to be low in the early stage of training to focus on basic feature learning, and the weight is gradually increased in the later stage of training to strengthen distillation supervision. The network parameters of the student model are updated by the gradient back propagation algorithm, and iterative optimization is performed until the model converges, to obtain the bamboo strip defect detection model.
[0054] In this embodiment, the knowledge distillation training framework realizes model compression by constructing a teacher-student model architecture. The teacher model uses a complete PINet detection network, and the student model is designed to be lightweight by reducing the number of channels by half, which can significantly reduce the model complexity while maintaining the detection performance, meeting the deployment requirements of edge devices. The channel distillation mechanism realizes knowledge transfer by minimizing the channel distribution difference between the teacher model and the student model at the corresponding intermediate feature layer. The channel normalization method is used to process the feature map, and the distribution difference loss in the channel dimension is calculated to enable the student model to learn the feature expression ability of the teacher model.
[0055] In this embodiment, the balanced collaborative knowledge distillation mechanism simultaneously constrains the consistency of classification distribution and bounding box prediction. The classification distribution difference loss based on Kullback-Leibler divergence ensures that the student model learns the class discrimination knowledge of the teacher model, and the bounding box prediction difference loss based on binary cross entropy ensures the transfer of positioning accuracy knowledge. The detection task refers to the identification and positioning task of bamboo strip surface defects, which specifically includes the classification and location detection of five types of defects: yellow-black knot, green-black knot, flat yellow, concave yellow, and damage. The basic loss is composed of bounding box regression loss, classification loss, and distribution focal loss, which jointly supervise the completion quality of the detection task. The cosine decay algorithm dynamically adjusts the weight coefficient of the distillation loss through the cosine function. In the early stage of training, the weight is set to be low to enable the student model to learn basic features first, and the weight is gradually increased to strengthen distillation supervision as the training progresses, realizing a smooth transition from basic learning to knowledge transfer.
[0056] This embodiment constructs an effective model compression training scheme through a multi-level distillation mechanism and dynamic weight adjustment. Feature distillation ensures the transfer of intermediate layer knowledge, logical distillation ensures the consistency of the output layer, and dynamic weight balances the learning focus in different training stages, ultimately realizing model lightweight while maintaining detection accuracy.
[0057] In some embodiments, sample bamboo strip surface image data is collected, and a training sample set containing multiple defect types is constructed, including: The original sample bamboo strip surface image data is collected under standard industrial lighting conditions, and the original sample bamboo strip surface image data contains five types of defects: yellow-black knot, green-black knot, flat yellow, concave yellow, and damage. The original sample bamboo strip surface image data is preprocessed, and the preprocessing operation includes image size normalization, light equalization and noise filtering processing; The training sample size is expanded through data enhancement, and the data enhancement includes random rotation, scale transformation, color jittering and mirror flipping; The enhanced image data is labeled by a bounding box labeling tool, and a labeled file containing defect category labels and position coordinates is generated; The image data after labeling is divided into a training set, a validation set and a test set according to a preset ratio; The divided data set is converted into a standardized training sample set that meets the input requirements of the PINet detection network.
[0058] In this embodiment, the standard industrial lighting environment ensures the consistency of image acquisition by controlling the intensity and angle of the light source. The original sample bamboo strip surface image data contains five typical defect types: yellow-black knot, green-black knot, flat yellow, concave yellow and damage. The standardized acquisition conditions ensure the reliability of the data quality and provide accurate supervision information for model training. The preprocessing operation unifies the input resolution through image size normalization, eliminates lighting differences through light equalization, and reduces image noise through noise filtering processing. This improves the image quality and reduces the interference of environmental factors on the detection performance, creating good conditions for subsequent feature extraction. Data augmentation expands sample diversity through methods such as random rotation, scale transformation, color jittering and mirror flipping. These transformations simulate the possible changes in viewing angle, size difference and lighting conditions in actual detection scenarios, significantly improving the generalization ability and robustness of the model.
[0059] In this embodiment, the bounding box labeling tool marks the defect area through manual labeling or semi-automatic labeling, generating a labeled file containing defect category labels and position coordinates. The labeling process ensures that each defect area has accurate category information and bounding box coordinates, providing complete training labels for supervised learning. The data set is divided into a training set, a validation set and a test set according to a preset ratio, and standardized data that meets the input requirements of the PINet detection network is generated through format conversion. The standardized division method ensures the objectivity of model evaluation, and the format conversion ensures the compatibility of data and network structure.
[0060] This embodiment constructs a high-quality bamboo defect detection data set through standardized data acquisition, preprocessing, enhancement and labeling processes. The standardized data processing process ensures the representativeness and accuracy of the training samples, laying a solid foundation for the effective training of the PINet detection network, and ultimately ensuring the reliable performance of the model in practical applications.
[0061] In some embodiments, the image of the bamboo strip to be detected is input into the trained bamboo strip defect detection model, and the output is defect category information and position coordinate information, including: The image of the bamboo strip to be detected is preprocessed, and the preprocessing operation includes image size standardization, illumination consistency correction, and noise elimination processing; The preprocessed image of the bamboo strip to be detected is input into the feature extraction module of the bamboo strip defect detection model, and multi-scale defect features are extracted through the EfficientViT structure fused with the Triplet Attention mechanism; The extracted multi-scale defect features are input into the feature fusion module, and feature enhancement and spatial weight strengthening are performed through the adaptive channel allocation convolution unit and the positioning perception attention unit to obtain an optimized defect feature map; The optimized defect feature map is input into the detection head module, and an initial detection result is generated through a multi-scale detection branch, the initial detection result containing defect category probability distribution and bounding box coordinate information; The initial detection result is filtered by a confidence threshold, and the detection result with a confidence higher than a preset threshold is retained; The filtered detection result is subjected to non-maximum suppression processing to eliminate overlapping redundant detection boxes; The final defect category information and position coordinate information are output, the defect category information including defect type identification, and the position coordinate information including center point coordinates and size parameters of the bounding box.
[0062] In this embodiment, the preprocessing operation unifies the input specification through image size standardization, eliminates environmental light differences through illumination consistency correction, and filters noise interference introduced in the image acquisition process through noise elimination processing. The quality consistency of the input image is ensured, providing standardized data input for subsequent feature extraction.
[0063] In this embodiment, the feature extraction module uses the EfficientViT structure fused with the Triplet Attention mechanism to perform feature interaction in three orthogonal dimensions of width-height plane, high-channel plane, and wide-channel plane, effectively extracting multi-scale defect features on the surface of the bamboo strip. It combines the global modeling capability of Transformer and the local enhancement characteristics of attention. The feature fusion module dynamically adjusts the feature channel weight through the adaptive channel allocation convolution unit, and combines the spatial weight strengthening of the positioning perception attention unit to realize feature enhancement of key defect areas. The dual enhancement mechanism significantly improves the discriminability and positioning accuracy of the feature map. The multi-scale detection branch of the detection head module processes in parallel on different resolution feature maps to generate an initial detection result containing defect category probability distribution and bounding box coordinates. The multi-scale design ensures effective detection of defects of different sizes, balancing the recall rate and accuracy of detection.
[0064] In this embodiment, the confidence threshold filter retains detection results above a preset threshold, and the non-maximum suppression process eliminates overlapping detection boxes by calculating the intersection over union. These two post-processing operations effectively remove low-quality detection results, ensuring the accuracy and reliability of the final output information.
[0065] This embodiment realizes accurate conversion from raw images to defect information through complete detection process design. Preprocessing ensures input quality, feature extraction and fusion enhances defect representation ability, multi-scale detection ensures comprehensive coverage, and post-processing optimizes output results, ultimately providing reliable technical support for bamboo strip quality evaluation.
[0066] In some embodiments, a bamboo strip surface defect detection report is generated based on defect category information and position coordinate information, including: Statistical analysis of defect category information to calculate the occurrence frequency and distribution density of each type of defect; Generating a defect spatial distribution map based on position coordinate information to mark the specific location of each type of defect on the bamboo strip surface; Based on the defect size parameter, the detected defects are classified into grades to generate a quality evaluation result; Integrate defect category information, position coordinate information, defect size parameter and quality evaluation result to generate structured detection data; According to the preset report template, the structured detection data is converted into a visual detection report, which includes defect statistical charts, spatial distribution diagrams and quality grade evaluation; Output the final draft of the bamboo strip surface defect detection report containing detection time, detection result summary and quality suggestion.
[0067] In this embodiment, the statistical analysis of defect category information quantifies the defect distribution characteristics of the bamboo strip surface by calculating the occurrence frequency and distribution density of each type of defect. It can identify the main defect types and their distribution patterns, providing data support for quality control and process improvement. The defect spatial distribution map is generated based on position coordinate information, which visually marks the specific location of each type of defect on the bamboo strip surface. It intuitively shows the spatial aggregation of defects, which helps to analyze the location correlation of defects.
[0068] In this embodiment, the quality evaluation result is classified based on the defect size parameter, and the defect is divided into different severity levels by setting reasonable size thresholds. The grading evaluation method can accurately reflect the overall quality of the bamboo strip, providing a basis for graded utilization. The structured detection data is formed by integrating defect category, position coordinate, size parameter and quality evaluation result, forming a complete detection record.
[0069] In the embodiment, the visual detection report is automatically generated according to a preset template, and contains defect statistical charts, spatial distribution diagrams and quality grade assessment. The report adopts a combination of text and graphics, making the detection results more intuitive and easy to understand, and facilitating users of different levels to understand. The final detection report contains detection time, result summary and quality suggestion, forming a complete quality evaluation document. Not only the detection results are recorded, but also targeted improvement suggestions are provided, providing decision support for production quality control.
[0070] The embodiment realizes effective conversion of detection results into practical information through the system report generation process. Statistical analysis reveals defect rules, visual display enhances the intuitiveness of the results, quality assessment provides grading standards, and the final complete report provides comprehensive technical support for bamboo strip production and quality management.
[0071] Unlike the prior art, the above technical solution constructs a PINet detection network containing a feature extraction module, a feature fusion module and a detection head module, and uses an EfficientViT structure with a fusion Triplet Attention mechanism to extract multi-scale defect features, combines a self-adaptive channel allocation convolution unit and a positioning perception attention unit to realize feature enhancement and spatial weight reinforcement, and finally outputs defect category information and position coordinate information. The technical solution significantly enhances the feature representation ability of the fine-grained defects on the surface of the bamboo strip through the cross-dimension interaction and dynamic channel weighting mechanism, effectively improves the discriminability of multi-scale feature fusion and the positioning accuracy of small defects in complex backgrounds, thereby ensuring high detection accuracy while meeting the efficiency requirements of industrial real-time detection.
[0072] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0073] If the integrated unit is implemented in the form of a software function unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application or the entire or part of the technical solutions that essentially contribute to the prior art can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0074] The above only describes some embodiments of the present application, and does not limit the protection scope of the present application. Any equivalent device or equivalent process transformation, or direct or indirect application in other related technical fields based on the content of the present application specification and drawings are also included in the patent protection scope of the present application.
Claims
1. A method for detecting defects in bamboo strips based on PINet networks, characterized in that, include: Collect surface image data of sample bamboo strips and construct a training sample set containing multiple defect types; A PINet detection network is constructed, comprising a feature extraction module, a feature fusion module, and a detection head module connected in sequence. The feature extraction module adopts the EfficientViT structure that integrates the Triplet Attention mechanism, and extracts multi-scale defect features on the surface of bamboo strips through cross-dimensional interaction, and outputs a primary feature map. The feature fusion module receives the primary feature map, dynamically weights the feature channels through an adaptive channel allocation convolutional unit to generate an enhanced feature representation, and simultaneously strengthens the spatial weights of the defect region through a localization-aware attention unit to output an optimized feature map that integrates multi-scale contextual information. The detection head module receives the optimized feature map, processes it through convolutional layers and classification and regression layers, and outputs a detection result containing the defect category probability and bounding box coordinates. The training sample set is input into the PINet detection network for end-to-end training to obtain a fully trained bamboo strip defect detection model. The bamboo strip image to be detected is input into the well-trained bamboo strip defect detection model, which outputs defect category information and location coordinate information. A bamboo strip surface defect detection report is generated based on the defect category information and location coordinate information.
2. The bamboo strip defect detection method based on PINet network according to claim 1, characterized in that, The feature extraction module employs an EfficientViT structure that integrates a Triplet Attention mechanism. It extracts multi-scale defect features from the bamboo strip surface through cross-dimensional interaction, outputting a primary feature map, including: The input sample bamboo strip surface image is compressed in spatial dimension and expanded in channel dimension through a downsampling module to obtain the initial feature representation; The initial feature representation is input into a sandwich-structured cascaded attention module, and computational efficiency is optimized by reducing the proportion of memory-intensive attention layers and increasing the proportion of feedforward network layers. In the cascaded attention module, the feature channel is divided into multiple attention calculation groups, and each group generates a query matrix, a key matrix, and a value matrix respectively. Attention calculation groups are adaptively selected based on the feature map size of the initial feature representation, including: When the feature map size of the initial feature representation is smaller than the preset window size, global attention is used to calculate grouping and model the dependency relationship across the entire image. When the feature map size of the initial feature representation is larger than the preset window size, local attention calculation groups are used to perform feature interaction in local regions by dividing the window; The enhanced features, after attention calculation and grouping, are input into the Triplet Attention module, and attention weights are calculated in three orthogonal dimensions: the width-height plane, the high-channel plane, and the wide-channel plane. Simultaneously perform max pooling and average pooling on each dimension using ZPool operations, and then concatenate the outputs of each dimension. The concatenated features are processed through a convolutional layer to extract local contextual relationships, and then the Sigmoid activation function is used to generate attention outputs for each dimension. By fusing the attention outputs from the three dimensions, enhanced cross-dimensional interaction features are obtained. The cross-dimensional interactive features are nonlinearly transformed and reshaped using a feedforward network to output a primary feature map containing multi-scale semantic information.
3. The bamboo strip defect detection method based on PINet network according to claim 1, characterized in that, The feature fusion module receives the primary feature map and dynamically weights the feature channels using adaptive channel allocation convolutional units to generate enhanced feature representations, including: The primary feature map is input into an adaptive channel allocation convolutional unit, and the channel weights of each convolutional branch are generated through a learnable parameter matrix. The channel weights are normalized using the Softmax function to obtain the channel attention weights for each branch. The primary feature map is multiplied channel by channel by channel attention weights of each branch to achieve adaptive allocation of feature channels and obtain weighted features. The weighted features are then input into two parallel convolutional branches, including: The first branch uses standard convolution operations to extract local texture features, which are used to capture subtle defects on the surface of the bamboo strips, and obtain the first output feature; The second branch uses receptive field attention convolution operation to extract global context features, which is used to enhance the defect recognition capability in complex backgrounds and obtain the second output feature; The first and second output features are concatenated along the channel dimension to obtain an enhanced feature representation that integrates local details and global semantics.
4. The bamboo strip defect detection method based on PINet network according to claim 1, characterized in that, Spatial weight enhancement of defect regions is achieved by using a localization-aware attention unit, resulting in an optimized feature map that integrates multi-scale contextual information, including: The enhanced feature representation is input into the localization and perception attention unit, and the feature map is pooled along the horizontal direction to generate horizontal perception features; Additionally, pooling is performed on the feature map along the vertical direction to generate vertically perceptual features; The horizontal perceptual features are processed by one-dimensional convolution and grouped and normalized, and then the horizontal spatial attention weights are generated by the Sigmoid function. The vertical direction perception features are processed by one-dimensional convolution and grouped and normalized, and then the vertical direction spatial attention weights are generated by the Sigmoid function. The horizontal spatial attention weights and the vertical spatial attention weights are fused to obtain a comprehensive spatial attention weight. The integrated spatial attention weights are multiplied element-wise with the enhanced feature representation to strengthen the spatial weights of the defective region, and an optimized feature map containing multi-scale contextual information and having localization capabilities is output.
5. The bamboo strip defect detection method based on PINet network according to claim 1, characterized in that, The detection head module receives the optimized feature map, processes it through convolutional layers and classification / regression layers, and outputs detection results containing defect category probabilities and bounding box coordinates, including: The optimized feature map is input into a multi-scale feature pyramid structure, and the fusion of feature maps at different scales is achieved through upsampling and downsampling operations; Detection branches are set up at each scale level of the feature pyramid, and each detection branch contains parallel classification convolutional layers and regression convolutional layers; The classification convolutional layer generates a probability distribution of defect categories for each preset anchor point. The defect categories include yellow-black knots, green-black knots, flat yellow, concave yellow, and damage. The regression convolutional layer generates bounding box coordinate offsets and size adjustment parameters for each preset anchor point; The distribution focus loss function is used to optimize classification prediction, and the bounding box regression loss function is used to optimize location prediction. Non-maximum suppression is applied to the detection results at each scale level to eliminate overlapping detection boxes; The final defect detection results are output, including defect category confidence, bounding box coordinates, and defect size information.
6. The bamboo strip defect detection method based on PINet network according to claim 5, characterized in that, The classification prediction is optimized using the distributed focus loss function, including: Soft label representations of category probability distributions are constructed, and the smoothness of the probability distribution is adjusted by a temperature parameter; The Kullback-Leibler divergence between the predicted probability distribution and the true label distribution is calculated as the classification loss. A focus adjustment factor is introduced to assign higher loss weights to samples that are difficult to classify; The localization accuracy of each predicted box is weighted using a bounding box quality evaluation function; The classification loss and localization quality loss are jointly optimized to obtain and output the optimized classification prediction results.
7. The bamboo strip defect detection method based on PINet network according to claim 1, characterized in that, The training sample set is input into the PINet detection network for end-to-end training to obtain a fully trained bamboo strip defect detection model, including: A knowledge distillation training framework is constructed, using the PINet detection network as the teacher model and a lightweight network with half the number of channels as the student model. The same training samples are input into the teacher model and the student model respectively, and the network parameters of the teacher model are kept frozen during the training process; The feature distillation loss of the teacher model and the student model at the corresponding intermediate feature layers is calculated by channel distillation mechanism, minimizing the feature distribution difference between the teacher model and the student model in the channel dimension; The logistic distillation loss of the teacher model and the student model at the output layer is calculated through a balanced collaborative knowledge distillation mechanism. The logistic distillation loss includes classification distribution difference loss based on Kullback-Leibler divergence and bounding box prediction difference loss based on binary cross-entropy. The characteristic distillation loss and the logical distillation loss are weighted and fused according to a preset weighting coefficient to obtain the total distillation loss; The total distillation loss is jointly constructed with the basic loss of the detection task, which includes bounding box regression loss, classification loss, and distribution focus loss. The cosine decay algorithm is used to dynamically adjust the weight coefficient of the total distillation loss in the joint loss. In the early stage of training, a lower weight is set to focus on basic feature learning, and the weight is gradually increased in the later stage of training to strengthen distillation supervision. The network parameters of the student model are updated using the gradient backpropagation algorithm, and the optimization is iteratively performed until the model converges, thus obtaining the bamboo strip defect detection model.
8. The bamboo strip defect detection method based on PINet network according to claim 1, characterized in that, Collect surface image data of sample bamboo strips to construct a training sample set containing various defect types, including: Raw sample bamboo strip surface image data were collected under standard industrial lighting conditions. The raw sample bamboo strip surface image data included five defect types: yellow-black knots, green-black knots, flat yellow, concave yellow, and broken. The original sample bamboo strip surface image data is preprocessed, including image size normalization, illumination equalization, and noise filtering. The training sample size is expanded through data augmentation, which includes random rotation, scaling, color jitter, and mirror flipping. The enhanced image data is annotated with a bounding box annotation tool to generate an annotation file containing defect category labels and location coordinates; The labeled image data is divided into training set, validation set and test set according to a preset ratio; The format of the partitioned dataset is converted to generate a standardized training sample set that meets the input requirements of the PINet detection network.
9. The bamboo strip defect detection method based on PINet network according to claim 1, characterized in that, The image of the bamboo strip to be detected is input into the fully trained bamboo strip defect detection model, which outputs defect category information and location coordinate information, including: The image of the bamboo strip to be detected is subjected to preprocessing operations, including image size standardization, illumination consistency correction, and noise reduction. The preprocessed bamboo strip image to be detected is input into the feature extraction module of the bamboo strip defect detection model, and multi-scale defect features are extracted by the EfficientViT structure that integrates the Triplet Attention mechanism. The extracted multi-scale defect features are input into the feature fusion module, and feature enhancement and spatial weight enhancement are performed through adaptive channel allocation convolutional units and localization-aware attention units to obtain the optimized defect feature map. The optimized defect feature map is input into the detection head module, and an initial detection result is generated through a multi-scale detection branch. The initial detection result includes the defect category probability distribution and bounding box coordinate information. The initial detection results are filtered by a confidence threshold, and the detection results with a confidence level higher than a preset threshold are retained. Non-maximum suppression is applied to the filtered detection results to eliminate overlapping redundant detection frames; The final defect category information and location coordinate information are output. The defect category information includes a defect type identifier, and the location coordinate information includes the center point coordinates and size parameters of the bounding box.
10. The bamboo strip defect detection method based on PINet network according to claim 1, characterized in that, A bamboo strip surface defect detection report is generated based on the defect category information and location coordinate information, including: Statistical analysis is performed on the defect category information to calculate the occurrence frequency and distribution density of each type of defect; A spatial distribution map of defects is generated based on the location coordinate information, and the specific locations of various defects on the surface of the bamboo strip are marked. Based on the defect size parameters, the detected defects are classified into different levels to generate quality assessment results; The defect category information, location coordinate information, defect size parameters, and quality assessment results are integrated to generate structured inspection data; According to the preset report template, the structured inspection data is converted into a visual inspection report, which includes defect statistical charts, spatial distribution diagrams and quality level assessments. Output a complete final bamboo strip surface defect inspection report, including inspection time, summary of inspection results, and quality recommendations.
Citation Information
Cited By
Explosive cladding plate blank performance detection system
CN121878034A