Power cable position detection method, electronic equipment and medium based on VIT
Through the VisionTransformer-based power cable position detection method, the attention mechanism and transformer codec structure are used to solve the problem of accurate detection of traditional detection methods in complex environments, and the power cable with high robustness and generalization capabilities is achieved Test.
Patent Information
- Application Number
- CN202310146631.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-21
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2043-02-21
AI Technical Summary
Traditional visual detection methods based on geometric characteristics cannot accurately detect the location of high-altitude power cables in complex outdoor environments. Deep learning methods such as CNN rely on local information and are complex, making it difficult to achieve reliable object detection.
Using the power cable position detection method based on VisionTransformer (VIT), the pre-trained VIT detection model is used to perform feature extraction, position encoding, encoding and decoding and classification regression, and the attention mechanism and transformer encoding and decoding structure are used to realize global modeling and binary modeling. Graph matching, directly detect target boxes and categories.
It improves the robustness and generalization ability of power cable detection, can accurately detect the location of power cables in outdoor scenarios, reduces the dependence on prior knowledge, and simplifies engineering implementation.
Smart Images

Figure CN116128965B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a VIT-based power cable position detection method, electronic equipment, and medium. Background Art
[0002] With the rapid development of high-tech and its application in various industries, high-altitude power operations are gradually shifting from manual to automated and intelligent, thus meeting the requirements of power grid companies to reduce staff, increase efficiency and reduce risks. Intelligent operations require accurate detection of the position of high-altitude power cables, and the detection results can further assist the camera in three-dimensional positioning.
[0003] However, due to the changing lighting in outdoor scenes and the interference of reflections from various metal products near overhead lines, traditional visual detection methods based on geometric characteristics cannot cope with such complex situations. Deep learning detection methods based on CNN (Convolutional Neural Networks) usually rely too much on local information, resulting in a certain degree of unreliability. In addition, mainstream target detection algorithms, such as Faster-RCNN (Faster-Regions with CNN features) or YOLO (You Only LookOnce) series algorithms, require setting prior anchors and nms (non maximum suppression), which requires more hyperparameters to be trained and are more complicated in engineering implementation. Summary of the invention
[0004] The embodiments of the present application provide a VIT-based power cable position detection method, electronic device, and medium, which can accurately detect the position of power cables at high altitudes.
[0005] In a first aspect, an embodiment of the present application provides a method for detecting a power cable position based on VIT, and the method for detecting a power cable position based on VIT includes:
[0006] Obtain power cable images and obtain a pre-trained VIT detection model;
[0007] Using the skeleton network of the VIT detection model to extract features of the power cable image, to obtain target image features of the power cable image;
[0008] Performing position encoding on the target image features to obtain a target position encoding vector;
[0009] Encoding the target image features and the target position encoding vector using the encoder structure of the VIT detection model to obtain target encoding features;
[0010] Decoding the target encoding features using the decoder structure and object queries of the VIT detection model to obtain target decoding features;
[0011] The target decoding features are input into the classification and regression head module of the VIT detection model to obtain the predicted cable position in the power cable image.
[0012] In a second aspect, an embodiment of the present application further provides a power cable position detection device based on VIT, wherein the power cable position detection device based on VIT comprises:
[0013] An acquisition unit, used for acquiring a power cable image and a pre-trained VIT detection model;
[0014] An extraction unit, configured to extract features of the power cable image using a skeleton network of the VIT detection model to obtain target image features of the power cable image;
[0015] An encoding unit, used for performing position encoding on the target image feature to obtain a target position encoding vector;
[0016] The encoding unit is further used to encode the target image feature and the target position encoding vector using the encoder structure of the VIT detection model to obtain a target encoding feature;
[0017] A decoding unit, used to decode the target encoding features using the decoder structure of the VIT detection model and object queries to obtain target decoding features;
[0018] A prediction unit is used to input the target decoding features into the classification and regression head module of the VIT detection model to obtain the predicted cable position in the power cable image.
[0019] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory storing at least one instruction; and a processor executing the instructions stored in the memory to implement the above method.
[0020] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein at least one instruction is stored in the computer-readable storage medium, and the at least one instruction is executed by a processor in an electronic device to implement the above method.
[0021] The embodiment of the present application provides a method, electronic device and medium for detecting the position of power cables based on VIT. It has the following beneficial effects: the position of high-altitude power cables is accurately detected by using a pre-trained VIT detection model, and because the VIT detection model has an attention mechanism, no prior knowledge is required, the global modeling capability is guaranteed by the transformer encoding and decoding structure, and the one-to-one correspondence between prediction and manual annotation is guaranteed by bipartite graph matching optimization, and the target detection frame and category attributes can be directly obtained, which has higher robustness and stronger generalization ability in dealing with power cable detection in outdoor scenes. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0023] Figure 1 A schematic flow chart of a method for detecting a power cable position based on VIT provided in an embodiment of the present application;
[0024] Figure 2 A schematic diagram of a functional module of a power cable position detection device based on VIT provided in an embodiment of the present application;
[0025] Figure 3 A schematic block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0027] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0028] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0029] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0030] The embodiments of the present application provide a method, electronic device and medium for detecting the position of an aerial power cable based on VIT (Vision Transformer), wherein the method can be applied to a power cable position detection device based on VIT.
[0031] The executor of the VIT-based power cable position detection method may be the VIT-based power cable position detection device provided in the embodiment of the present application, or an electronic device integrating the VIT-based power cable position detection device, wherein the VIT-based power cable position detection device may be implemented in hardware or software, and the electronic device may be a detector, etc., specifically a control device in the detector, or a terminal or server having a communication connection with the control device.
[0032] See also Figure 1 , Figure 1 A flow chart of a VIT-based power cable position detection method provided in an embodiment of the present application. The VIT-based power cable position detection method provided in an embodiment of the present application can be applied to a VIT-based power cable position detection device. Of course, in other embodiments, the VIT-based power cable position detection method can also be applied to other types of detection equipment, which is not limited by the present application.
[0033] Specifically, the VIT-based power cable position detection method includes the following steps S110 - S160 .
[0034] S110: Acquire a power cable image and obtain a pre-trained VIT detection model.
[0035] In this embodiment, the power cable image may be collected by a camera or a camera device installed at a designated location, such as collecting the power cable image by a camera installed on a utility pole.
[0036] In this embodiment, the VIT detection model can be obtained by training a VIT network.
[0037] Specifically, before obtaining the pre-trained VIT detection model, the method further includes:
[0038] Use the image acquisition device to collect RGB (red, green, and blue) images of cables under different environmental conditions to construct an image set to be annotated, and obtain the initial VIT model and the pre-built loss function;
[0039] Annotating each image to be annotated in the set of images to be annotated to obtain a set of sample images;
[0040] Using the sample image set to train the initial VIT model, and detecting whether the loss function reaches convergence during the training process;
[0041] When it is detected that the loss function reaches convergence, the training is stopped to obtain the VIT detection model;
[0042] The environmental conditions include light, background and spatial position.
[0043] The step of labeling each image to be labeled in the set of images to be labeled includes:
[0044] Each image to be annotated in the image set to be annotated is annotated at a preset distance from the anti-vibration hammer. For example, each image to be annotated in the image set to be annotated can be annotated at a position about 1.2 m away from the anti-vibration hammer.
[0045] Wherein, detecting whether the loss function reaches convergence during the training process includes:
[0046] Obtain an unordered set of model outputs during each round of training, and extract multiple foreground categories and corresponding region of interest frames from the unordered set; obtain multiple marked categories and corresponding marked frames that have a corresponding relationship with the multiple foreground categories and the corresponding region of interest frames from the sample image set;
[0047] Each foreground category and the corresponding region of interest box are combined into a set of features to obtain multiple sets of output features; each tag category and the corresponding tag box are combined into a set of features to obtain multiple sets of tag features;
[0048] Using a bilateral matching algorithm to perform index matching on the multiple groups of output features and the multiple groups of label features, to obtain the optimal binary matching features obtained in each round of training;
[0049] Based on the optimal binary matching features obtained in each round of training, the sum of the predicted category loss and the bounding box prediction loss is calculated to obtain the target loss obtained in each round of training;
[0050] During the training process, when it is detected that the target loss no longer decreases, it is determined that the loss function has reached convergence;
[0051] The prediction category loss is calculated based on the foreground category with the highest prediction probability, and the bounding box prediction loss is a linear combination of the L1 loss and the GIOU loss of the prediction value of the region of interest box.
[0052] For example: Get 100 unordered sets output by the model in each round of training, and extract the foreground category and the corresponding bbox coordinates from the 100 unordered sets. Let y be the ground truth set, that is, the marked category and the corresponding marked box; Yi = (Ci, Bi) is the set predicted by the network, where Ci represents the prediction type, Bi represents the predicted bounding box bbox, where Bi = (xi, yi, wi, hi), (xi, yi) represents the center point of the bbox, wi represents the width of the bbox, hi represents the height of the bbox, and i is a positive integer. Further, the bilateral matching algorithm is used to solve the index matching loss between the predicted bounding box bbox and the marked bbox to obtain the optimal binary matching feature obtained in each round of training. Further, a loss function is created based on the optimal binary matching:
[0053]
[0054] Wherein, L represents the loss function; P(Ci) is the argmax of the prediction type Ci, that is, the prediction category loss, indicating the prospect category corresponding to the highest prediction probability; L box Represents the prediction loss corresponding to bbox, that is, the bounding box prediction loss. If Then the prediction loss corresponding to bbox is 0. box It is a linear combination of L1 loss and GIOU loss of bbox prediction value, specifically:
[0055] L box =a*L1+b*L GIOU
[0056] Wherein, L1 represents the L1 loss, L GIOU represents the GIOU loss, a and b are hyperparameters, a represents the importance of distance error, b represents the importance of area error, and a=b=0.5 can be configured.
[0057] Through the configured loss function, the foreground type is matched first and then the predicted bounding box is matched during the training process, which effectively improves the training effect of the model and further improves the accuracy of the trained VIT detection model.
[0058] S120 , using the skeleton network of the VIT detection model to perform feature extraction on the power cable image to obtain target image features of the power cable image.
[0059] In this embodiment, the skeleton network of the VIT detection model is used to extract features of the power cable image to obtain target image features of the power cable image, including:
[0060] Scaling the power cable image to obtain a first feature;
[0061] Determine the data volume of each batch of data, and construct a second feature according to the data volume of each batch of data and the first feature;
[0062] Inputting the second feature into the skeleton network for feature extraction to obtain a third feature;
[0063] The third feature is processed by dimension reduction using a 1*1 convolutional layer to obtain the target image feature.
[0064] For example, a single power cable image is resized to (c, h_0, w_0), and the image (b, c, h_0, w_0) is input into the skeleton network for feature extraction. The extracted feature map is reduced in dimension by 1*1 convolution, and the output shape is (b, d, h_1, w_1). Among them, c = 3, indicating the number of channels; h_0 = 800, indicating the image height; w_0 = 1200, indicating the image width; b = 16, indicating the number of images in a batch; h_1 = h_0 / / 32, w_1 = w_0 / / 32, d = 256, the transformed image has h_1*w_1 dimensions, and the feature of each dimension is a d-dimensional vector.
[0065] Wherein, b can be configured according to the performance of the GPU (Graphics Processing Unit) of the system.
[0066] S130, performing position encoding on the target image features to obtain a target position encoding vector.
[0067] In this embodiment, the performing position encoding on the target image feature to obtain the target position encoding vector includes:
[0068] The even-numbered bits of the target image feature are encoded using a sine function, and the odd-numbered bits of the target image feature are encoded using a cosine function to obtain the target position encoding vector.
[0069] In the above embodiment, the target image feature is expanded from 1-dimensional to 2-dimensional image, that is, position encoding is performed in both the horizontal and vertical directions to obtain the target position encoding vector.
[0070] S140, using the encoder structure of the VIT detection model to encode the target image features and the target position encoding vector to obtain target encoding features.
[0071] In this embodiment, the encoder structure includes a plurality of encoders connected end to end. For example, the encoder structure may be composed of 6 encoders connected in series.
[0072] Specifically, the target image feature and the target position encoding vector are encoded using the encoder structure of the VIT detection model to obtain the target encoding feature, including:
[0073] Adding the target image feature and the target position encoding vector bit by bit to obtain a first input vector;
[0074] The first input vector is input to a first encoder in the encoder structure, and output data of a last encoder in the encoder structure is obtained as the target encoding feature.
[0075] In the above encoding process, the shape of the feature remains unchanged.
[0076] S150, using the decoder structure of the VIT detection model and object queries to decode the target encoding features to obtain target decoding features.
[0077] In this embodiment, the decoder structure includes a plurality of decoders connected end to end. For example, the decoder structure may be composed of 6 decoders connected in series.
[0078] Specifically, the target encoding features are decoded using the decoder structure and object queries of the VIT detection model to obtain the target decoding features, including:
[0079] Initialize based on object queries to get a query vector with all values as 0;
[0080] Combining the query vector and the target encoding feature to obtain a second input vector;
[0081] The second input vector is input to a first decoder in the decoder structure, and output data of a last decoder in the decoder structure is obtained as the target decoding feature.
[0082] For example, we introduce learnable object queries, which aim to provide the relationship between the target object and the global image. We initialize a query vector with all zeros and a shape of (100, b, d), where 100 indicates that there are 100 categories. We decode and output the vector in combination with the position encoding vector, and the shape of the decoder output is (6, b, 100, d). 6 indicates the output of 6 decoders, and the following decoder accepts the output of the previous decoder and keeps moving forward.
[0083] S160: Input the target decoding features into the classification and regression head module of the VIT detection model to obtain the predicted cable position in the power cable image.
[0084] In this embodiment, the target decoding features are input into the classification and regression head module of the VIT detection model for classification and regression processing, so as to obtain the predicted cable position in the power cable image.
[0085] It can be seen from the above technical solutions that this application is based on a deep learning strategy and combines the transformer's multi-head attention mechanism to apply the vision transformer to high-altitude power cable target detection. It can obtain the similarity between the local and global representations of the power cable from the image, thereby adapting to complex outdoor environments and improving the detection effect and accuracy of the cable.
[0086] Figure 2 is a schematic block diagram of a VIT-based power cable position detection device provided in an embodiment of the present application. Figure 2 As shown, corresponding to the above VIT-based power cable position detection method, the present application also provides a VIT-based power cable position detection device. The VIT-based power cable position detection device includes a unit for executing the above VIT-based power cable position detection method, and the device can be configured in a detector or other equipment. Specifically, please refer to Figure 2 The VIT-based power cable position detection device 200 includes an acquisition unit 201, an extraction unit 202, an encoding unit 203, a decoding unit 204, and a prediction unit 205, wherein:
[0087] The acquisition unit 201 is used to acquire a power cable image and a pre-trained VIT detection model;
[0088] The extraction unit 202 is used to extract features of the power cable image using the skeleton network of the VIT detection model to obtain target image features of the power cable image;
[0089] The encoding unit 203 is used to perform position encoding on the target image feature to obtain a target position encoding vector;
[0090] The encoding unit 203 is further used to encode the target image feature and the target position encoding vector using the encoder structure of the VIT detection model to obtain a target encoding feature;
[0091] The decoding unit 204 is used to decode the target encoding features using the decoder structure of the VIT detection model and object queries to obtain target decoding features;
[0092] The prediction unit 205 is used to input the target decoding features into the classification and regression head module of the VIT detection model to obtain the predicted cable position in the power cable image.
[0093] The above-mentioned power cable position detection device based on VIT can be implemented in the form of a computer program. The computer program can be used in Figure 3 The electronic device shown is running.
[0094] See also Figure 3 , Figure 3 300 is a schematic block diagram of an electronic device provided in an embodiment of the present application. The electronic device 300 may be a device such as a detector, specifically a control device in the detector, or a terminal or server having a communication connection with the control device.
[0095] See also Figure 3 The electronic device 300 includes a processor 302 , a memory and a network interface 305 connected via a system bus 301 , wherein the memory may include a non-volatile storage medium 303 and an internal memory 304 .
[0096] The non-volatile storage medium 303 can store an operating system 3031 and a computer program 3032. The computer program 3032 includes program instructions, and when the program instructions are executed, the processor 302 can execute a power cable position detection method based on VIT.
[0097] The processor 302 is used to provide computing and control capabilities to support the operation of the entire electronic device 300 .
[0098] The internal memory 304 provides an environment for the operation of the computer program 3032 in the non-volatile storage medium 303 . When the computer program 3032 is executed by the processor 302 , the processor 302 can execute a power cable position detection method based on VIT.
[0099] The network interface 305 is used to communicate with other devices over the network. Figure 3 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device 300 to which the scheme of the present application is applied. The specific electronic device 300 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0100] The processor 302 is used to run a computer program 3032 stored in the memory to implement the following steps:
[0101] Obtain power cable images and obtain a pre-trained VIT detection model;
[0102] Using the skeleton network of the VIT detection model to extract features of the power cable image, to obtain target image features of the power cable image;
[0103] Performing position encoding on the target image features to obtain a target position encoding vector;
[0104] Encoding the target image features and the target position encoding vector using the encoder structure of the VIT detection model to obtain target encoding features;
[0105] Decoding the target encoding features using the decoder structure and object queries of the VIT detection model to obtain target decoding features;
[0106] The target decoding features are input into the classification and regression head module of the VIT detection model to obtain the predicted cable position in the power cable image.
[0107] It should be understood that in the embodiment of the present application, the processor 302 may be a central processing unit (CPU), and the processor 302 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0108] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.
[0109] Therefore, the present application also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the following steps:
[0110] Obtain power cable images and obtain a pre-trained VIT detection model;
[0111] Using the skeleton network of the VIT detection model to extract features of the power cable image, to obtain target image features of the power cable image;
[0112] Performing position encoding on the target image features to obtain a target position encoding vector;
[0113] Encoding the target image features and the target position encoding vector using the encoder structure of the VIT detection model to obtain target encoding features;
[0114] Decoding the target encoding features using the decoder structure and object queries of the VIT detection model to obtain target decoding features;
[0115] The target decoding features are input into the classification and regression head module of the VIT detection model to obtain the predicted cable position in the power cable image.
[0116] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which are computer-readable storage media that can store program codes.
[0117] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0118] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0119] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present application can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0120] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for an electronic device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.
[0121] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A method for detecting the position of a power cable based on VIT, characterized in that: The VIT-based power cable position detection method comprises: Obtaining a power cable image captured by a camera or a camera installed at a specified location, and obtaining a pre-trained VIT detection model; wherein the power cable image is taken in an outdoor scene with variable lighting, and there is reflective interference from various metal products near the overhead line; The skeleton network of the VIT detection model is used to extract features of the power cable image to obtain target image features of the power cable image, including: scaling the power cable image to obtain a first feature; determining the data volume of each batch of data, and constructing a second feature according to the data volume of each batch of data and the first feature; inputting the second feature into the skeleton network for feature extraction to obtain a third feature; performing dimensionality reduction processing on the third feature using a 1*1 convolutional layer to obtain the target image feature; wherein, for a single power cable image, the first feature (c, h_0, w_0) is obtained by scaling processing, and the second feature (b, c, h_0, w_0) corresponding to (c, h_0, w_0) is input into the skeleton network for feature extraction, and the extracted feature map is subjected to dimensionality reduction processing by a 1*1 convolutional layer, and the output shape=(b, d, h_1,w_1); where c=3, indicating the number of channels; h_0=800, indicating the image height; w_0=1200, indicating the image width; b=16, indicating the number of images in a batch, configured according to GPU performance; h_1=h_0 / / 32, w_1=w_0 / / 32, d=256, the transformed image has h_1*w_1 dimensions, and the feature of each dimension is a d-dimensional vector; Performing position encoding on the target image feature to obtain a target position encoding vector, including: encoding the even bits of the target image feature using a sine function, and encoding the odd bits of the target image feature using a cosine function to obtain the target position encoding vector; Encoding the target image feature and the target position encoding vector using the encoder structure of the VIT detection model to obtain a target encoding feature, including: adding the target image feature and the target position encoding vector bit by bit to obtain a first input vector; inputting the first input vector to a first encoder in the encoder structure, and obtaining output data of a last encoder in the encoder structure as the target encoding feature; The target coding features are decoded using the decoder structure and object queries of the VIT detection model to obtain target decoding features, including: obtaining a query vector (M, b, d) in which all bits are 0 based on object queries initialization; combining the query vector and the target coding features to obtain a second input vector; inputting the second input vector to the first decoder in the decoder structure, and obtaining output data (J, M, b, d) of the last decoder in the decoder structure as the target decoding features; wherein M represents M categories and J represents the number of decoders; Inputting the target decoding features into the classification and regression head module of the VIT detection model to obtain the predicted cable position in the power cable image; Wherein, the encoder structure includes a plurality of encoders connected end to end; the decoder structure includes a plurality of decoders connected end to end; Before obtaining the pre-trained VIT detection model, an image acquisition device is used to collect RGB images of cables under different environmental conditions to construct a set of images to be annotated, and an initial VIT model and a pre-constructed loss function are obtained; each image to be annotated in the set of images to be annotated is annotated to obtain a set of sample images; the initial VIT model is trained using the set of sample images, and whether the loss function has reached convergence during the training process; when it is detected that the loss function has reached convergence, the training is stopped to obtain the VIT detection model; wherein the environmental conditions include light, background and spatial position; The step of labeling each image to be labeled in the image set to be labeled includes: labeling each image to be labeled in the image set to be labeled at a preset distance from the shock-absorbing hammer; Wherein, the detection of whether the loss function has reached convergence during the training process includes: obtaining an unordered set of model outputs during each round of training, and extracting multiple foreground categories and corresponding region of interest boxes bboxes from the unordered set; obtaining multiple label categories and corresponding label boxes that have a corresponding relationship with the multiple foreground categories and corresponding region of interest boxes from the sample image set; combining each foreground category and the corresponding region of interest box into a set of features to obtain multiple sets of output features; combining each label category and the corresponding label box into a set of features to obtain multiple sets of label features; using a bilateral matching algorithm to index match the multiple sets of output features with the multiple sets of label features to obtain the optimal binary matching features obtained in each round of training; calculating the sum of the predicted category loss and the bounding box prediction loss based on the optimal binary matching features obtained in each round of training to obtain the target loss obtained in each round of training; during the training process, when it is detected that the target loss no longer decreases, it is determined that the loss function has reached convergence; wherein, the predicted category loss is calculated according to the foreground category with the highest prediction probability, and the bounding box prediction loss is a linear combination of the L1 loss and the GIOU loss of the predicted value of the region of interest box; Wherein, the loss function is expressed as follows: ; Wherein, L represents the loss function; P(Ci) is the prediction category loss of the prediction type Ci, indicating the corresponding prospect category when the prediction probability is the highest; L box is the prediction loss corresponding to bbox, indicating the prediction loss of the bounding box; if , then the prediction loss corresponding to bbox is 0; the value range of i is [1, N], where N represents the total number of prediction types; L box is the linear combination of L1 loss and GIOU loss of the bbox prediction value, L box It is expressed as follows: ; Wherein, L1 represents the L1 loss, L GIOU represents the GIOU loss, a and b are hyperparameters, a represents the importance of distance error, b represents the importance of area error, and a=b=0.
5.
2. An electronic device, characterized in that: The electronic device comprises: a memory storing at least one instruction; and A processor executes the instructions stored in the memory to implement the power cable position detection method based on VIT as claimed in claim 1.
3. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in an electronic device to implement the power cable position detection method based on VIT as claimed in claim 1.