Intelligent detection methods, devices, equipment, and media for defects in ancient architectural wooden components

By constructing a heterogeneous defect detection network and introducing multi-dimensional feature adaptive alignment and normalized Wasserstein distance metric, the problems of poor model generalization ability and inaccurate localization in the detection of wooden components of ancient buildings are solved, and efficient and accurate defect detection is achieved.

CN121639683BActive Publication Date: 2026-04-21XIAMEN UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XIAMEN UNIV OF TECH
Filing Date
2026-02-04
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing technologies for detecting defects in wooden components of ancient buildings suffer from problems such as low efficiency of manual inspection, poor generalization ability of traditional deep learning models, feature mismatch of knowledge distillation technology, and sensitivity of traditional loss functions to positional deviations, which limit the accuracy of detection.

Method used

A heterogeneous defect detection network is constructed, employing a teacher model based on the Vision Transformer architecture and a student model based on the convolutional neural network architecture. Through multi-dimensional feature adaptive alignment and distillation, combined with the normalized Wasserstein distance metric, end-to-end joint training is performed to optimize the student model parameters.

Benefits of technology

It significantly improves the model's detection accuracy and robustness for defects in ancient building wooden components, achieving efficient, accurate, and automated monitoring under conditions of few samples, especially for the accurate location of minute defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121639683B_ABST
    Figure CN121639683B_ABST
Patent Text Reader

Abstract

This invention relates to a method, apparatus, equipment, and medium for intelligent detection of defects in wooden components of ancient buildings, encompassing the field of image processing technology. The method includes: constructing a heterogeneous defect detection network comprising a teacher model and a student model; inputting images into the heterogeneous defect detection network and extracting multi-level feature maps through the teacher and student models; performing multi-dimensional adaptive feature alignment and distillation between the feature maps output by the student model and those output by the teacher model; extracting feature maps from adjacent levels of the teacher model and introducing learnable weight parameters to adaptively weight and fuse the feature maps from adjacent levels; calculating the feature distillation loss between the fused teacher target feature map and the aligned student feature map; introducing the Wasserstein distance metric into the localization branch of the student model, modeling the predicted bounding box and the ground truth bounding box as a two-dimensional Gaussian distribution to calculate the localization loss, and combining this with the feature distillation loss to perform end-to-end joint training of the student model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and more specifically, to an intelligent detection method, device, equipment, and medium for defects in ancient architectural wooden components. Background Technology

[0002] Health monitoring of wooden components in ancient buildings is a crucial aspect of cultural relic preservation. Its core task lies in the precise identification and continuous monitoring of minute defects such as cracks, decay, and insect infestation on the surfaces of key wooden components like brackets, beams, and columns. Developing efficient, accurate, and scalable automated inspection technologies to overcome the high costs, low efficiency, and safety hazards of manual inspections is a long-standing and urgent need in this field.

[0003] Currently, the solutions adopted in the industry mainly include manual inspection, object detection methods based on traditional deep learning, and knowledge distillation techniques. Manual inspection relies on expert experience, while deep learning methods such as YOLO series or Faster R-CNN attempt to achieve automated detection through large amounts of labeled data. Knowledge distillation methods further utilize the strong representational capabilities of pre-trained large models to guide the training of small models, aiming to improve model performance in data-scarce scenarios.

[0004] However, existing methods have several significant drawbacks. Manual inspection is inefficient and struggles to cover high-altitude components. Traditional deep learning models are prone to overfitting and exhibit poor generalization ability when sample defects in ancient buildings are scarce. Existing knowledge distillation techniques face the challenge of feature mismatch between heterogeneous models; for example, the feature maps output by large models with visual Transformer architectures differ in spatial scale and channel dimension from those output by convolutional neural network detectors, leading to poor knowledge transfer. Furthermore, existing methods often fail to fully integrate feature information from different levels of the teacher model, and for detecting minute defects on the surface of wooden components, traditional intersection-union-ratio (IUU) loss functions are overly sensitive to positional deviations, resulting in unstable training and limited detection accuracy. Summary of the Invention

[0005] This invention provides an intelligent detection method, device, equipment, and medium for defects in ancient building wooden components, in order to improve at least one of the aforementioned technical problems.

[0006] Firstly, the present invention provides an intelligent detection method for defects in wooden components of ancient buildings, comprising S1 to S5.

[0007] S1. Construct a heterogeneous defect detection network, which includes a teacher model based on the Vision Transformer architecture and a student model based on the convolutional neural network architecture. The teacher model loads pre-trained parameters and freezes the parameters during training, while the student model is the network to be trained.

[0008] S2. Obtain images of ancient building wooden components and input them into the heterogeneous defect detection network. Extract multi-level feature maps through the teacher model and student model respectively.

[0009] S3. Perform multi-dimensional feature adaptive alignment and distillation on the feature maps output by the student model and the feature maps output by the teacher model. Multi-dimensional feature adaptive alignment includes feature map spatial scale alignment using bilinear interpolation algorithm and feature map channel dimension mapping alignment using convolutional layers.

[0010] S4. Extract the feature maps of adjacent layers of the teacher model, introduce learnable weight parameters to adaptively weight and fuse the feature maps of adjacent layers, and calculate the feature distillation loss between the fused teacher target feature map and the aligned student feature map.

[0011] S5. A normalized Wasserstein distance metric is introduced into the localization branch of the student model. The predicted bounding boxes and ground truth bounding boxes are modeled as two-dimensional Gaussian distributions. The similarity between these distributions is measured by calculating the Wasserstein distance to calculate the localization loss. This is combined with feature distillation loss for end-to-end joint training of the student model. The trained student model is used to perform defect detection inference on images of ancient architectural wooden components and output the defect detection results.

[0012] As a further aspect of the present invention, constructing a heterogeneous defect detection network specifically includes:

[0013] The DINOv3 model based on the ViT-B architecture was used as the teacher model. The teacher model contains a Transformer encoder consisting of 12 encoder blocks connected in sequence.

[0014] The YOLOv11-m model is used as the student model. The student model includes a backbone network and a neck network, and outputs feature maps of three layers, P3, P4 and P5, with spatial resolution decreasing sequentially.

[0015] Specifically, the outputs of the 3rd and 4th encoder blocks closest to the input in the teacher model are defined as shallow encoder features, matching the P3 level feature map of the student model. The outputs of the 7th and 8th encoder blocks in the middle of the teacher model are defined as mid-level encoder features, matching the P4 level feature map of the student model. The outputs of the 11th and 12th encoder blocks closest to the output in the teacher model are defined as deep encoder features, matching the P5 level feature map of the student model.

[0016] As a further aspect of the present invention, feature map spatial scale alignment specifically includes:

[0017] Obtain the spatial resolution of the feature maps output by the teacher model, as well as the spatial resolutions of feature maps P3, P4, and P5 output by the student model.

[0018] For the feature map P3 of the student model, the feature map output by the shallow encoder block of the teacher model is upsampled to the same spatial size as P3 using a bilinear interpolation algorithm.

[0019] For the feature map P4 of the student model, the feature map output by the encoder block in the middle layer of the teacher model is downsampled to the same spatial size as P4 using a bilinear interpolation algorithm.

[0020] For the feature map P5 of the student model, the feature map output by the deep encoder block of the teacher model is downsampled to the same spatial size as P5 using a bilinear interpolation algorithm.

[0021] The pixel mapping rule based on bilinear interpolation is as follows: for any pixel in the target feature map... The floating-point coordinates are obtained by mapping them to the coordinate system of the source feature map according to the scaling ratio. Four integer coordinate pixels adjacent to the floating-point coordinates in the source feature map are selected. The weights are calculated based on the distance between the floating-point coordinates and the four integer coordinate pixels. The pixel values ​​of the four integer coordinate pixels are then weighted and summed to obtain the value of the target pixel.

[0022] As a further aspect of the present invention, the feature map channel dimension mapping alignment specifically includes:

[0023] Determine the number of channels in the feature maps of each level of the student model. The number of channels in the feature map of the teacher model .

[0024] After each layer's feature output in the student model, a convolutional kernel with a size of [size missing] is connected. The convolutional layer.

[0025] The convolutional layer is used to increase the number of channels in the student model feature map from... Linear projection mapping to This ensures that the mapped student feature map and the teacher model feature map are consistent in the channel dimension.

[0026] As a further aspect of the present invention, adaptive weighted fusion specifically includes:

[0027] Extracting feature maps from two adjacent layers in the teacher model and The spliced ​​features are obtained by splicing them together along the channel dimension.

[0028] The concatenated features are input into a convolutional layer with two output channels to generate a weight mapping map for the two channels. .

[0029] Perform a Softmax operation on the weight map in spatial location to obtain a normalized weight matrix. and And calculate the fused teacher target feature map. :

[0030] .

[0031] .

[0032] .

[0033] .

[0034] In the formula, These are the indices of the three dimensions in the feature map. for The weight. for The weight. It is a natural exponential function. This is the weight mapping diagram for the first channel. This is the weight mapping diagram for the second channel.

[0035] As a further aspect of the present invention, joint training minimizes the total loss function. To optimize student model parameters.

[0036] .

[0037] In the formula, For classification loss. To pinpoint the loss. Characteristic distillation loss. This represents the distribution focus loss. , , and They are respectively , , and The weight parameters.

[0038] As a further aspect of the present invention, calculating the characteristic distillation loss specifically includes:

[0039] Aligned student feature maps are calculated using a smoothed L1 loss function. With the integrated teacher target feature map The differences between them are calculated, and the losses at different levels are weighted and summed.

[0040] .

[0041] .

[0042] In the formula, Total characteristic distillation loss This is an index of the feature maps for the three levels of the student model. for Weights of feature maps at each level. for Loss at different levels. This is the smoothed L1 loss function.

[0043] As a further aspect of the present invention, calculating the positioning loss specifically includes:

[0044] Predict bounding box and true bounding box They are modeled as two-dimensional Gaussian distributions. and .

[0045] Calculate the square of the Wasserstein distance between two Gaussian distributions. The bounding box contains only the coordinates of the center point. and width and height In this case, the simplified formula is as follows.

[0046] .

[0047] Calculate the normalized Wasserstein distance based on the Wasserstein distance. and its positioning loss :

[0048] .

[0049] .

[0050] In the formula, This represents the coordinates of the center point. for The coordinates. for The coordinates. Let represent the covariance matrix. for The covariance matrix. for The covariance matrix. It is an L2 norm. It is the F-norm. and for Width and height parameters related to diagonal elements. and for Width and height parameters related to diagonal elements. These are constants related to the dataset. It is a natural exponential function.

[0051] Secondly, the present invention provides an intelligent detection device for defects in ancient building wooden components, which includes a network construction module, a feature extraction module, a feature alignment module, a feature fusion module, and a training module.

[0052] The network building module is used to construct a heterogeneous defect detection network, which includes a teacher model based on the Vision Transformer architecture and a student model based on the convolutional neural network architecture. The teacher model loads pre-trained parameters and freezes them during training, while the student model is the network to be trained.

[0053] The feature extraction module is used to acquire images of wooden components of ancient buildings and input them into the heterogeneous defect detection network, extracting multi-level feature maps through the teacher model and student model respectively.

[0054] The feature alignment module is used to perform multi-dimensional adaptive feature alignment and distillation on the feature maps output by the student model and the feature maps output by the teacher model. The multi-dimensional adaptive feature alignment includes feature map spatial scale alignment using bilinear interpolation algorithm and feature map channel dimension mapping alignment using convolutional layers.

[0055] The feature fusion module is used to extract feature maps of adjacent layers of the teacher model, introduce learnable weight parameters to adaptively weight and fuse the feature maps of adjacent layers, and calculate the feature distillation loss between the fused teacher target feature map and the aligned student feature map.

[0056] The training module introduces a normalized Wasserstein distance metric into the localization branch of the student model. It models the predicted and ground truth bounding boxes as two-dimensional Gaussian distributions, calculates the similarity between these distributions using the Wasserstein distance to calculate the localization loss, and combines this with feature distillation loss for end-to-end joint training of the student model. The trained student model is then used to perform defect detection inference on images of ancient architectural wooden components and output the defect detection results.

[0057] Thirdly, the present invention provides an intelligent detection device for defects in ancient architectural wooden components, comprising a processor, a memory, and a computer program stored in the memory. The computer program can be executed by the processor to implement an intelligent detection method for defects in ancient architectural wooden components as described in any paragraph of the first aspect.

[0058] Fourthly, the present invention provides a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed, it controls the device containing the computer-readable storage medium to perform an intelligent detection method for defects in ancient building wooden components as described in any paragraph of the first aspect.

[0059] By adopting the above technical solution, the present invention can achieve the following technical effects:

[0060] This invention effectively addresses the problem of poor model generalization ability caused by sample scarcity in the detection of defects in wooden components of ancient buildings by constructing a heterogeneous defect detection network comprising a Vision Transformer architecture teacher model and a convolutional neural network architecture student model. Through the design of a multi-dimensional feature adaptive alignment mechanism and an adjacent-level feature fusion strategy incorporating learnable weights, this invention successfully overcomes the structural differences between heterogeneous models in terms of feature map spatial scale and channel dimension. This allows the lightweight student model to fully inherit and fuse deep features containing global semantics and shallow features rich in texture details from the teacher model, thereby significantly improving the model's feature extraction capability and detection accuracy for defects in wooden components under complex backgrounds without increasing computational costs during the inference stage.

[0061] Furthermore, considering that defects such as cracks and insect infestations on the surface of ancient buildings are often small in scale or have extreme aspect ratios, this invention introduces the Normalized Wasserstein Distance (NWD) as a metric in the localization branch. By modeling the predicted bounding box and the ground truth bounding box as a two-dimensional Gaussian distribution to calculate the localization loss, this fundamentally solves the problem of the traditional IoU loss function's lack of sensitivity to positional deviations in the detection of small targets. This improvement not only optimizes gradient backpropagation in non-strict overlap cases but also significantly enhances the model's accuracy and robustness in locating small defects, enabling efficient, accurate, and automated monitoring of the health status of ancient buildings under limited sample conditions. Attached Figure Description

[0062] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the specific embodiments of the present invention will be briefly introduced below. It should be understood that the following drawings only show some specific embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained from these drawings without creative effort.

[0063] Figure 1 This is a flowchart of an intelligent detection method for defects in wooden components of ancient buildings.

[0064] Figure 2 This is the network structure diagram of VIT-B / 14.

[0065] Figure 3 yes Figure 2 Network structure diagram of the encoder block.

[0066] Figure 4 This is a diagram of the YOLOv11 network structure. Detailed Implementation

[0067] The technical solutions of the present invention will now be clearly and completely described with reference to the accompanying drawings in the embodiments of the present invention.

[0068] Example 1, please refer to Figures 1 to 3 The first embodiment of the present invention provides an intelligent detection method for defects in ancient building wooden components, which can be executed by an intelligent detection device for defects in ancient building wooden components (hereinafter referred to as: detection device). In particular, it is executed by one or more processors in the detection device to realize S1 to S5.

[0069] S1. Construct a heterogeneous defect detection network, which includes a teacher model based on the Vision Transformer architecture and a student model based on the convolutional neural network architecture. The teacher model loads pre-trained parameters and freezes the parameters during training, while the student model is the network to be trained.

[0070] S2. Acquire images of ancient architectural wooden components and input them into a heterogeneous defect detection network. Extract multi-level feature maps using both the teacher and student models. Specifically, collect images of ancient architectural wooden components (bracket sets, beams, columns) and label the defect categories (cracks, decay, insect infestation).

[0071] S3. Perform multi-dimensional feature adaptive alignment and distillation on the feature maps output by the student model and the feature maps output by the teacher model. Multi-dimensional feature adaptive alignment includes feature map spatial scale alignment using bilinear interpolation algorithm and feature map channel dimension mapping alignment using convolutional layers.

[0072] S4. Extract the feature maps of adjacent layers of the teacher model, introduce learnable weight parameters to adaptively weight and fuse the feature maps of adjacent layers, and calculate the feature distillation loss between the fused teacher target feature map and the aligned student feature map.

[0073] S5. A normalized Wasserstein distance metric is introduced into the localization branch of the student model. The predicted bounding boxes and ground truth bounding boxes are modeled as two-dimensional Gaussian distributions. The similarity between these distributions is measured by calculating the Wasserstein distance to calculate the localization loss. This is combined with feature distillation loss for end-to-end joint training of the student model. The trained student model is used to perform defect detection inference on images of ancient architectural wooden components and output the defect detection results.

[0074] This invention achieves significant benefits in detecting defects in ancient wooden building components by constructing a heterogeneous knowledge distillation framework and optimizing a small target detection mechanism. First, it effectively overcomes the bottleneck of model training under limited sample conditions. By designing a multi-level feature adaptive alignment and distillation mechanism, it efficiently transfers the powerful visual representation capabilities learned by the large visual model from massive amounts of data to a lightweight student model, thereby significantly reducing the dependence on annotated data for ancient building defects. A high-precision, highly generalized detection model can be trained with only a small number of samples. Second, it ingeniously solves the problem of feature mismatch between heterogeneous models. Spatial scale alignment is achieved through bilinear interpolation, and channel dimension mapping is completed using a 1×1 convolutional layer. This enables effective knowledge transfer between the Transformer-based teacher model and the CNN-based student model, overcoming the feature gap caused by architectural differences.

[0075] Furthermore, this invention addresses the issue of unstable detection of minute defects (such as micro-cracks and wormholes) in ancient wooden building components. It introduces the Normalized Wasserstein distance (NWD) as a localization loss function, models the bounding boxes as Gaussian distributions, and measures similarity by calculating the distance between distributions. This method effectively decouples the influence of object scale on loss calculation, providing stable gradient signals even when the predicted and ground truth boxes only partially overlap or have slight offsets, significantly improving the model's localization accuracy and training stability for minute defects. Ultimately, this invention achieves high-precision, automated detection of various defects on the surface of ancient wooden building components, especially subtle and difficult-to-detect minute defects, under conditions of scarce samples, providing reliable technical support for intelligent monitoring in the field of cultural relic preservation.

[0076] Based on the above embodiments, in an optional embodiment of the present invention, such as Figures 2 to 4 As shown, constructing a heterogeneous defect detection network specifically includes:

[0077] The DINOv3 model based on the ViT-B architecture was used as the teacher model. The teacher model contains a Transformer encoder consisting of 12 encoder blocks connected in sequence.

[0078] The YOLOv11-m model is used as the student model. The student model includes a backbone network and a neck network, and outputs feature maps of three layers, P3, P4 and P5, with spatial resolution decreasing sequentially.

[0079] Specifically, the outputs of the 3rd and 4th encoder blocks closest to the input in the teacher model are defined as shallow encoder features, matching the P3 level feature map of the student model. The outputs of the 7th and 8th encoder blocks in the middle of the teacher model are defined as mid-level encoder features, matching the P4 level feature map of the student model. The outputs of the 11th and 12th encoder blocks closest to the output in the teacher model are defined as deep encoder features, matching the P5 level feature map of the student model.

[0080] Initialize the teacher model: Load the pre-trained DINOv3 model and freeze its parameters throughout the training process. Preferably, the teacher model DINOv3 employs the ViT-B (Vision Transformer-Based) architecture, which is a visual feature extraction network based on the standard Transformer structure. Figure 2 This is a network architecture diagram of ViT-B. Its specific structure consists of the following interconnected components.

[0081] 1. Image Patch Embedding: Used to embed the input... The image is divided into fixed sizes. The non-overlapping patches are generated, and each patch is mapped to a 768-dimensional vector embedding through a convolution operation.

[0082] 2. Class Vector Concatenation: At the beginning of the patch embedding sequence, a pre-defined learnable special vector, called a class token, is concatenated.

[0083] 3. Position Encoding Overlay: To preserve the spatial location information of the image, learnable one-dimensional position embeddings are overlaid into the patch embeddings.

[0084] 4. Transformer Encoder Blocks: Contains 12 repeating encoder blocks, such as... Figure 3 As shown.

[0085] Initialize the student model: Load the YOLOv11-m model as the network to be trained. Preferably, the student model uses a YOLOv11-m architecture that is a single-stage object detection network based on a convolutional neural network (CNN), the specific structure of which is as follows: Figure 4 As shown.

[0086] Based on the above embodiments, in an optional embodiment of the present invention, feature map spatial scale alignment specifically includes the following steps.

[0087] Obtain the spatial resolution of the feature maps output by the teacher model, as well as the spatial resolutions of feature maps P3, P4, and P5 output by the student model.

[0088] For the feature map P3 of the student model, the feature map output by the shallow encoder block of the teacher model is upsampled to the same spatial size as P3 using a bilinear interpolation algorithm.

[0089] For the feature map P4 of the student model, the feature map output by the encoder block in the middle layer of the teacher model is downsampled to the same spatial size as P4 using a bilinear interpolation algorithm.

[0090] For the feature map P5 of the student model, the feature map output by the deep encoder block of the teacher model is downsampled to the same spatial size as P5 using a bilinear interpolation algorithm.

[0091] The pixel mapping rule based on bilinear interpolation is as follows: for any pixel in the target feature map... The floating-point coordinates are obtained by mapping them to the coordinate system of the source feature map according to the scaling ratio. Four integer coordinate pixels adjacent to the floating-point coordinates in the source feature map are selected. The weights are calculated based on the distance between the floating-point coordinates and the four integer coordinate pixels. The pixel values ​​of the four integer coordinate pixels are then weighted and summed to obtain the value of the target pixel.

[0092] Specifically, the image (input image size is 640) 640) After inputting the teacher and student models respectively, in order to achieve point-to-point distillation of feature maps between heterogeneous models, this invention uses the spatial resolution of the student model YOLOv11-m as a benchmark and performs adaptive spatial scale alignment on the feature map output by the teacher model DINOv3.

[0093] In this embodiment, the input image for the student model is a 640-shape image. 640 The three tensors are processed sequentially through the backbone network and the fusion feature network module to obtain feature maps P3, P4, and P5, which have already been processed. Figure 4 The annotations are in the middle. P3, P4, and P5 are equivalent to downsampling from the original image. times, and The shapes of feature maps P3, P4, and P5 are 80 times. 80 192, 40 40 384, 20 20 512. The first two dimensions of P3, P4, and P5 represent the size of the feature maps. The length of the third dimension of P3, P4, and P5 represents the number of channels in each feature map. The size of the P3 layer feature map in YOLOv11-m is defined as follows: .

[0094] S5. A normalized Wasserstein distance metric is introduced into the localization branch of the student model. The predicted bounding boxes and ground truth bounding boxes are modeled as two-dimensional Gaussian distributions. The similarity between these distributions is measured by calculating the Wasserstein distance to calculate the localization loss. This is combined with feature distillation loss for end-to-end joint training of the student model. The trained student model is used to perform defect detection inference on images of ancient architectural wooden components and output the defect detection results. The output feature map of the teacher model refers to the two-dimensional feature space representation generated after the Transformer encoder block output sequence has had its class vectors removed and rearranged. The size of the output feature map is defined as... .

[0095] The input image A of the teacher model has a tensor shape of 640. 640 3. For the image Using bilinear interpolation, The size is 640 640 becomes 644 644, with the number of channels unchanged, yields a tensor. Tensor The input is fed into image block embedding, resulting in 2116. 768 Shape Tensors In tensor Add 1 to the beginning The tensor class token of shape 768 yields 2117. 768 Shape Tensors Tensor Inputting position embedding yields 2117 768 Shape Tensors Tensor The dropout module returned 2117. 768 Shape Tensors Tensor As input to the transformer encoder, the tensor shape output by each encoded block is the same as that of the tensor. The shapes are the same, and the output of the Nth coded block is 2117. 768 Shape Tensors Remove The first line gives 2116 768 Shape Tensors Then... Reshaped into 46 in the first dimension 46 (vectors in the original tensor) The subscript m ranges from 0 to 2115, representing a vector. The shape is 1 768, the vector after reshaping The index of the corresponding target tensor is ( m / 46 ,m%46)), resulting in 46 46 768-shaped tensor This refers to the feature map output from the Nth layer of VIT-B / 14. (Tensor) The first two dimensions correspond to the length and width of the feature map output from the Nth layer of VIT-B / 14, respectively. Tensor The length of the third dimension represents the number of channels in the feature map output of the Nth layer of VIT-B / 14.

[0096] For tensors Each channel in (N=3,4) has the following shape: 1. There are a total of 768 channels of the same shape, each using bilinear interpolation. Upsampling to .

[0097] Similarly, the feature map sizes of layers P4 and P5 in YOLOv11-m are respectively and Because the dimensions of P4 and P5 are smaller than For tensors For each channel of (N=7,8), use bilinear interpolation to... downsampling to For tensors For each channel of (N=11,12), use bilinear interpolation to... downsampling to Finally, all downsampled data... The result is recorded as (N=3,4,7,8,11,12).

[0098] The specific steps for pixel mapping based on bilinear interpolation are as follows.

[0099] First, define the coordinate mapping. Let the original image size be... The target image size is Then the target image points Coordinates corresponding to the coordinate system of the original image The calculation formula is as follows.

[0100] .

[0101] .

[0102] Then, find The coordinates of four adjacent integer pixels:

[0103] . . . .

[0104] in For rounding down, Round up to the nearest whole number.

[0105] Then, horizontal interpolation is performed ( (The pixel value of the corresponding point).

[0106] .

[0107] .

[0108] Finally, vertical interpolation is performed.

[0109] .

[0110] Based on the above embodiments, in an optional embodiment of the present invention, the feature map channel dimension mapping alignment specifically includes the following steps.

[0111] Determine the number of channels in the feature maps of each level of the student model. The number of channels in the feature map of the teacher model .

[0112] After each layer's feature output in the student model, a convolutional kernel with a size of [size missing] is connected. The convolutional layer.

[0113] The convolutional layer is used to increase the number of channels in the student model feature map from... Linear projection mapping to This ensures that the mapped student feature map and the teacher model feature map are consistent in the channel dimension.

[0114] Specifically, let the YOLOv11-m feature channels be... (The lengths of the third dimension, P3, P4, and P5, represent the number of channels in their respective feature maps, which are 192, 384, and 512 respectively). The block embedding dimension of DINOv3 is... ( It is a tensor The length of the third dimension is 768.

[0115] After the feature layer of the student model, add a Convolutional layers reduce the number of channels from Mapped to Specifically, for P3 (shape 80) 80 192), input P3 into a convolutional network configured with 192 input channels, 768 output channels, and a kernel size of [missing value]. The convolutional layer ultimately outputs a shape of... Alignment feature map .

[0116] Similarly, for P4, the number of input channels is 384 and the number of output channels is 768. The convolutional layer performs calculations, and the output result is of shape [missing information]. Feature map For P5, the number of input channels is 512 and the number of output channels is 768. The convolutional layer performs projection calculations to generate a shape of Feature map .

[0117] This series of operations ensures that the channel dimensions of the student model YOLOv11-m are consistent with those of the teacher model DINOv3 at each feature level, thus laying the foundation for further feature distillation.

[0118] To ensure semantic space equivalence during the distillation process, the student model YOLOv11-m... Matching feature maps of the third and fourth layers of the teacher model DINOv3 (ViT-B) (N=3, 4). The feature maps of the seventh and eighth layers of the corresponding teacher model DINOv3 (ViT-B) (N=7, 8). Feature maps corresponding to layers 11 and 12 of the teacher model DINOv3 (ViT-B) (N=11, 12).

[0119] Student model The layer has the highest spatial resolution ( It mainly captures the local geometric details of an image, such as its contours and textures. Shallow layer of teacher model DINOv3 ( Matching (N=3, 4) can effectively transfer the fine visual representations captured by the large model to the student model, which is crucial for feature extraction of minor defects (such as fine cracks and early decay) on the surface of ancient wooden components.

[0120] As network depth increases, the receptive field of the feature maps expands, but the spatial resolution decreases. (Student model) Both the deep layers of the teacher model and the teacher model (layers 11 and 12) carry the most abstract global semantic information. This matching can guide the student model to accurately distinguish between defect targets and natural wood textures in complex ancient building backgrounds by using global contextual information, thereby improving the detection accuracy.

[0121] Based on the above embodiments, in an optional embodiment of the present invention, adaptive weighted fusion specifically includes:

[0122] Extracting feature maps from two adjacent layers in the teacher model and The spliced ​​features are obtained by splicing them together along the channel dimension.

[0123] The concatenated features are input into a convolutional layer with two output channels to generate a weight mapping map for the two channels. .

[0124] Perform a Softmax operation on the weight map in spatial location to obtain a normalized weight matrix. and And calculate the fused teacher target feature map. :

[0125] .

[0126] .

[0127] .

[0128] .

[0129] In the formula, These are the indices of the three dimensions in the feature map. for The weight. for The weight. It is a natural exponential function. This is the weight mapping diagram for the first channel. This is the weight mapping diagram for the second channel.

[0130] Preferably, the calculation of characteristic distillation loss specifically includes:

[0131] Aligned student feature maps are calculated using a smoothed L1 loss function. With the integrated teacher target feature map The differences between them are calculated, and the losses at different levels are weighted and summed.

[0132] .

[0133] .

[0134] In the formula, Total characteristic distillation loss This is an index of the feature maps for the three levels of the student model. for Weights of feature maps at each level. for Loss at different levels. This is the smoothed L1 loss function.

[0135] Specifically, extract the feature map of DINOv3. (like Take the output of the third layer of ViT-B. Equivalent to When N=3, the shape is 80. 80 768) and feature map (like Take the output of the fourth layer of ViT-B. Equivalent to When N=4, the shape is 80. 80 768).

[0136] Will and By piecing them together in the last dimension, we obtain... , The shape is 80 80 1536.

[0137] Then, it passes through a channel with 1536 input channels and 2 output channels. 1 convolution kernel, calculated , Shape 80 80 2.

[0138] A softmax operation is performed at each spatial location to obtain the final weight matrix. and These correspond to the first and second channels, respectively. The specific calculation process is as follows.

[0139] 1. Let In spatial location The two channel components at that point are respectively and ,in , .

[0140] 2. For each spatial location The values ​​of the two channels are normalized using an exponential function, and the calculation formula is as follows.

[0141] .

[0142] .

[0143] 3. For any spatial location on the feature map The corresponding weight values ​​satisfy the normalization constraint:

[0144] .

[0145] To improve the convergence speed of the model in the early stages of training and its numerical stability in the later stages of training, this invention uses the Smooth L1 loss function for calculation.

[0146] This represents the target feature map after weighted fusion. Feature maps representing student models aligned by the channel dimension ( , , ), calculated according to feature matching relationship Then sum them up. .

[0147] .

[0148] .

[0149] .

[0150] .

[0151] In the formula , and They are respectively , and The weight.

[0152] Preferred, =0.5、 =0.3、 =0.2, giving a greater weight to the feature distillation loss of shallow matching is because this embodiment aims to make the student model pay more attention to the local details of the wooden component surface, which is more conducive to detecting minute defects.

[0153] Feature matching relationship: When =1, Depend on , It is derived from weighted fusion, and correspondingly Similarly, when When =2, Depend on , It is derived from weighted fusion, and correspondingly .when When =3, Depend on , It is derived from weighted fusion, and correspondingly .

[0154] Based on the above embodiments, in an optional embodiment of the present invention, calculating the localization loss specifically includes the following steps.

[0155] Predict bounding box and true bounding box They are modeled as two-dimensional Gaussian distributions. and .

[0156] Calculate the square of the Wasserstein distance between two Gaussian distributions. The bounding box contains only the coordinates of the center point. and width and height In this case, the simplified formula is as follows.

[0157] .

[0158] Calculate the normalized Wasserstein distance based on the Wasserstein distance. and its positioning loss :

[0159] .

[0160] .

[0161] In the formula, This represents the coordinates of the center point. for The coordinates. for The coordinates. Let represent the covariance matrix. for The covariance matrix. for The covariance matrix. It is an L2 norm. It is the F-norm. and for Width and height parameters related to diagonal elements. and for Width and height parameters related to diagonal elements. These are constants related to the dataset. It is a natural exponential function.

[0162] Specifically, for small target defects, this embodiment abandons the IoU-based localization loss (YOLOv11-m uses CIOU) and adopts NWD Loss. In this scenario, the traditional IoU-based loss is easily affected by wood grain interference in crack detection. When the prediction box mistakenly predicts wood grain as crack, the IoU drops sharply to 0, so the IoU does not contribute to the gradient. Moreover, for objects with extreme aspect ratios such as cracks, when the prediction box shifts by a few pixels, the IoU-based loss will change drastically, affecting the stability of model training.

[0163] Predicted box and real frame Modeled as a two-dimensional Gaussian distribution and .

[0164] Calculate the Wasserstein distance between two distributions. And normalize to obtain NWD.

[0165]

[0166]

[0167]

[0168]

[0169]

[0170]

[0171] In the formula, and These are the coordinates of the center points of the predicted bounding box and the ground truth bounding box after normalization. and It is the normalized prediction box size, and similarly... and It is the normalized true frame size. These are constants related to the dataset.

[0172] The positioning loss is defined as: .

[0173] Based on the above embodiments, in an optional embodiment of the present invention, joint training minimizes the total loss function. To optimize student model parameters.

[0174] .

[0175] In the formula, For classification loss. To pinpoint the loss. Characteristic distillation loss. This represents the distribution focus loss. , , and They are respectively , , and The weight parameters.

[0176] The standard YOLOv11-m model typically uses a classification loss during the training phase. CIoU-based box regression loss and distribution focus loss The combination that constitutes the composition.

[0177] In comparison, this invention makes the following two core improvements at the loss function level.

[0178] 1. Introduce characteristic distillation losses By leveraging the feature representation capabilities of large models to supervise student models, the overfitting problem caused by the scarcity of defective samples in ancient buildings was solved.

[0179] 2. Loss Term Replacement: The CIoU loss in the standard algorithm is replaced with the normalized Wasserstein distance (NWD) loss. This replacement is designed based on the specific needs of detecting minute defects in ancient wooden building components.

[0180] This invention utilizes a small amount of labeled data for end-to-end fine-tuning training. During inference, distillation-related branches are removed, retaining only the original output structure of YOLOv11-m for rapid detection.

[0181] This invention aims to address the following technical problems: Given the scarcity of defect samples in ancient wooden building components, existing detection models suffer from low accuracy and poor generalization. The significant differences between the YOLOv11 and DINOv3 architectures, and the mismatch between feature map scale and channels, lead to difficulties in knowledge transfer. Defects in wooden components (such as early cracks and wormholes) are typically extremely small in scale, and the traditional IoU loss function results in unstable training and difficulty in convergence.

[0182] To address the aforementioned issues, this invention proposes a few-sample defect detection method for ancient wooden architectural components based on knowledge distillation and NWD loss, comprising: Heterogeneous model construction: constructing a frozen teacher model based on DINOv3 (ViT-B) and a trainable student model based on YOLOv11-m. Multi-scale feature adaptive alignment and distillation: addressing the shape mismatch between YOLOv11-m and DINOv3 (ViT-B) feature maps, bilinear interpolation is used to resolve the spatial mismatch. A 1×1 convolutional layer is used to project the number of channels of the YOLOv11-m feature map to match the number of channels of the DINOv3 (ViT-B) feature map. Simultaneously, feature maps from adjacent layers of DINOv3 are extracted, learnable weight parameters are introduced, and feature knowledge from different layers is adaptively fused to calculate SmoothL1Loss with the student feature map. NWD-based small target localization optimization: Normalized Wasserstein Distance (NWD) Loss is introduced in YOLOv11-m to replace the traditional bounding box loss (CIoULoss). By modeling the bounding box as a two-dimensional Gaussian distribution and measuring similarity by calculating the Wasserstein distance between the distributions, the influence of object scale is decoupled, enabling stable detection of minute defects.

[0183] This embodiment overcomes the limitation of few samples: through multi-level and multi-dimensional deep distillation, the general visual features learned by DINOv3 on massive data are efficiently transferred to YOLOv11-m, which greatly reduces the dependence on ancient building defect annotation data.

[0184] This embodiment addresses the challenge of heterogeneous alignment by designing an alignment module that includes spatial interpolation, channel projection, and adaptive hierarchical weights, effectively resolving the feature incompatibility issue between CNN and ViT architectures.

[0185] This embodiment improves the detection rate of minor defects: by leveraging the scale-insensitive nature of NWD Loss, it significantly improves the detection accuracy for small targets such as minute cracks and wormholes commonly found in ancient wooden structural components. Compared to IoU, NWD can provide gradients even when the predicted bounding box does not overlap with the ground truth bounding box, thus solving the problem of training instability.

[0186] Example 2: The present invention provides an intelligent detection device for defects in ancient building wooden components, which includes a network construction module, a feature extraction module, a feature alignment module, a feature fusion module, and a training module.

[0187] The network building module is used to construct a heterogeneous defect detection network, which includes a teacher model based on the Vision Transformer architecture and a student model based on the convolutional neural network architecture. The teacher model loads pre-trained parameters and freezes them during training, while the student model is the network to be trained.

[0188] The feature extraction module is used to acquire images of wooden components of ancient buildings and input them into the heterogeneous defect detection network, extracting multi-level feature maps through the teacher model and student model respectively.

[0189] The feature alignment module is used to perform multi-dimensional adaptive feature alignment and distillation on the feature maps output by the student model and the feature maps output by the teacher model. Multi-dimensional adaptive feature alignment includes feature map spatial scale alignment using bilinear interpolation algorithm and feature map channel dimension mapping alignment using convolutional layers.

[0190] The feature fusion module is used to extract feature maps of adjacent layers of the teacher model, introduce learnable weight parameters to adaptively weight and fuse the feature maps of adjacent layers, and calculate the feature distillation loss between the fused teacher target feature map and the aligned student feature map.

[0191] The training module introduces a normalized Wasserstein distance metric into the localization branch of the student model. It models the predicted and ground truth bounding boxes as two-dimensional Gaussian distributions, calculates the similarity between these distributions using the Wasserstein distance to calculate the localization loss, and combines this with feature distillation loss for end-to-end joint training of the student model. The trained student model is then used to perform defect detection inference on images of ancient architectural wooden components and output the defect detection results.

[0192] Example 3: This invention provides an intelligent detection device for defects in ancient building wooden components, comprising a processor, a memory, and a computer program stored in the memory. The computer program can be executed by the processor to implement an intelligent detection method for defects in ancient building wooden components as described in any paragraph of Example 1.

[0193] It is understood that the detection device can be an electronic device with computing power, such as a portable laptop computer, desktop computer, server, smartphone, or tablet computer.

[0194] Example 4: The present invention provides a computer-readable storage medium, the computer-readable storage medium including a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to execute a method for intelligent detection of defects in ancient building wooden components as described in any paragraph of Example 1.

[0195] Obviously, the embodiments described above are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0196] In the several embodiments provided in this invention, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus and method embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0197] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0198] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, electronic device, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks. It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0199] The terminology used in the embodiments of this invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The singular forms “a,” “the,” and “the” used in the embodiments of this invention are also intended to include the plural forms unless the context clearly indicates otherwise.

[0200] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0201] Depending on the context, the word "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection." Similarly, depending on the context, the phrase "if determination" or "if detection (of the stated condition or event)" can be interpreted as "when determination," "in response to determination," "when detection (of the stated condition or event)," or "in response to detection (of the stated condition or event)."

[0202] The terms "first" and "second" used in the embodiments are merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first" and "second" can be interchanged in a specific order or sequence where permitted. It should be understood that the objects distinguished by "first" and "second" can be interchanged where appropriate so that the embodiments described herein can be implemented in an order other than those illustrated or described herein.

[0203] 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 principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for intelligent detection of defects in wooden components of ancient buildings, characterized in that, Include: A heterogeneous defect detection network is constructed, comprising a teacher model based on the Vision Transformer architecture and a student model based on a convolutional neural network architecture. The teacher model loads pre-trained parameters and freezes them during training, while the student model is the network to be trained. The construction steps include: using the DINOv3 model based on the ViT-B architecture as the teacher model; the teacher model contains a Transformer encoder consisting of 12 sequentially connected encoder blocks; and using the YOLOv11-m model as the student model, which contains a backbone network and a neck network, outputting feature maps at three levels (P3, P4, and P5) with sequentially decreasing spatial resolution. Specifically, the outputs of the 3rd and 4th encoder blocks closest to the input in the teacher model are defined as shallow encoder features, matching the P3 level feature map of the student model; the outputs of the 7th and 8th encoder blocks in the middle of the teacher model are defined as mid-level encoder features, matching the P4 level feature map of the student model; and the outputs of the 11th and 12th encoder blocks closest to the output in the teacher model are defined as deep encoder features, matching the P5 level feature map of the student model. Images of wooden components of ancient buildings are acquired and input into a heterogeneous defect detection network, and multi-level feature maps are extracted through teacher and student models respectively. Multi-dimensional adaptive feature alignment and distillation are performed on the feature maps output by the student model and the feature maps output by the teacher model. Multi-dimensional adaptive feature alignment includes feature map spatial scale alignment using bilinear interpolation algorithm and feature map channel dimension mapping alignment using convolutional layers. Extracting feature maps from two adjacent layers in the teacher model and The concatenated features are obtained by concatenating them along the channel dimension; these concatenated features are then input into a convolutional layer with two output channels to generate a weight mapping map for the two channels. Perform a Softmax operation on the weight map in spatial location to obtain a normalized weight matrix. and And calculate the fused teacher target feature map. ;Calculate the feature distillation loss between the fused teacher target feature map and the aligned student feature map; where adjacent layers are the 3rd and 4th encoder blocks, the 7th and 8th encoder blocks, and the 11th and 12th encoder blocks; ; ; ; ; In the formula, These are the indices of the three dimensions in the feature map; for The weights; for The weights; It is a natural exponential function; This is the weight mapping diagram for the first channel; This is the weight mapping diagram for the second channel; Indices for the feature maps of the three levels of the student model; The localization branch of the student model introduces a normalized Wasserstein distance metric, which models the predicted bounding box and the ground bounding box as a two-dimensional Gaussian distribution. The similarity between the distributions is measured by calculating the Wasserstein distance to calculate the localization loss. The student model is then jointly trained end-to-end by combining the feature distillation loss. The trained student model is used to perform defect detection inference on images of ancient building wooden components and output the defect detection results.

2. The intelligent detection method for defects in ancient architectural wooden components according to claim 1, characterized in that, Feature map spatial scale alignment specifically includes: Obtain the spatial resolution of the feature map output by the teacher model, and the spatial resolution of the feature maps P3, P4 and P5 output by the student model; For the feature map P3 of the student model, the feature map output by the shallow encoder block of the teacher model is upsampled to the same spatial size as P3 using a bilinear interpolation algorithm; For the feature map P4 of the student model, the feature map output by the encoder block in the middle layer of the teacher model is downsampled to the same spatial size as P4 using a bilinear interpolation algorithm; For the feature map P5 of the student model, the feature map output by the deep encoder block of the teacher model is downsampled to the same spatial size as P5 using a bilinear interpolation algorithm; The pixel mapping rule based on bilinear interpolation is as follows: for any pixel in the target feature map... The floating-point coordinates are obtained by mapping them to the coordinate system of the source feature map according to the scaling ratio. Four integer coordinate pixels adjacent to the floating-point coordinates in the source feature map are selected. The weights are calculated based on the distance between the floating-point coordinates and the four integer coordinate pixels. The pixel values ​​of the four integer coordinate pixels are then weighted and summed to obtain the value of the target pixel.

3. The intelligent detection method for defects in ancient architectural wooden components according to claim 1, characterized in that, Feature map channel dimension mapping alignment specifically includes: Determine the number of channels in the feature maps of each level of the student model. The number of channels in the feature map of the teacher model ; After each layer's feature output in the student model, a convolutional kernel with a size of [size missing] is connected. Convolutional layers; The convolutional layer is used to increase the number of channels in the student model feature map from... Linear projection mapping to This ensures that the mapped student feature map and the teacher model feature map are consistent in the channel dimension.

4. A method for intelligent detection of defects in ancient architectural wooden components according to any one of claims 1 to 3, characterized in that, The calculation of characteristic distillation losses specifically includes: Aligned student feature maps are calculated using a smoothed L1 loss function. With the integrated teacher target feature map The differences between them are calculated, and the losses at different levels are weighted and summed. ; ; In the formula, Total characteristic distillation loss; for Weights of feature maps at each level; for Loss of hierarchy; This is the smoothed L1 loss function.

5. The intelligent detection method for defects in ancient architectural wooden components according to claim 4, characterized in that, The calculation of positioning loss specifically includes: Predict bounding box and true bounding box They are modeled as two-dimensional Gaussian distributions. and ; Calculate the square of the Wasserstein distance between two Gaussian distributions. The bounding box contains only the coordinates of the center point. and width and height In this case, the simplified formula is as follows; ; Calculate the normalized Wasserstein distance based on the Wasserstein distance. and its positioning loss : ; ; In the formula, Indicates the coordinates of the center point; for The coordinates; for The coordinates; Represent the covariance matrix; for The covariance matrix; for The covariance matrix; and for The width and height parameters related to diagonal elements; and for The width and height parameters related to diagonal elements; These are constants related to the dataset; It is a natural exponential function; Joint training minimizes the total loss function. To optimize student model parameters; ; In the formula, For classification loss; To locate the loss; Total characteristic distillation loss; For distribution focus loss; , , and They are respectively , , and The weight parameters.

6. An intelligent detection device for defects in wooden components of ancient buildings, characterized in that, Used to perform the intelligent detection method for defects in ancient architectural wooden components as described in any one of claims 1 to 5; The intelligent detection device for defects in ancient building wooden components includes: The network building module is used to build a heterogeneous defect detection network. The network includes a teacher model based on the Vision Transformer architecture and a student model based on the convolutional neural network architecture. The teacher model loads pre-trained parameters and freezes the parameters during training, while the student model is the network to be trained. The feature extraction module is used to acquire images of wooden components of ancient buildings and input them into the heterogeneous defect detection network, and extract multi-level feature maps through the teacher model and student model respectively. The feature alignment module is used to perform multi-dimensional adaptive feature alignment and distillation on the feature maps output by the student model and the feature maps output by the teacher model. The multi-dimensional adaptive feature alignment includes feature map spatial scale alignment using bilinear interpolation algorithm and feature map channel dimension mapping alignment using convolutional layers. The feature fusion module is used to extract feature maps of adjacent layers of the teacher model, introduce learnable weight parameters to adaptively weight and fuse the feature maps of adjacent layers, and calculate the feature distillation loss between the fused teacher target feature map and the aligned student feature map. The training module introduces a normalized Wasserstein distance metric into the localization branch of the student model. It models the predicted bounding boxes and the ground truth bounding boxes as two-dimensional Gaussian distributions, measures the similarity between the distributions by calculating the Wasserstein distance to calculate the localization loss, and performs end-to-end joint training of the student model by combining the feature distillation loss. The trained student model is used to perform defect detection inference on images of ancient building wooden components and output the defect detection results.

7. An intelligent detection device for defects in wooden components of ancient buildings, characterized in that, It includes a processor, a memory, and a computer program stored in the memory; the computer program can be executed by the processor to implement the intelligent detection method for defects in ancient building wooden components as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform an intelligent detection method for defects in ancient building wooden components as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Defect detection method and device based on multi-scale characteristic distillation and medium

    CN113962928A

  • Semi-supervised domain adaptive weak light environment pedestrian detection method

    CN117854044A