Semi-supervised detection method based on UAV-based adaptive inspection of overhead lines
By using semi-supervised methods and teacher-student mutual learning framework in drone distribution network overhead line detection, and using feature queues and similarity matrices to generate pseudo labels, the problem of utilizing unlabeled data in complex environments is solved and the recall of target detection is improved. efficiency and stability, meeting the real-time and accuracy of adaptive inspection.
Patent Information
- Application Number
- CN202410962896.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-07-18
AI Technical Summary
The existing technology is difficult to effectively utilize unlabeled data in the complex environment of distribution network overhead lines, resulting in low target detection recall rate, insufficient model stability and accuracy, and unable to meet the real-time and accuracy requirements of adaptive inspection.
A semi-supervised detection method based on drones is used to improve the model's ability to process unlabeled data through feature queues and similarity matrices. Combined with the teacher-student mutual learning framework, accurate pseudo-labels are generated to enhance the model's robustness and Generalization ability, reducing dependence on large amounts of annotated data.
It improves the recall rate and stability of the model in complex environments, meets the real-time and accuracy requirements of adaptive inspection, and reduces the dependence on a large amount of annotated data.
Smart Images

Figure CN118506221B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of target detection and discloses a semi-supervised detection method based on adaptive inspection of overhead lines by unmanned aerial vehicles. Background Art
[0002] As a key component of the power system, distribution network lines are crucial to ensuring the safety and stability of power supply. Since distribution network overhead lines cross cities, mountains and other complex terrains, and have long spans and many poles, the adaptive inspection of distribution network overhead lines requires the collection of a huge amount of distribution network line data to complete the inspection work in a complex background environment. However, the massive data covering different scenes and situations also has a huge demand for manual labeling. The video data collected by drones contains a large amount of redundant and inefficient line data, which further increases the workload of labeling.
[0003] Ordinary target detection methods can only use labeled data, resulting in low recall rates for target detection in some scenarios. At the same time, traditional semi-supervised target detection methods often perform poorly when faced with massive amounts of unlabeled data. Especially in the complex environment of distribution lines, the diversity and validity of data are difficult to predict, and conventional models often have difficulty making full use of unlabeled data, or use pseudo-labels incorrectly, which reduces the stability of the model and fails to meet the real-time and accuracy requirements of adaptive inspection tasks. Summary of the invention
[0004] The purpose of the invention is to provide a semi-supervised detection method based on adaptive inspection of overhead lines by unmanned aerial vehicles to solve the above-mentioned problems existing in the prior art.
[0005] The technical solution is a semi-supervised detection method based on the adaptive inspection of overhead lines by drones, which includes the following steps:
[0006] S1, collecting image data of distribution network overhead lines, and preprocessing them, dividing the preprocessed image data into labeled data and unlabeled data;
[0007] S2. Input the labeled data into a pre-trained neural network model to generate a first feature and a first feature classification score, and construct a feature queue based on the first feature and the first feature classification score;
[0008] S3. Based on the feature queue and unlabeled data, construct positive and negative samples, and calculate the contrast loss of positive and negative samples;
[0009] S4. Based on contrast loss, the unlabeled data is input into the neural network model to generate the second feature and the second feature classification score, and a similarity matrix is constructed based on the second feature and the feature queue;
[0010] S5, determining pseudo labels for unlabeled data based on the similarity matrix and the second feature classification score;
[0011] S6. Adopt the framework of mutual learning between teachers and students, construct the supervised loss based on the first feature, construct the semi-supervised loss based on the second feature and pseudo-label, and use the supervised loss and semi-supervised loss to train the neural network model.
[0012] Beneficial effects: The present invention improves the model's ability to process unlabeled data and enhances the robustness and generalization ability of the model by introducing feature queues and similarity matrices; in the training process, the similarity matrix is combined with the feature classification score to more accurately confirm more pseudo-labels, thereby improving the recall of difficult samples in complex environments, thereby enhancing the stability of the model and meeting the real-time and accuracy requirements of adaptive inspection tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 It is a flow chart of the present invention.
[0014] Figure 2 This is a flow chart of step S1 of the present invention.
[0015] Figure 3 This is a flow chart of step S2 of the present invention.
[0016] Figure 4 This is a flow chart of step S3 of the present invention.
[0017] Figure 5 This is a flow chart of step S4 of the present invention.
[0018] Figure 6 This is a flow chart of step S5 of the present invention.
[0019] Figure 7 This is a flow chart of step S6 of the present invention. DETAILED DESCRIPTION
[0020] like Figure 1 As shown, the present application proposes a semi-supervised detection method based on adaptive inspection of overhead lines by drones, comprising the following steps:
[0021] S1, collecting image data of distribution network overhead lines, and preprocessing them, dividing the preprocessed image data into labeled data and unlabeled data;
[0022] S2. Input the labeled data into a pre-trained neural network model to generate a first feature and a first feature classification score, and construct a feature queue based on the first feature and the first feature classification score;
[0023] S3. Based on the feature queue and unlabeled data, construct positive and negative samples, and calculate the contrast loss of positive and negative samples;
[0024] S4. Based on contrast loss, the unlabeled data is input into the neural network model to generate the second feature and the second feature classification score, and a similarity matrix is constructed based on the second feature and the feature queue;
[0025] S5, determining pseudo labels for unlabeled data based on the similarity matrix and the second feature classification score;
[0026] S6. Adopt the framework of mutual learning between teachers and students, construct the supervised loss based on the first feature, construct the semi-supervised loss based on the second feature and pseudo-label, and use the supervised loss and semi-supervised loss to train the neural network model.
[0027] In this embodiment, first, through data preprocessing and feature extraction, the system is allowed to learn from the actual distribution network overhead line image and better adapt to changes in the actual environment, such as lighting, weather and the physical state of the line. Extracting features through a pre-trained neural network model can ensure that the model can capture key information and can better distinguish different objects in subsequent steps. Secondly, by constructing positive and negative samples and calculating contrast losses, unlabeled data can be used to enhance the generalization ability of the model, which can significantly reduce the need for manual labeling. Through the generation of similarity matrices and pseudo-labels, the adaptive ability of the model is further improved. By comparing the similarity between unlabeled data and known features, the model can automatically generate pseudo-labels for these data and use these data in the training process, thereby improving the accuracy and robustness of the model. Finally, the supervised loss and semi-supervised loss are combined through the framework of mutual learning and mutual learning between teachers and students, so that the model can continuously improve itself during the learning process. The student model learns the knowledge of the teacher model and also enhances the learning effect through its own exploration. This two-way learning mechanism can effectively improve the performance of the model.
[0028] This embodiment combines semi-supervised learning with a teacher-student mutual learning framework, which not only improves the adaptability and accuracy of the model, but also reduces the dependence on a large amount of labeled data.
[0029] like Figure 2 As shown, according to one aspect of the present application, step S1 is further:
[0030] S11, collecting image data of the distribution network overhead lines, performing target detection on the image data, and obtaining detection results;
[0031] S12. Calculate the importance score of each pixel in the image data based on the detection result;
[0032] S13, setting a uniform grid on the image data, and subdividing the grid based on the importance score to generate an adaptive grid;
[0033] S14, for each grid cell in the adaptive grid, calculating a local transformation matrix from the image data to a preset target size;
[0034] S15, based on the local transformation matrix, using bilinear interpolation, mapping the corresponding area in the image data to the target size image;
[0035] S16, performing edge smoothing processing on the mapped target size image to obtain pre-processed image data;
[0036] S17, dividing the preprocessed image data into labeled data and unlabeled data.
[0037] In a further embodiment, a distribution network overhead line image dataset taken by a drone is collected as the original image. Since the images collected by the distribution network lines of the drone are mostly large-size images of 5000×3000 pixels, in order to improve the inspection performance, the original images are preprocessed, including resizing to 640×640 and basic data enhancement. Specifically, the original image I orig Perform preliminary downsampling to obtain the downsampled image I down (Size is H target ×W target ×3); where H target Indicates the height of the image, W target Represents the width of the image, using the detection model to detect the image I down Perform target detection and obtain the detection result D=(b i , c i ,s i ), where b i is the bounding box coordinate, c i is the category, s i is the confidence. According to the detection result D, the importance score of each pixel is calculated: for each detection box b i , calculate the importance mask M i :
[0038] M i (x,y)=s i ·exp(-(((xx c ) 2 +(yy c ) 2 ) / (2σ 2 )))
[0039] Where (x c ,y c ) represents the center of the bounding box, σ is proportional to the size of the bounding box, represents the standard deviation, and exp( ) represents the exponential function; merge all importance masks:
[0040] Mtotal =max(M1,M2,...,M n )
[0041] Among them, M total represents all importance masks, i.e., important regions, M n Represents the importance mask of the nth detection box;
[0042] Initialize the uniform grid G uniform (Size is g h ×g w ), according to the importance area M total Adjust the grid density, for each grid cell G ij , calculate its average importance score:
[0043] S ij =mean(M total (G ij ))
[0044] Among them, mean( ) means taking the average value;
[0045] Use importance score S ij Subdivide the grid, if S ij >threshold high , divide the grid cells into 2×2; if threshold low ij <=threshold high , divide the grid cells into 1×2 or 2×1; where threshold high Indicates the high threshold, threshold low Represents a low threshold, which is used to determine the subdivision method of the grid unit and finally generate an adaptive grid G adaptive .
[0046] Then, based on the adaptive grid G adaptive , perform non-uniform image scaling. For the adaptive grid G adaptive For each grid cell in , calculate the local transformation matrix T from the original image to the target size ij ; Use bilinear interpolation to convert the original image I orig The corresponding area in is mapped to the target size image I target middle.
[0047] Detect discontinuous edges in an adaptively scaled image and apply a local weighted average filter to smooth these edges:
[0048] I smooth (x,y)=∑ i,j w ij Itarget (x+i,y+j) / ∑ i,j w ij
[0049] Among them I smooth represents the smoothed image, w ij is a weight based on pixel distance and intensity difference, i and j represent the offset of the filter window, and x+i and y+j represent the offset position relative to the current pixel (x, y) in the original image;
[0050] Crop or pad the smoothed image to the exact target size and normalize it:
[0051] I final =(I smooth -μ) / σ
[0052] Where μ and σ are the mean and standard deviation of the image, respectively. final Represents the final image, and divides the final image data into labeled data sets and unlabeled data sets.
[0053] This embodiment adaptively adjusts the scaling ratio of different areas of the image according to the importance of the image content. The important areas in the image are determined through preliminary target detection. An adaptive grid is generated, and a higher sampling density is used for important areas. Non-uniform image scaling and edge smoothing are used to ensure the final image quality, solve the problem of small target loss or blurring caused by traditional fixed-ratio scaling, and improve the model's detection accuracy for key targets, especially for high-resolution drone images, while maintaining key information, effectively reducing computational complexity.
[0054] In order to solve the problem that small targets are easily lost and the processing complexity is large in high-resolution UAV images, non-uniform scaling of different image areas is achieved through important area determination and adaptive grid generation. This effectively reduces the computational complexity while maintaining the clarity of key targets, thereby improving the detection accuracy and processing efficiency of the model for small targets.
[0055] like Figure 3 As shown, according to one aspect of the present application, step S2 is further:
[0056] S21, inputting the labeled data into a pre-trained neural network model, extracting a feature map of the labeled data, and extracting a feature vector at each spatial position of the feature map;
[0057] S22, classifying the feature vector, and calculating a first feature classification score based on the classification result;
[0058] S23, using Monte Carlo dropout technique to estimate the uncertainty of the neural network model;
[0059] S24. Determine the first feature based on the uncertainty and the first feature classification score, and perform bi-norm normalization on the first feature;
[0060] S25, constructing a feature queue based on the first feature normalized by the binary norm and the first feature classification score;
[0061] S26, using the queue category pointer, locating the storage location of each category of features in the feature queue;
[0062] S27. Synchronize and aggregate the feature queue and queue category pointers in each process.
[0063] In a specific embodiment, the pre-stored feature, i.e., the first feature, is located by the feature classification score, and normalization and queue management operations are performed simultaneously to construct a feature queue. The model is pre-trained using labeled data, and 10 rounds of training are performed to ensure that the features generated by the model have a certain ability to distinguish categories. After the pre-training is completed, the pre-stored feature is located using the feature classification score. When the feature classification score is greater than 0.7, the feature is marked as a pre-stored feature with a higher confidence level; after obtaining the pre-stored feature, the pre-stored feature is classified by category index of the feature classification score, and all pre-stored features are subjected to a two-norm normalization operation:
[0064] L2norm(x')=x' / (sqrt(∑ i=1 n x' i 2 )
[0065] Among them, x' represents the feature generated by the model, L2norm (x') represents the normalization operation of the feature x', and x' i Represents the i-th component or element in the feature vector x' generated by the model;
[0066] To avoid overwriting old features, the queue category pointer is set to locate the storage position of the feature in the queue; at the same time, due to the use of distributed training, the feature queue and queue category pointer need to be synchronized and summarized in each process to avoid data redundancy or loss.
[0067] In a further embodiment, a basic neural network model (such as ResNet50) is constructed as a feature extractor; a classification head and a regression head are added for target detection; a cyclic learning rate strategy and progressive fine-tuning are used for training, and mixed precision training is used to improve efficiency, specifically, the model is trained for N rounds using labeled data.
[0068] The preprocessed image is input into the pretrained model, and feature maps are extracted from the middle and last layers of the model. For each feature map, it is regarded as a H×W'×C tensor, where H and W' are the height and width of the feature map, and C is the number of channels; for each spatial position (i, j) on the feature map, a C-dimensional feature vector x' is extracted ij , for each feature map, we get H×W' C-dimensional feature vectors. For each feature vector x', we classify it through the fully connected layer (classification head):
[0069] z ij =W·x' ij +b
[0070] where z ij represents the score output by the classification head, W represents the weight matrix, and b represents the bias vector;
[0071] The probability of belonging to each category is calculated by the softmax function:
[0072] p(y|x')=softmax(W x'+b)
[0073] Where p(y| x') represents the probability that the feature vector x' belongs to each category;
[0074] Select the class with the highest probability as the predicted class:
[0075] y pred =argmax(p(y| x'))
[0076] where y pred Represents the predicted category, argmax() means taking the category with the highest probability;
[0077] The probability value of the category is used as the feature classification score:
[0078] score=max(p(y|x'))
[0079] Where score represents the feature classification score, that is, the highest category probability.
[0080] Read and use the classification head to perform preliminary classification on the feature map to obtain the category probability distribution at each position. The classification head is usually a 1×1 convolution layer, which can be regarded as a fully connected layer applied at each spatial position. Assuming there are K categories, the parameters of this convolution layer are: weight W is [1, 1, C, K], bias b is [K]; apply 1×1 convolution to the feature map:
[0081] z=conv2d(feature map , W)+b
[0082] Where z represents the score of the convolution layer output, conv2d() represents a two-dimensional convolution operation, and feature map Represents a feature map;
[0083] The shape of the score z output by the convolutional layer is [H, W, K], and the softmax function is applied on the last dimension:
[0084] p=softmax(z,axis=-1)
[0085] p represents the category probability distribution at each position. The shape of p is still [H, W, K], but now the sum of the K values at each spatial position is 1. axis=-1 means that the softmax function is applied on the last dimension.
[0086] Use the regression head to predict the bounding box coordinates for each location. Use another fully connected layer (regression head) to predict the bounding box coordinates corresponding to each feature vector:
[0087] bbox ij =W bbox ·x' ij +b bbox
[0088] Where bbox ij represents the predicted bounding box coordinates, W bbox represents the weight matrix of the regression head, b bbox represents the bias vector of the regression head;
[0089] Use Monte Carlo dropout to estimate model uncertainty. Keep the dropout layer enabled during the inference phase; perform T forward propagations (e.g., T=20) on the same input to get T different predictions; calculate the prediction variance as an estimate of uncertainty:
[0090] uncertainty=var(y pred1 ,y pred2 , ..., y predT )
[0091] where uncertainty represents the uncertainty estimate, var() represents the variance, and y predT Represents the prediction result of the Tth forward propagation;
[0092] Combining the classification score and uncertainty, features with high confidence and low uncertainty (classification score > 0.7 and uncertainty < 0.2) were selected.
[0093] Perform binary norm normalization on pre-stored features, set queue category pointers and synchronize feature queues in distributed training. Update normalization factors using exponential sliding average:
[0094] norm factor =α·norm factor +(1-α)·current norm
[0095] where norm factor represents the normalization factor, α is the smoothing coefficient, initially set to 0.99, and current norm Represents the current normalization factor; normalize using the updated normalization factor:
[0096] normalized feature =feature / norm factor
[0097] where normalized feature represents the normalized features, and feature represents the original features.
[0098] According to one aspect of the present application, step S25 also includes dynamically updating the feature queue, specifically:
[0099] S25a, using a time-based decay factor to update the weights of features in the feature queue according to a predetermined period;
[0100] S25b. Based on the distributed asynchronous update mechanism, a ring full reduction algorithm is used to synchronize the feature queue after the weight is updated.
[0101] Periodically update the weights of features in the queue using a time-based decay factor:
[0102] w t =w0·e -λt
[0103] Where w0 is the initial weight, λ is the decay rate, and t is the time the feature is in the queue;
[0104] Implement a distributed asynchronous update mechanism and use a ring full reduction algorithm to synchronize feature queues; Initial setting: There are N computing nodes, each with its own local feature queue, logically arranging the N nodes into a ring. Each node divides its feature queue into N equal blocks. In the scatter-reduce phase, N-1 iterations are performed. In the i-th iteration (i from 0 to N-2), each node sends the (rank+i)%Nth block of data to its next node; where % represents the modulo operator, ensuring that when (rank+i) exceeds N, the result will loop back to the range of 0~N-1, thereby realizing the cyclic transfer of data blocks between nodes. Rank represents the number or ranking of the current node; each node receives data from its previous node; after receiving the data, the node performs an element-level sum operation on the data with its corresponding data block. Then, in the all-gather phase, N-1 iterations are performed again. In the i-th iteration (i ranges from 0 to N-2), each node sends the (rank-i+N)%N block of data calculated in the previous phase to its next node; each node receives data from its previous node; the received data is directly saved without further calculation.
[0105] After completing the above steps, each node has exactly the same feature queue that includes contributions from all nodes. Use the synchronized data to update each node's local feature queue; perform deduplication on the merged feature queue to delete duplicate features; if the feature queue exceeds the predetermined size, it may be necessary to sample or delete the oldest features; update the timestamp of each feature in the feature queue for subsequent decay operations.
[0106] This embodiment addresses the problems of low utilization of unlabeled data and difficulty in identifying small sample categories in semi-supervised learning. By constructing a dynamic adaptive feature queue to store high-quality features and using a time decay mechanism and distributed asynchronous updates, it achieves efficient utilization of unlabeled data and effective learning of rare categories, thereby improving the adaptability and generalization ability of the model in complex and changing environments.
[0107] like Figure 4 As shown, according to one aspect of the present application, step S3 is further:
[0108] S31, calculating the similarity between the predetermined category features in the feature queue and the unlabeled data as positive samples;
[0109] S32, selecting non-predetermined category features in the feature queue, and calculating the similarity between the features and the unlabeled data as negative samples;
[0110] S33. Based on positive samples and negative samples, a cross entropy loss function is constructed as a contrast loss.
[0111] In a specific embodiment, in order to make the features in the feature queue compactly distributed within the class and have a large distance between classes, thereby helping to generate more accurate pseudo labels for unlabeled data, contrast loss is introduced:
[0112] Among the features generated by the model, take out the features of this type stored in the feature queue and calculate the similarity value with multiple normalized features with the attributes of this category in this round. Since the feature queue stores features of different images from multiple rounds, these features are used as positive samples to increase the diversity of samples and better compact the distance between classes:
[0113] sim(A,B)=(A,B) / (∣∣A∣∣⊙∣∣B∣∣)
[0114] Among them, sim(A, B) represents the similarity of features, A and B represent two sets of features, and features can be regarded as vectors. ⊙ is the dot product of vectors, |||A||| represents the second norm of vector A, and |||B||| represents the second norm of vector B. The stored features that do not belong to the category are extracted from the feature queue, and the similarity between multiple normalized features with the same category attributes as this round is calculated to construct negative samples; after the positive and negative samples are constructed, the sample data is input into the cross entropy loss function to complete the contrast loss:
[0115] Contrastive loss =BCE([pos sim , neg sim ], sim labels )
[0116] Among them, Contrastive loss represents the contrast loss function, pos sim is a positive sample, neg sim is a negative sample, sim labels To build the label, sim labels The corresponding positive samples are set to 1, the negative samples are set to 0, and BCE() represents the binary cross entropy loss function.
[0117] In a further embodiment, the similarity of positive samples is calculated and a temperature parameter τ is introduced for softening:
[0118] similarity=exp(x i ·x j / τ) / ∑ k exp(x i ·x k / τ)
[0119] where x i represents the feature vector of the i-th sample, x jrepresents the feature vector of the jth sample, k represents the index of all samples, x k represents the feature vector of the kth sample, τ represents the temperature parameter;
[0120] Use the hard example mining strategy to construct negative samples and calculate the loss of all negative samples; select the k negative samples with the highest loss (k is initially set to 20% of the number of samples processed in each training iteration), dynamically adjust the k value, and gradually increase the proportion of hard examples according to the training progress. Introduce the category balance factor β c :
[0121] β c =(1-ε) / (1-ε nc )
[0122] where n c is the number of samples of category c, ε is a hyperparameter (initial setting is 0.9), and the weighted contrast loss is calculated as:
[0123] L contrast =-∑ i ∑ j β ci log[exp(x i ·x j / τ) / ∑ k exp(x i ·x k / τ)]
[0124] where β ci Indicates category c i The balance factor.
[0125] like Figure 5 As shown, according to one aspect of the present application, step S4 is further:
[0126] S41. Based on contrast loss, the t-distributed random neighbor embedding algorithm is used to visualize the feature queue;
[0127] S42. Dynamically adjust the parameters of the neural network model based on the visualization results;
[0128] S43, inputting the unlabeled data into the neural network model after dynamically adjusting the parameters, generating a second feature, a second feature classification score, and a second feature regression coordinate;
[0129] S44, calculating the similarity between the second feature and the feature queue to form a similarity matrix;
[0130] S45. Use the graph attention network to refine the similarity matrix, and use the spectral clustering algorithm to cluster the refined similarity matrix.
[0131] In a specific embodiment, after the contrast loss is introduced, the features generated by the model have the ability to identify each other in the feature space, that is, they are compact within the class and have large intervals between classes. Then, the similarity matrix of the features can be constructed to measure the information content of the features from another dimension. By embedding the feature queue into the visual image of the feature space through the t-distributed random neighbor, it can be clearly seen that the feature space distribution after the contrast loss is introduced is compact within the class and has large intervals between classes. The unlabeled image is input into the model to generate three output features (b, 80, 80, 256), (b, 40, 40, 256), and (b, 20, 20, 256). The stored features in the feature queue are taken out and the similarity is calculated with the corresponding three-layer output features, where each feature calculates the similarity of the number of corresponding queue features for each category. Then, the similarity calculated for the feature in each category is averaged and processed by applying the softmax activation function. The similarity matrix is constructed by traversing all features:
[0132] sim metrix =sim(feature',queue)
[0133] sim metrix =softmax(sim metrix .min(-1))
[0134] Among them, feature' represents three output features, queue represents feature queue, sim metrix Represents the similarity matrix generated by calculating the similarity between the output features and the feature queue, min (-1) means calculating the average of the last dimension of the similarity matrix, softmax () means the softmax activation function, and sim () means the similarity function.
[0135] In a further embodiment, t-distributed random neighbor embedding and uniform popular approximation and projection (UMAP) are used for feature space visualization and analysis. The features are reduced in dimensionality, and the features are first reduced to 50 dimensions using principal component analysis (PCA); the t-distributed random neighbor embedding algorithm is applied to the features after PCA dimensionality reduction, the conditional probability between point pairs in the high-dimensional space is calculated, the KL divergence is minimized in the low-dimensional space, and the position of the points is optimized; the UMAP algorithm is used for dimensionality reduction, and a fuzzy topological representation in the high-dimensional space is constructed; similar topological structures are found in the low-dimensional space, and statistical indicators of feature distribution are calculated, and the intra-class variance is calculated as:
[0136] var intra =1 / N∑ i ∑ j ||x i -μ j || 2
[0137] Where N is the total number of samples, x i is the i-th sample in category j, μ j is the mean of category j;
[0138] The distance between classes is calculated as:
[0139] dist inter =1 / C*(C*-1)∑ i ∑ j ||μ i -μ j || 2
[0140] Where C* represents the total number of categories, μ i and μ j is the mean of different categories. The model parameters are adjusted dynamically according to the analysis results. If the intra-class variance increases, the contrast loss weight is increased; if the inter-class distance decreases, the proportion of difficult example mining is increased; the temperature parameter τ is adjusted according to the change of feature distribution.
[0141] Calculate the adaptive feature similarity matrix. Use cosine similarity to calculate the initial similarity matrix, introduce local sensitive hashing (LSH) to accelerate large-scale similarity calculations, and select k random hyperplanes as hash functions:
[0142] h i (x)=sign(w' i ·x+b i )
[0143] where h i (x) represents the i-th hash function, w' i represents the i-th random hyperplane, x' represents the feature vector, b i Represents the bias term, sign() represents the sign function, which is used to map the result to binary code; the feature vector is mapped to a k-bit binary code, and only the exact similarity between feature pairs with similar hash codes is calculated.
[0144] Apply the graph attention network (GAT) to refine the similarity matrix:
[0145] α ij =exp(LeakyReLU(a T [Wh i ||Wh j ])) / ∑ k∈Ni exp(LeakyReLU(a T [Wh i ||Wh k ]))
[0146] h i '=α*(∑j∈Ni α ij W j )
[0147] where α ij is the attention coefficient, h i and h j is the node feature, W is the learnable weight matrix, that is, the similarity matrix, a is the learnable parameter, LeakyReLU() represents the LeakyReLU activation function, N i represents the set of neighbor nodes of node i, h i ' represents the updated node features, α* represents the scaling factor;
[0148] Use the spectral clustering algorithm to cluster the refined similarity matrix and optimize the feature distribution. Construct the Laplacian matrix:
[0149] L=D–W
[0150] Where D is the degree matrix and W is the similarity matrix; calculate the eigenvalues and eigenvectors of the Laplace matrix L, select the eigenvectors corresponding to the k smallest non-zero eigenvalues, and perform K-means clustering on these k eigenvectors.
[0151] like Figure 6 As shown, according to one aspect of the present application, step S5 is further:
[0152] S51. When the second feature classification score is greater than or equal to 0.7, the corresponding second feature is used as a pseudo label; wherein the coordinate information of the pseudo label is the second feature regression coordinate, and the category information of the pseudo label is the category corresponding to the maximum value of the second feature classification score;
[0153] S52, when the second feature classification score is greater than or equal to 0.5 and less than 0.7, and the corresponding similarity matrix is greater than or equal to 0.8, the corresponding second feature is used as a pseudo label; wherein the coordinate information of the pseudo label is the second feature regression coordinate, and the category information of the pseudo label is the category corresponding to the maximum value of the similarity matrix;
[0154] S53, when the second feature classification score is greater than or equal to 0.3 and less than 0.5, if the corresponding similarity matrix is greater than or equal to 0.95, only the category corresponding to the maximum value of the similarity matrix is retained, and no pseudo label is set; otherwise, no pseudo label is set directly;
[0155] S54: When the second feature classification score is less than 0.3, no pseudo label is set.
[0156] In this embodiment, the classification scores and similarity matrices of the features are summarized and classified to obtain a pseudo-label assignment method. When the classification score is greater than or equal to 0.7, the feature is identified as a pseudo-label point, the regression coordinates of the feature are the coordinate information of the pseudo-label, and the category corresponding to the maximum value of the feature classification score is the category information of the pseudo-label, and the pseudo-label is determined to participate in the loss calculation of the model classification and regression; when the classification score is greater than or equal to 0.5 and less than 0.7, and the similarity matrix score corresponding to the feature is greater than or equal to 0.8, the similarity score is trusted, the feature is identified as a pseudo-label point, the regression coordinates of the feature are the coordinate information of the pseudo-label, and the category corresponding to the maximum value of the feature similarity matrix is the category information of the pseudo-label, and the pseudo-label is determined to participate in the model classification and regression. The loss of the model is calculated; when the classification score is greater than or equal to 0.3 and less than 0.5, and the similarity matrix score corresponding to the feature is greater than or equal to 0.95, the feature category is considered to be correct, but the positioning is inaccurate, and the feature is identified as an uncertain pseudo-label point. The category corresponding to the maximum value of the feature similarity matrix is the category information of the pseudo-label, and the uncertain pseudo-label only participates in the model classification loss calculation; when the classification score is greater than or equal to 0.3 and less than 0.5, and the similarity matrix score corresponding to the feature is less than 0.95, the feature category and positioning are considered to be inaccurate, but it may still be a valid label. The feature is identified as an uncertain pseudo-label point and does not participate in the loss calculation.
[0157] Furthermore, step S5 may also be:
[0158] S5a, using Bayesian neural network to estimate the uncertainty of neural network model;
[0159] S5b, based on the uncertainty and similarity matrix, a fuzzy logic system is used to adaptively assign pseudo labels to unlabeled data.
[0160] In a further embodiment, a Bayesian neural network is used to estimate model uncertainty, and a prior distribution (such as a Gaussian distribution) is imposed on the network weights; a weight prior distribution is defined for each layer of the neural network: for each weight w, it is assumed to obey a normal distribution: w~N(μ prior , σ prior 2 ), where μ prior represents the prior mean, which is usually set to 0, σ prior represents the prior variance, which is used as a hyperparameter adjustment, and N is the total number of samples; the variational inference is used to approximate the posterior distribution, and the variational posterior distribution is defined: for each weight w, its variational posterior distribution is defined as: q(w)~N(μ post , σ post 2 ), where μ post represents the posterior mean, which is a parameter to be learned, σ postRepresents the posterior variance, which is also a parameter that needs to be learned. To implement the reparameterization technique:
[0161] w=μ post +σ post ·ε
[0162] Where ε~N(0,1) represents the noise sampled from the standard normal distribution;
[0163] Define the objective function of variational inference (ELBO):
[0164] ELBO=E q [logp(D|w)]-KL(q(w)||p(w))
[0165] Where E q represents the expectation of the variational posterior distribution, logp(D|w) represents the likelihood function, and the KL divergence is used to measure the difference between the posterior distribution q(w) and the prior distribution p(w).
[0166] Estimate the uncertainty of the prediction by sampling multiple times. Multiple sampling is performed during the forward propagation. For each input x, T forward propagations are performed (such as T=30), and each forward propagation samples new weights from the posterior distribution. Calculate the statistics of the predicted distribution, specifically, calculate the average prediction:
[0167] μ pred =1 / T·∑ t y t
[0168] where y t Represents the prediction result of the tth forward propagation;
[0169] Calculate the prediction variance:
[0170] σ pred 2 =1 / T·∑ t (y t -μ pred ) 2 +1 / T·∑ t σ t 2
[0171] where σ t 2 is the variance of the model output at the tth sampling.
[0172] Uncertainty includes aleatoric uncertainty and epistemic uncertainty, where aleatoric uncertainty represents the inherent noise in the data, and epistemic uncertainty represents the uncertainty of model parameters. Total uncertainty = aleatoric uncertainty + epistemic uncertainty. For each predicted bounding box and category probability, calculate its uncertainty, and use uncertainty information to filter low-confidence detection results or guide post-processing steps.
[0173] Adaptive pseudo-label assignment based on uncertainty and similarity. Calculate the entropy of the prediction as an uncertainty measure:
[0174] H=-∑ i p i logp i
[0175] where p i represents the probability of the i-th category;
[0176] Combining uncertainty and similarity matrices, a fuzzy logic system is used to assign pseudo labels. Normalize the uncertainty estimate:
[0177] U norm =(UU min ) / (U max -U min )
[0178] Where U represents the uncertainty estimate, U min represents the minimum value of the uncertainty estimate, U max represents the maximum value of the uncertainty estimate;
[0179] Extract the rows related to the current sample in the similarity matrix: Srow=W[current sampleindex ,:]; where W represents the similarity matrix, current sampleindex Represents the index of the current sample, which is used to select a specific row from the matrix W: represents the selection of the row current sampleindex All columns of , that is, the entire row;
[0180] Define fuzzy sets: confidence fuzzy set is {low, medium, high}; uncertainty fuzzy set is {low, medium, high}; similarity fuzzy set is {low, medium, high}
[0181] The confidence membership function is:
[0182] μ conflow (x)=max(0,1-2x)
[0183] μ confmedium(x)=max(0,min(2x,2-2x))
[0184] μ confhigh (x)=max(0,2x-1)
[0185] where μ conflow Represents the membership function with low confidence, μ confmedium represents the membership function of the confidence level, μ confhigh represents a high confidence membership function, and x represents the normalized value of a specific metric;
[0186] The uncertainty membership function is:
[0187] μ uncertlow (x)=max(0,1-3x)
[0188] μ uncertmedium (x)=max(0,min(3x,2-3x))
[0189] μ uncerthigh (x)=max(0,3x-1)
[0190] where μ uncertlow Represents the membership function with low uncertainty, μ uncertmedium The membership function of uncertainty in the representation, μ uncerthigh Membership functions that represent high uncertainty;
[0191] The similarity membership function is:
[0192] μ simlow (x)=max(0,1-4x)
[0193] μ simmedium (x)=max(0,min(4x,2-4x))
[0194] μ simhigh (x)=max(0,4x-1)
[0195] where μ simlow Represents the membership function with low similarity, μ simmedium Represents the membership function of similarity in , μ simhigh Membership function indicating high similarity;
[0196] The fuzzy rules are defined as: R1: If the confidence is high, the uncertainty is low, and the similarity is high, then the pseudo-label credibility is high; R2: If the confidence is medium, the uncertainty is medium, and the similarity is high, then the pseudo-label credibility is medium; R3: If the confidence is low or the uncertainty is high or the similarity is low, then the pseudo-label credibility is low. For each sample, calculate its membership in each fuzzy set, apply fuzzy rules, use Mamdani reasoning method, use centroid method for defuzzification, and get the pseudo-label credibility score C". If C"> high threshold T high , assigned as a high confidence pseudo label; if the low threshold T low ≤C"≤High threshold T high , assigned as a medium confidence pseudo label; if C"< low threshold T low , no pseudo-labels are assigned. Finally, the pseudo-label set PL=(x i ,y i , b i , c" i ), where x i is a sample, y i is the predicted category, b i is the bounding box, c″ i is the confidence level.
[0197] Furthermore, an adaptive threshold strategy is designed to dynamically adjust the pseudo-label allocation criteria according to the training process. First, a performance trend analysis is performed to calculate the performance change rate of the last N rounds:
[0198] δ perf =(val performance -val performanceprev ) / val performanceprev
[0199] where val performance Indicates the current validation set performance indicator, val performanceprev Represents the performance index of the validation set of the previous round;
[0200] Use an exponential moving average to smooth the rate of change in performance:
[0201] δ perfsmooth =α·δ perf +(1-α) ·δ perfsmoothprev
[0202] Where α represents the smoothing coefficient, δ perfsmoothprev represents the smoothing performance change rate of the previous round, δ perf Indicates the rate of change of performance;
[0203] Analyze the distribution of pseudo labels and calculate the mean and standard deviation of pseudo label credibility scores:
[0204] μC =mean(C distribution )
[0205] σ C =std(C distribution )
[0206] Among them C distribution represents the pseudo-label credibility score distribution, σ C represents the standard deviation of the pseudo-label confidence score distribution, std() represents the standard deviation;
[0207] Adjust the base threshold based on performance trends:
[0208] If δ perfsmooth >0:T base =T baseprev ·(1+ψ·δ perfsmooth )
[0209] Otherwise: T base =T baseprev ·(1-γ·|δ perfsmooth |)
[0210] Where ψ and γ are adjustment coefficients, T base Indicates the current basic threshold, T baseprev Indicates the base threshold of the previous round;
[0211] Calculate new high and low thresholds:
[0212] T high =min(T base +k1·σ C , 0.95)
[0213] T low =max(T base -k2·σ C , 0.05)
[0214] Where k1 and k2 are adjustment coefficients;
[0215] Use an exponential moving average to smooth threshold changes:
[0216] T highsmooth =λ'·T high +(1-λ')·T highprev
[0217] T lowsmooth =λ'·T low +(1-λ')·T lowprev
[0218] Where T highprev Indicates the high threshold of the previous round, T lowprevrepresents the low threshold of the previous round, λ' represents the smoothing coefficient,
[0219] Adjust the threshold strictness based on the training epoch:
[0220] T highfinal =T highsmooth ·(1+ρ·epoch / total epochs )
[0221] T lowfinal =T lowsmooth ·(1-ρ·epoch / total epochs )
[0222] Where T highfinal represents the updated high threshold, T lowfinal represents the updated low threshold, epoch represents the current training round, and total epochs represents the total number of training rounds, T highsmooth represents the high threshold after smoothing, T lowsmooth represents the smoothed low threshold, and ρ represents the adjustment coefficient. Update the pseudo-label assignment standard and use the new high threshold T highfinal and low threshold T lowfinal .
[0223] like Figure 7 As shown, according to one aspect of the present application, step S6 is further:
[0224] S61, performing multi-scale fusion on the first feature to obtain a fused first feature, and converting the fused first feature into a first classification feature and a first regression feature;
[0225] S62. Constructing a supervision loss based on the first classification feature and the first regression feature;
[0226] S63, performing multi-scale fusion on the second feature to obtain a fused second feature, and converting the fused second feature into a second classification feature and a second regression feature;
[0227] S64. Construct a semi-supervised loss based on the second classification feature, the second regression feature and the pseudo label;
[0228] S65. Use supervised loss and semi-supervised loss to train the neural network model.
[0229] In a specific embodiment, after confirming the pseudo-label, the unlabeled data is subjected to data enhancement operations such as copying, pasting, and mixing, and then input into the model to calculate the semi-supervised loss. The semi-supervised loss and the supervised loss work together to complete the training of the model. The Cross Stage Partial Network (CSPNet) is used as the backbone network (BackBone), where CSPNet consists of 5 downsampling modules with a step size of 2, generating three output features (b, 80, 80, 256), (b, 40, 40, 256), and (b, 20, 20, 256); the Path Aggregation Network for Feature Pyramid as the neck module of the model The Pyramid (PAN-FPN) module performs multi-scale fusion of the three output features to make full use of feature information at different levels; the fully connected layer is used as the head module to output three classification features (b, 80, 80, c), (b, 40, 40, c), (b, 20, 20, c) and three regression features (b, 80, 80, 4), (b, 40, 40, 4), (b, 20, 20, 4), respectively. The output features are matched with the labels to construct the supervised loss, and during the training process, the features with higher classification scores are stored in the feature queue according to the category. The semi-supervised loss is constructed using the determined pseudo-labels, and the semi-supervised loss and the supervised loss jointly complete the training of the model.
[0230] In a further embodiment, a search space is defined. The set of operations is defined as:
[0231] O={3×3 depthwise-separable conv, 5×5 depthwise-separable conv, 3×3 dilated conv, 5×5 dilated conv, 3×3 max pooling, 3×3 avg pooling, identity, zero}; where 3×3 depthwise-separable conv represents a 3×3 depthwise separable convolution, 5×5 depthwise-separable conv represents a 5×5 depthwise separable convolution, 3×3 dilated conv represents a 3×3 dilated convolution, 5×5 dilated conv represents a 5×5 dilated convolution, 3×3 max pooling represents the maximum pooling of 3×3, 3×3 avg pooling represents the average pooling of 3×3, identity represents the identity operation, that is, the output is equal to the input, and zero represents the zero operation, that is, the output is zero.
[0232] The channel number search range is C = {16, 32, 64, 128, 256};
[0233] The connection method is E={skipconnection, concatenation, addition}; skipconnection means skip connection, which allows the information in the network to skip some layers and pass directly; concatenation means splicing, merging the feature maps of different layers in the channel dimension; addition means addition, adding the feature maps of different layers;
[0234] The number of nodes in the defined unit in the search unit structure is N=4, and each node can select the input: the output of the first two nodes and the output of all previous nodes;
[0235] Construct a super network H and convert the initial backbone network structure N init Converted to a parameterized network, a mixture operation (a weighted sum of all possible operations) is inserted at each searchable position.
[0236] The DARTS algorithm is used for optimization. The architecture parameters Φ are randomly initialized, the network weights w are randomly initialized, and the optimization process is repeated. In the weight optimization phase, the training data set D train Forward propagation, calculate the loss L train (w, Φ); back propagation, update weight w:
[0237]
[0238] Where Φ represents the architecture parameter, η w represents the weight learning rate, represents the gradient of the weight;
[0239] Extract the architecture, for each mixed operation, select the operation with the largest weight; remove the operation with probability lower than the threshold p threshold The connection of the optimized discrete architecture A is obtained discrete . Implement progressive architecture search, initialize the search stage s=0, and the maximum number of stages S max , progressive search loop: As long as the current stage s has not reached the maximum stage S max , and the resource limit R has not been reached, the cycle continues; adjust the search space according to the current stage s, increase the number of searchable layers, expand the channel number search range, and finally fine-tune the architecture, and fine-tune the network structure A with the best performance on the complete training set best weights; Apply knowledge distillation, from the initial backbone network structure N init To network structure A best , output the final optimized backbone network structure N final and the trained network weights wfinal .
[0240] Use the path aggregation network module of the feature pyramid or the dynamic convolution and cross-scale feature aggregation module for multi-scale feature fusion. When building and using the dynamic convolution and cross-scale feature aggregation module, the input multi-scale feature map {F1, F2, ..., F N}, where F i The size is H i ×W i ×C i Design a lightweight network G to generate dynamic convolution kernel parameters θ=G(I), where θ contains N sets of convolution kernel parameters {θ1, θ2, ..., θ N}, I represents the current input image; for each scale i, a dynamic convolution kernel is generated:
[0241] K i =reshape(θ i , [k, k, C i , C out ])
[0242] Where k is the convolution kernel size (such as 3×3), C out is the number of output channels, reshape() represents the reshaping function, θ i represents the convolution kernel parameters of the i-th scale, C i Indicates the number of input channels of the i-th scale;
[0243] For each feature map F i Apply the corresponding dynamic convolution kernel:
[0244] F idyn =conv2d(F i , K i )
[0245] where F idyn Represents the feature map after applying the dynamic convolution kernel, and conv2d() represents a two-dimensional convolution operation;
[0246] Add residual connection:
[0247] F ires =F idyn +F i
[0248] where F ires Represents the feature map after adding residual connection;
[0249] Construct a feature pyramid, a top-down path, and traverse each scale from top to bottom in the feature pyramid:
[0250] F iup= upsample(F i+1 res )
[0251] F ifused =conv1×1(concat(F ires , F iup ))
[0252] where F iup represents the upsampled feature map, F i+1 res represents the feature map of the next scale, upsample() represents the function of increasing the feature map to a higher resolution, F ifused Represents the fused feature map, conv1×1 represents 1x1 convolution, and concat() represents the concatenation function;
[0253] Perform multi-scale feature fusion, upsample all feature maps to the maximum resolution, and for each scale i from 1 to N, the fused feature map F ifused Upsample to the maximum resolution to obtain the fused feature map F final .
[0254] Based on the dynamic weight adjustment of the focal loss, the focal loss parameters are initialized, the focal parameter ω is set (usually 2), and the category balance factor β is initialized to 0.25. The standard focal loss for each sample i is calculated as:
[0255] FL i = -β·y i ·(1-p i ) ω ·log(p i )-(1-β)·(1-y i )·p i ω ·log(1-p i )
[0256] where y i represents the true label of the i-th sample, y i ∈{0, 1}, p i is the probability that the i-th sample is classified as a positive class, and the model predicts that P=p i , ω represents the focusing parameter, β represents the category balance factor;
[0257] Compute the average loss over the batch:
[0258] FL avg =(1 / N) ∑FL i
[0259] Where N is the batch size,
[0260] Calculate the dynamic factor for the current training round:
[0261] ω=1-e / E
[0262] The dynamic factor focusing parameter ω decreases as the training progresses, e represents the current number of training rounds, and E represents the total number of training rounds;
[0263] Calculate the difficulty of each sample:
[0264] d i =|y i -p i |
[0265] where d i Indicates the difficulty of the sample;
[0266] For each sample, calculate the dynamic weight:
[0267] w i =1+ω·d i
[0268] Apply dynamic weights to the focal loss:
[0269] FL dyni =w i ·FL i
[0270] Among them, FL dyni Indicates that dynamic weight w is applied i focal loss;
[0271] Calculate the positive sample ratio: pos ratio =∑y i / N;
[0272] Dynamically adjust category balance factor: β dyn =clip(0.5-pos ratio , 0.1, 0.9); where clip() represents a function that limits the value to a specified range;
[0273] Recompute the focal loss with dynamic weights and balancing factors:
[0274] FL finali =-β dyn ·y i ·(1-p i ) ω ·log(p i )·w i -(1-β dyn )·(1-y i )·p i ω ·log(1-p i )·wi
[0275] Among them, FL finali represents the dynamic weighted focal loss for each sample, β dyn Represents the dynamically adjusted category balance factor;
[0276] Compute the final average loss for the batch:
[0277] FL finalavg =(1 / N) ∑FL finali
[0278] Use the fully connected layer as the head module, output classification features and regression features, and construct supervised loss and semi-supervised loss.
[0279] This embodiment uses differential architecture search (DARTS) and progressive search strategies to automatically optimize the backbone network structure. Define a search space containing various operations and connection methods, use the differential architecture search algorithm to alternately optimize the network weights and architecture parameters, and gradually expand the search space through progressive search to avoid falling into local optimality. It solves the problem that manual design of network structure is time-consuming and difficult to adapt to specific tasks, improves the performance of the model on specific tasks (such as drone image analysis), and finds the best balance between performance and efficiency under limited computing resources. In view of the problem that manual design of network structure is time-consuming and difficult to adapt to specific tasks, by defining a wide search space and combining the differential architecture search algorithm and the progressive search strategy, the backbone network structure is automatically optimized, and the best balance between performance and efficiency is found under limited computing resources, thereby improving the specific performance of the model on drone image analysis tasks.
[0280] A lightweight network is used to generate dynamic convolution kernel parameters based on the input image; the top-down and bottom-up feature pyramids are used to achieve effective fusion of multi-scale information; the attention mechanism is applied to further enhance the expression of important features. The model's ability to handle objects of different scales, especially the detection of small objects, is enhanced, the model's adaptability to complex scenes and the effectiveness of feature extraction are improved, and the problem that fixed convolution kernels are difficult to adapt to diverse inputs is solved.
[0281] To address the problems that fixed convolution kernels are difficult to adapt to diverse inputs and have insufficient multi-scale target detection performance, the convolution kernel parameters are dynamically generated and a multi-scale feature pyramid and attention mechanism are designed to effectively integrate features of different scales and enhance important information, thereby improving the model's ability to understand complex scenes and its detection performance for small targets.
[0282] Dynamically adjust the weights and category balance factors in the focus loss to adapt to the training process and data distribution. Dynamically adjust sample weights according to the training process, gradually focusing on more difficult samples; dynamically adjust category balance factors based on the category distribution of the current round; combine sample difficulty and category balance to calculate the final loss, guide the model to learn more effectively, effectively solve the problems of category imbalance and difficult and easy sample processing, improve the model's learning effect on difficult samples and rare categories, and enhance the model's adaptability during training.
[0283] In another embodiment, a semi-supervised target detection method in an adaptive inspection of overhead lines of a distribution network based on a drone specifically includes the following steps:
[0284] Step 1: Pre-train the model based on the labeled data, and build a feature queue based on the feature classification scores of the unlabeled data;
[0285] Step 2: In the feature generation process of the model, find multiple normalized features corresponding to each category, and at the same time, let multiple normalized features with certain category attributes construct samples by calculating similarities with each other, and calculate the loss based on positive and negative samples;
[0286] Step 3: Introduce contrast loss to enhance the ability of the model-generated features to distinguish each other in the feature space, thereby constructing a similarity matrix to further measure the information content of the features;
[0287] Step 4: The unlabeled image passes through the head network layer of the model, outputs the classification score, regression coordinates and similarity matrix of the feature, and confirms the pseudo label;
[0288] Step 5: A framework of mutual learning between teachers and students is adopted, in which the labeled data is enhanced by mosaic data, and the supervised loss is constructed through the student model. The unlabeled data is subjected to data enhancement operations such as copying, pasting, and mixing, and then input into the model to calculate the semi-supervised loss through pseudo labels. The semi-supervised loss and the supervised loss work together to complete the training of the model.
[0289] This embodiment proposes a similarity matching label method to give full play to the utilization rate of unlabeled data, improve the recall and accuracy of adaptive inspection targets, and help adaptive inspection tasks achieve better inspection results in complex environments.
[0290] This application generates pseudo labels for unlabeled data based on the similarity matching label method. First, feature queues are constructed for the three feature layers respectively, and the qualified features are normalized. These features are stored in the feature queues according to categories and updated during the training process. In order to construct positive and negative sample pairs of category features, contrast loss is introduced to make the features compactly distributed within the class and increase the distribution distance between classes. Then, the features in the feature queue are used to calculate the similarity with the normalized feature layer to form a category similarity matrix. Finally, the pseudo labels are assigned to determined pseudo labels and uncertain pseudo labels according to the similarity matrix and the confidence score of the classification feature, and semi-supervised loss is constructed according to the pseudo labels.
[0291] This application introduces feature queues and similarity matrices to help small sample categories determine pseudo labels more accurately, especially for difficult samples and small sample categories, thereby improving the model's ability to handle rare categories and samples that are difficult to accurately classify, and enhancing the model's robustness and generalization capabilities; during the training process, the similarity matrix and feature classification scores are combined to more accurately confirm and determine more pseudo labels, and the credibility of the similarity of difficult samples (such as small sample categories) is better than the classification score, thereby improving the recall of difficult samples in complex environments and helping the model converge better; since the feature queue stores a large number of features in different forms and periods, it helps adaptive inspection to effectively complete inspection tasks in a wider range of and more complex scenarios.
[0292] The preferred embodiments of the present invention are described in detail above; however, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, various equivalent transformations can be made to the technical solutions of the present invention, and these equivalent transformations all belong to the protection scope of the present invention.
Claims
1. A semi-supervised detection method based on UAV overhead line adaptive inspection, characterized in that: The steps include: S1, collecting image data of distribution network overhead lines, and preprocessing them, dividing the preprocessed image data into labeled data and unlabeled data; S2. Input the labeled data into a pre-trained neural network model to generate a first feature and a first feature classification score, and construct a feature queue based on the first feature and the first feature classification score; S3. Based on the feature queue and unlabeled data, construct positive and negative samples, and calculate the contrast loss of positive and negative samples; S4. Based on contrast loss, the unlabeled data is input into the neural network model to generate the second feature and the second feature classification score, and a similarity matrix is constructed based on the second feature and the feature queue; S5. Determine pseudo labels for unlabeled data based on the similarity matrix and the second feature classification score; S6. Adopt the framework of mutual learning between teachers and students, construct the supervised loss based on the first feature, construct the semi-supervised loss based on the second feature and pseudo-label, and use the supervised loss and semi-supervised loss to train the neural network model; Step S2 is further as follows: S21, inputting the labeled data into a pre-trained neural network model, extracting a feature map of the labeled data, and extracting a feature vector at each spatial position of the feature map; S22, classifying the feature vector, and calculating a first feature classification score based on the classification result; S23, using Monte Carlo dropout technique to estimate the uncertainty of the neural network model; S24. Determine the first feature based on the uncertainty and the first feature classification score, and perform bi-norm normalization on the first feature; S25, constructing a feature queue based on the first feature normalized by the binary norm and the first feature classification score; S26, using the queue category pointer, locating the storage location of each category of features in the feature queue; S27, synchronously summarizing the feature queue and queue category pointer in each process; Step S4 is further as follows: S41. Based on contrast loss, the t-distributed random neighbor embedding algorithm is used to visualize the feature queue; S42. Dynamically adjust the parameters of the neural network model based on the visualization results; S43, inputting the unlabeled data into the neural network model after dynamically adjusting the parameters, generating the second feature, the second feature classification score and the second feature regression coordinate; S44, calculating the similarity between the second feature and the feature queue to form a similarity matrix; S45. Use the graph attention network to refine the similarity matrix, and use the spectral clustering algorithm to cluster the refined similarity matrix.
2. The semi-supervised detection method based on UAV overhead line adaptive inspection according to claim 1 is characterized in that: Step S1 is further as follows: S11, collecting image data of the distribution network overhead lines, performing target detection on the image data, and obtaining detection results; S12. Calculate the importance score of each pixel in the image data based on the detection result; S13, setting a uniform grid on the image data, and subdividing the grid based on the importance score to generate an adaptive grid; S14, for each grid cell in the adaptive grid, calculating a local transformation matrix from the image data to a preset target size; S15, based on the local transformation matrix, using bilinear interpolation, mapping the corresponding area in the image data to the target size image; S16, performing edge smoothing processing on the mapped target size image to obtain pre-processed image data; S17, dividing the preprocessed image data into labeled data and unlabeled data.
3. The semi-supervised detection method based on UAV overhead line adaptive inspection according to claim 2 is characterized in that: Step S3 is further as follows: S31, calculating the similarity between the predetermined category features in the feature queue and the unlabeled data as positive samples; S32, selecting non-predetermined category features in the feature queue, and calculating the similarity between the features and the unlabeled data as negative samples; S33. Based on positive samples and negative samples, a cross entropy loss function is constructed as a contrast loss.
4. The semi-supervised detection method based on UAV overhead line adaptive inspection according to claim 3 is characterized in that: Step S5 is further as follows: S51. When the second feature classification score is greater than or equal to 0.7, the corresponding second feature is used as a pseudo label; wherein the coordinate information of the pseudo label is the second feature regression coordinate, and the category information of the pseudo label is the category corresponding to the maximum value of the second feature classification score; S52, when the second feature classification score is greater than or equal to 0.5 and less than 0.7, and the corresponding similarity matrix is greater than or equal to 0.8, the corresponding second feature is used as a pseudo label; wherein the coordinate information of the pseudo label is the second feature regression coordinate, and the category information of the pseudo label is the category corresponding to the maximum value of the similarity matrix; S53, when the second feature classification score is greater than or equal to 0.3 and less than 0.5, if the corresponding similarity matrix is greater than or equal to 0.95, only the category corresponding to the maximum value of the similarity matrix is retained, and no pseudo label is set; otherwise, no pseudo label is set directly; S54: When the second feature classification score is less than 0.3, no pseudo label is set.
5. The semi-supervised detection method based on UAV overhead line adaptive inspection according to claim 4 is characterized in that: Step S6 is further as follows: S61, performing multi-scale fusion on the first feature to obtain a fused first feature, and converting the fused first feature into a first classification feature and a first regression feature; S62. Constructing a supervision loss based on the first classification feature and the first regression feature; S63, performing multi-scale fusion on the second feature to obtain a fused second feature, and converting the fused second feature into a second classification feature and a second regression feature; S64. Construct a semi-supervised loss based on the second classification feature, the second regression feature and the pseudo label; S65. Use supervised loss and semi-supervised loss to train the neural network model.
6. The semi-supervised detection method based on UAV overhead line adaptive inspection according to claim 5 is characterized in that: Step S25 also includes dynamically updating the feature queue, specifically: S25a, using a time-based decay factor to update the weights of features in the feature queue according to a predetermined period; S25b. Based on the distributed asynchronous update mechanism, a ring full reduction algorithm is used to synchronize the feature queue after the weight is updated.
7. The semi-supervised detection method based on UAV overhead line adaptive inspection according to claim 5 is characterized in that: Step S5 may also be: S5a, using Bayesian neural network to estimate the uncertainty of neural network model; S5b, based on the uncertainty and similarity matrix, a fuzzy logic system is used to adaptively assign pseudo labels to unlabeled data.
