Optical cable drawing parsing method based on dynamic pre-cutting and task decoupling alignment

Through dynamic pre-cutting and task decoupling and alignment methods, interference information in optical cable drawings is eliminated and detection head design is optimized, and the problem of insufficient detection performance in optical cable drawing analysis tasks in the existing technology is solved, and high-precision and efficient drawing analysis are achieved.

CN120279343BActive Publication Date: 2025-08-08NANJING UNIV OF POSTS & TELECOMM
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510766718.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-08-08
Estimated Expiration
2045-06-10

AI Technical Summary

Technical Problem

Existing object detection algorithms are difficult to meet high-precision requirements in optical cable drawing analysis tasks. Especially when dealing with specific tasks in complex scenarios, detection performance and memory usage are insufficient, and there is a lack of explicit task decoupling strategies. The differences between classification and positioning tasks are not fully paid attention to.

Method used

Using a method based on dynamic pre-cutting and task decoupling and alignment, we use dynamic cropping to remove interference information, use K-Means weak edge perception technology to cut the target area, and introduce a mixed frequency domain decoupling structure and a task alignment structure of the collection and distribution mechanism to optimize the detection head design and improve detection accuracy.

Benefits of technology

It realizes efficient acquisition of the detection target area in the optical cable drawing, eliminates interference content, improves detection and analysis accuracy, saves labor costs, and improves the calculation efficiency and accuracy of drawing detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120279343B_ABST
    Figure CN120279343B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for parsing optical cable drawings based on dynamic pre-cutting and task decoupling and alignment. The method comprises obtaining original substation drawing data; analyzing the characteristics of the optical cable drawing data, performing pre-processing based on prior information of the drawing, and obtaining the target area using dynamic cutting based on K-Means weak edge perception; using Fourier transform to separate high- and low-frequency information and decouple detection head features; aligning classification and positioning features based on a collection and distribution mechanism to alleviate the problem of inconsistent tasks between classification and positioning; and applying the trained target detection model to primitive detection in optical cable drawings to output the drawing parsing results. By introducing a method of dynamic pre-cutting and task decoupling and alignment, the present invention effectively locates the detection targets in the optical cable drawings. While fully considering the characteristics of the classification and positioning tasks, it balances the inconsistencies between the two, achieving high-precision intelligent parsing of the drawings, while greatly improving parsing efficiency and saving labor costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision, and in particular to an image preprocessing method, a target detection head design, and an optical cable drawing analysis solution. Background Art

[0002] In the field of computer vision, object detection has always been a research focus and a challenge. With the rapid development of deep learning technology, object detection algorithms based on convolutional neural networks have achieved significant progress in accuracy and efficiency. However, many challenges remain in practical industrial applications, especially for specific tasks in complex scenarios. Optical cable drawing parsing, a typical application scenario in industrial inspection, focuses on automatically extracting key information from optical cable design drawings, such as text information and device locations. By combining text recognition technology, this process automates the extraction of drawing content, reducing the manual burden.

[0003] While existing object detection algorithms, such as Faster R-CNN and the YOLO series, excel in general object detection tasks, they often struggle to meet practical requirements when processing scenarios with specific structure and semantics, such as optical cable drawings. Optical cable drawings typically contain a large amount of lines, symbols, and text, with complex spatial relationships and semantic associations between these elements. However, much of this information does not need to be parsed into a standard data format, and the richness of these elements can interfere with the final parsing results. Furthermore, the high resolution, large scale, and densely packed targets of optical cable drawings place higher demands on the algorithm's detection performance and memory usage.

[0004] In terms of image preprocessing, traditional methods primarily focus on operations such as image enhancement, denoising, and normalization to improve the accuracy of subsequent target detection. In the task of parsing optical cable drawings, the design and characteristics of the drawings must be comprehensively considered. During the preprocessing phase, the target area must be clearly defined to remove redundant interference information.

[0005] In the optical cable drawing parsing task, we have high requirements for object detection accuracy, as detection quality directly determines the effectiveness of subsequent text recognition and parsing matching. The design of the object detection head is a core component of the object detection algorithm, and its performance directly affects the accuracy and efficiency of the detection results. Existing object detection heads typically use a decoupled head to predict objects of varying sizes and shapes. However, in mainstream detection models such as the YOLO series, detection lacks a more explicit task decoupling strategy, and the differences between classification and localization tasks are not adequately addressed. Furthermore, during post-processing of the model output, the prediction confidence only considers the classification score, without taking into account localization quality. This can lead to some detection boxes with high localization quality being discarded during the NMS process. A task-aligned detection head aligns the classification and localization information, alleviating the conflict between classification and localization, facilitating the acquisition of high-quality detection boxes and improving drawing detection accuracy. Therefore, an efficient object detection head alignment structure is precisely what is needed for this task. Summary of the Invention

[0006] The present invention provides a method for parsing optical cable drawings based on dynamic pre-cutting and task decoupling and alignment, aiming to efficiently obtain the target area for detection and identification in the optical cable drawings and eliminate interference content. At the same time, a new decoupling-alignment detection head is proposed to improve the detection and parsing accuracy.

[0007] To achieve the above object, the technical solution adopted by the present invention is as follows:

[0008] A method for parsing optical cable drawings based on dynamic pre-cutting and task decoupling alignment includes the following steps:

[0009] Step 1: Obtain the original substation drawing data. Drawing data is divided into two categories: optical cable drawings and terminal strip drawing slices. Terminal strip drawing slices are introduced to supplement the data and improve the generalization ability of the training model in text detection.

[0010] Step 2: Analyze the characteristics of the optical cable drawing data and perform preprocessing based on the prior information of the drawing, including prior cropping of interference information, and use dynamic cropping based on K-Means weak edge perception to obtain the target area for cropping.

[0011] Step 2.1, priori cropping of interference information. The real effective information area in the optical cable drawing is a rectangular table, called the target area; the entire outline formed by the reference marks around the drawing is called the reference mark area; the rest of the area is redundant. In addition to the rectangle formed by the reference mark area, the target area has the largest outer contour area on the drawing. The reference mark area has a complex structure and the contour detection effect is difficult to predict. In order to eliminate the interference caused by the complex structure, the reference mark area is dynamically cropped according to the horizontal auxiliary lines drawn from the midpoints of the left and right edges of the drawing. Assume that the original image is , size is , search step , pixel threshold , the upper limit of the auxiliary line length is 500. The horizontal position of the left crop is determined by the following formula (1):

[0012] (1);

[0013] in is the horizontal coordinate of the left crop, is the number of search steps, Indicates that the image is at height and horizontal position The pixel value at . From all possible Find the smallest satisfying condition in the set The horizontal position of the right crop is determined by the following formula (2):

[0014] (2); among them is the horizontal coordinate of the right crop, From all possible Find the largest satisfying condition in the set . Crop the drawing and keep the horizontal coordinates as arrive part, get .

[0015] In step 2.2, under the condition of many weak edges, a dynamic cropping method based on K-Means weak edge perception is designed. By analyzing the gradient amplitude, the Canny edge detection threshold is dynamically adjusted, and the target area is selected and cropped according to the edge area. To prevent abnormal breakage of the target area contour, a large Gaussian kernel is used to smooth the image before contour detection. The calculation of the Gaussian kernel is shown in formulas (3), (4), and (5):

[0016] (3);

[0017] (4);

[0018] (5);

[0019] where k=11, is the standardized Gaussian convolution kernel. Gaussian smoothing is shown in formula (6):

[0020] (6);

[0021] Use Canny detection to crop the target area. In order to improve the computational efficiency and dynamically set the dual thresholds of Canny detection, the following method is adopted: first sample the image pixels, then consider the weak edge characteristics, use the Mini Batch K-Means algorithm to cluster the sampled gradients, and finally dynamically set the high and low thresholds of Canny detection based on the clustering results. Assume that the total number of pixels in the image is , the number of sampled pixels is , calculate the pixel gradient amplitude , and sampling Data obtained The two Sobel operators used to calculate the gradient are shown in formulas (7) and (8):

[0022] (7);

[0023] (8);

[0024] After convolving the smoothed image with the operator, we can further obtain the gradient and direction , as shown in formulas (9) and (10):

[0025] (9);

[0026] (10);

[0027] in and is an image respectively and 、 After convolution, we get the x-direction gradient and y-direction gradient amplitude. When using the Mini Batch K-Means algorithm for clustering, the loss function that needs to be optimized is shown in formula (11):

[0028] (11);

[0029] in represents the number of clusters, It is The center of the cluster, represents the Euclidean distance. Randomly select a batch , batch=500, assign each gradient magnitude to the nearest cluster center, as shown in formula (12):

[0030] (12);

[0031] Then update the cluster center as shown in formula (13):

[0032] (13);

[0033] in is assigned to A cluster of pixel gradients. Repeat the above steps until the maximum number of iterations is reached or the convergence condition is met, as shown in formula (14):

[0034] (14);

[0035] in is the maximum number of iterations, is the minimum cluster center change, and They are The cluster centers of the first iteration and the The cluster center of the iteration. Considering that the large Gaussian kernel convolution will greatly blur the drawing content and increase the number of weak edges, sufficient attention should be paid to it. Therefore, k=3 is set to divide the non-edge gradient center , weak edge gradient center and strong edge gradient center . Set the low gradient threshold low_threshold of Canny detection to Corresponding to the right boundary of the cluster, the high gradient threshold high_threshold is The corresponding cluster is the right edge. According to the gradient amplitude and direction obtained by formula (9) and (10), the gradient amplitude is suppressed to a non-maximum value. Then, based on the double gradient threshold, the gradient amplitude information around the weak edge is judged and classified as non-edge or edge. After completing all the above processes, the contour binary image is obtained.

[0036] Step 2.3, cut the target area. Use the cv2.findContours function in the Python library to process the binary image. For all contours, only the contour endpoints are retained and the outer contour is detected. Next, the area of each contour is calculated. The target area is the area with the largest contour area. The calculation of is shown in formula (15):

[0037] (15);

[0038] in are the coordinates of consecutive points on the contour, is the number of vertices on the contour.

[0039] Step 3: Using the YOLOv11 model as the baseline, modify the target detection head and introduce a hybrid frequency domain decoupling structure.

[0040] Step 3.1: Use Fourier transform to decouple the input features of the detection head. Fourier transform is used to separate high-frequency and low-frequency information: high-frequency information is used to enhance classification capabilities and capture the detailed features of the target; low-frequency information is used to improve positioning accuracy and capture the overall structure of the target. Definition is the training batch, is the number of channels, for the input features of the detection head Perform a two-dimensional discrete Fourier transform. The two-dimensional discrete Fourier transform is shown in formula (16):

[0041] (16);

[0042] in are the spatial coordinates, is the frequency domain coordinate, Is the input feature map in batch ,aisle ,Location The eigenvalue at It is a batch in the frequency domain after Fourier transform ,aisle ,frequency The complex value at . The frequency domain information is processed using the frequency shift function torch.fft.fftshift in the python library. Then create the mask , as shown in formula (17):

[0043] (17);

[0044] in , , and Controls the size of the low frequency area. Use After processing the frequency domain information, the frequency is shifted again to restore the frequency domain order, and the high and low frequency features of the spatial domain are restored using the inverse Fourier transform, as shown in formulas (18), (19), and (20):

[0045] (18);

[0046] (19);

[0047] (20);

[0048] In the formula is a low-frequency feature, is a high-frequency feature, is python's torch.fft.fftshift method, is the inverse Fourier transform.

[0049] Step 3.2: Fusion of decoupled features and original features. The method of fusing decoupled features and original features is shown in formulas (21) and (22):

[0050] (twenty one);

[0051] (twenty two);

[0052] In the formula is the positioning branch feature after fusion, is the classification branch feature after fusion, and It is a learnable parameter that learns the mixing ratio of frequency domain features and original features from the model.

[0053] Step 4 proposes a task alignment structure based on a collection and distribution mechanism. This paper designs a task alignment structure to ensure that the classification and localization tasks have unified objectives, rather than being relatively isolated. First, the number of channels for the classification and localization tasks is restored. Then, by collecting and distributing task features, the feature information from different tasks is integrated, and finally, this information is reinjected into the two task branches.

[0054] Step 4.1, restore the task channel. The classification and positioning features have different channel numbers. Use 1*1 convolution kernel to change the feature channel and get and . The number of channels is , is the number of channels of the detection head input feature map, is the discretization parameter of positioning output; The number of channels is , Is the detection category.

[0055] Step 4.2: Collect and distribute task features. First, preliminarily fuse the features of the two tasks to obtain , as shown in formula (23):

[0056] (twenty three);

[0057] in It is a 1*1 convolution. The feature maps are concatenated by channel. Next, further feature extraction is performed, as shown in formula (24):

[0058] (twenty four);

[0059] in is the new feature extraction information, It is a 3*3 depth separable convolution with an input channel of , the number of output channels is D, and its specific implementation is as shown in formula (25):

[0060] (25);

[0061] in is the output feature map of the depthwise separable convolution at position and channel The value at For the point-wise convolution weights (and an input channel , equivalent to the 1*1 convolution kernel of the output channel D), is the weight of the depthwise convolution, . Then proceed Inter-channel information interaction , split it into positioning distribution features and classification distribution characteristics , as shown in formulas (26)(27)(28):

[0062] (26);

[0063] (27);

[0064] (28);

[0065] Step 4.3, re-inject the information into the two task branches to obtain and The injection process is shown in formula (29) (30):

[0066] (29);

[0067] (30);

[0068] in is the Sigmoid function.

[0069] This completes the construction of the new detection head.

[0070] Step 5: For the text target in the target detection result, use text recognition technology to parse the text string content.

[0071] Step 6: Combine the graphic element location information and text location information in target detection, as well as the text recognition content, to perform semantic analysis of the drawing based on power expertise, and reject any possible abnormal information.

[0072] Step 6.1: Semantic parsing of drawings in the context of power expertise. Although we have identified the target area, there is still interfering text within the area. In target detection, the detection elements include text, device locators, and cable numbers. The text contains all the character information to be parsed, and the device locators and cable numbers assist in obtaining the spatial position of the parsed text. The semantic parsing strategy is to determine all text search intervals through the device locator and cable number elements. Then, based on the correspondence between the starting device and the end device in the device locator, match the text content within the starting search interval and the end search interval. Finally, organize the numbering information within the starting device name, end device name, and cable number and output it to Excel.

[0073] Step 6.2: Reject abnormal information. Design drawings naturally have differences and anomalies, and analysis results cannot be guaranteed to be foolproof. This invention incorporates a rejection function that provides rejection warnings for potential text overlap and missing information.

[0074] In summary, the present invention achieves significant optimization of computational efficiency and detection accuracy in the optical cable drawing parsing task through the collaborative design of dynamic pre-cutting and task decoupling-alignment detection head. The pre-cutting mechanism adopts a dynamic strategy to automatically filter out irrelevant background content in the image preprocessing stage, and automatically adjusts the contour detection parameters according to the image feature information to cut out the key target area. This technology solves the problem of manual parameter adjustment in traditional contour detection methods, optimizes memory usage during training, and provides higher quality input data for subsequent processes. The decoupling-alignment detection head proposed in the present invention adopts a dual-branch structure and uses the frequency domain decomposition method to independently optimize the classification and positioning tasks, thereby enhancing the feature learning ability of each task and avoiding feature interference. At the same time, the task alignment strategy based on the collection and distribution mechanism effectively alleviates the contradiction between classification and positioning, unifies the prediction targets of the tasks, and improves the final detection accuracy. Finally, the present invention combines the background of electric power professional knowledge, automatically matches text content according to the specified parsing strategy and adds a rejection function, which has high reliability and versatility. BRIEF DESCRIPTION OF THE DRAWINGS

[0075] Figure 1 It is a flow chart of the optical cable drawing identification and analysis method of the present invention.

[0076] Figure 2 It is a dynamic pre-cutting flow chart of the present invention.

[0077] Figure 3 It is a model structure diagram of the decoupling-alignment detection head of the present invention.

[0078] Figure 4 This is the target area diagram of the substation optical cable drawing provided by the present invention.

[0079] Figure 5 The present invention is Figure 4 Schematic diagram of the analytical results of the target area of the drawing shown. DETAILED DESCRIPTION

[0080] The following describes possible embodiments of the present invention in conjunction with the accompanying drawings.

[0081] like Figure 1 As shown, the optical cable drawing parsing method based on dynamic pre-cutting and task decoupling alignment of the present invention includes the following steps:

[0082] Step 1: Obtain substation drawing data, including optical cable drawings and terminal block drawing slices;

[0083] Step 2: Analyze the characteristics of the optical cable drawing data, perform preprocessing based on the prior information of the drawing, perform prior cropping on the interference information, and use dynamic cropping based on K-Means weak edge perception to obtain the target area;

[0084] Step 3: When using the detector to locate the target area information, a hybrid frequency domain decoupling structure is introduced in the detector head to fully consider the feature requirements of different tasks and enhance their respective task branches;

[0085] Step 4: For different task branches, a task alignment structure based on the collection and distribution mechanism is designed to ensure the unity of the goals of classification and localization tasks;

[0086] Step 5: Apply the improved detector to detect the graphic elements of the optical cable drawing and recognize the text content;

[0087] Step 6: Perform semantic analysis of the drawing based on the background of electric power professional knowledge on the text recognition results, reject possible abnormal information, and output the drawing analysis results.

[0088] The specific implementation steps are as follows:

[0089] S1, obtain the substation drawing dataset. On the one hand, collect the optical cable drawing data from all substation drawings. After preprocessing, these will be used as detection and parsing targets. On the other hand, considering that the vast majority of the text content in the target area of the optical cable drawings is single and repetitive and does not need to be parsed; while the target text content that needs to be parsed is relatively complex in form but small in quantity, consider using text data from other types of drawings to supplement the dataset to improve the generalization ability of text detection. The specific supplementation method is to select terminal block drawings with a similar format to the optical cable drawings, and use a manual screening method to cut out drawing slices that meet the text characteristics in the target area of the optical cable drawings. The slice size is fixed at 1760*1760.

[0090] S2, such as Figure 2 As shown, the optical cable drawings are preprocessed based on prior knowledge.

[0091] Specifically, it is divided into the following steps:

[0092] S2.1, perform a priori cropping of interference information. Analyze all optical cable drawing data, where the real effective information area is a rectangular table, called the target area; the entire outline formed by the reference marks around the drawing is called the reference mark area; the remaining areas are redundant areas. In addition to the rectangle formed by the reference mark area, the target area has the largest outer contour area on the drawing. The reference mark area has a complex structure and the contour detection effect is difficult to predict, so the reference mark area on the left and right sides of the drawing is cropped so that the target area must have the largest outer contour area on the drawing after cropping. The cropping method dynamically searches for the cropping edge based on the horizontal auxiliary lines drawn from the midpoints of the left and right edges of the drawing. We set the original image to be , size is , search step , pixel value threshold , the upper limit of the auxiliary line length is 500. The horizontal position of the left crop is determined by the following formula (1):

[0093] (1);

[0094] in is the horizontal coordinate of the left crop, is the number of search steps, Indicates that the image is at height , horizontal position The pixel value at . From all possible Find the smallest satisfying condition in the set The horizontal position of the right crop is determined by the following formula (2):

[0095] (2); among them is the horizontal coordinate of the right crop, From all possible Find the largest satisfying condition in the set Finally, cut the drawing to keep only the image The horizontal coordinate is arrive part, get .

[0096] S2.2, a dynamic cropping method based on K-Means weak edge perception is designed. By analyzing the gradient amplitude, the Canny edge detection threshold is dynamically adjusted, and the target area is selected and cropped according to the edge area. A large Gaussian kernel is used to smooth the image to prevent abnormal breakage of the target area contour. The calculation of the Gaussian kernel is shown in formulas (3), (4), and (5):

[0097] (3);

[0098] (4);

[0099] (5); where k=11, is the standardized Gaussian convolution kernel. Gaussian smoothing is shown in formula (6):

[0100] (6);

[0101] Use Canny contour detection to crop the target area. In order to improve the computational efficiency and dynamically set the dual threshold of Canny detection, the following method is adopted: sample the image gradient amplitude, consider the weak edge characteristics, use Mini Batch K-Means algorithm to cluster the gradient amplitude, and finally dynamically set the high and low thresholds of Canny detection based on the clustering results. Assume that the total number of pixels in the image is , the number of sampled pixels is , calculate the pixel gradient amplitude , and sampling Data obtained The two Sobel operators used to calculate the gradient are shown in formulas (7) and (8):

[0102] (7);

[0103] (8);

[0104] After convolution operation of the smoothed image and the operator, the gradient amplitude is further obtained. and direction , as shown in formulas (9) and (10):

[0105] (9);

[0106] (10);

[0107] in and is an image respectively and 、 After convolution, we get the x-direction gradient and y-direction gradient amplitude. When using the Mini Batch K-Means algorithm for clustering, the loss function that needs to be optimized is shown in formula (11):

[0108] (11);

[0109] in represents the number of clusters, It is The center of the cluster, represents the Euclidean distance. Randomly select a batch , batch=500, assign each gradient magnitude to the nearest cluster center, as shown in formula (12):

[0110] (12);

[0111] Then update the cluster center as shown in formula (13):

[0112] (13);

[0113] in is assigned to A cluster of pixel gradients. Repeat the above steps until the maximum number of iterations is reached or the convergence condition is met, as shown in formula (14):

[0114] (14);

[0115] in is the maximum number of iterations, is the minimum cluster center change, and They are The cluster centers of the first iteration and the The cluster center of the iteration. Considering that the large Gaussian kernel convolution will greatly blur the drawing content and increase the number of weak edges, sufficient attention should be paid to it. Therefore, k=3 is set to divide the non-edge gradient center , weak edge gradient center and strong edge gradient center . Set the low gradient threshold low_threshold of Canny detection to Corresponding to the right boundary of the cluster, the high gradient threshold high_threshold is The right boundary of the corresponding cluster. According to the gradient amplitude and direction obtained by formula (9) and (10), the gradient amplitude is non-maximum suppressed to preliminarily obtain the contour information. Then, according to the dual gradient threshold, the pixels below the low_threshold are set as non-edge pixels, and the pixels above the high_threshold are set as edge pixels. The gradient amplitude of the surrounding area of the pixels between the low_threshold and the high_threshold is determined. If there is at least one strong edge with a gradient amplitude higher than the high_threshold around it, the pixel is retained as an edge pixel, otherwise it is recorded as a non-edge pixel. After completing all the above processes, the contour binary image is obtained.

[0116] S2.3. Cut the target area based on the contour detection results. For the contour binary image, use the cv2.findContours function in the Python library to process it. For all contours, only the endpoints are retained and only the outer contours are detected. Calculate the area of each contour and take the contour with the largest area as the target area contour based on the prior. Calculate the area contour Using the Shoelace theorem, as shown in formula (15):

[0117] (15);

[0118] in are the coordinates of consecutive points on the contour, is the number of vertices on the contour.

[0119] S3, modify the YOLOv11 target detection head, introduce a hybrid frequency domain decoupling structure, introduce the feature requirements of different tasks, and enhance their respective task branches. The model structure diagram is as follows Figure 3 shown.

[0120] S3.1, use Fourier transform to decouple the detection head input features. The YOLOv11 detection head decouples the shared features of the positioning and classification tasks, but does not fully consider the differences between the classification and positioning tasks. The classification task needs to capture the representative features of the target, such as texture, edges, and contours, and this information is usually concentrated in the high-frequency components. The positioning task depends on detecting the external contour and overall structure of the target, and generally this information is usually concentrated in the low-frequency components. The input features are decomposed into high-frequency and low-frequency components through Fourier transform, which can be used for classification and positioning tasks respectively: high-frequency information is used to enhance classification capabilities and capture the detailed features of the target; low-frequency information is used to improve positioning accuracy and capture the overall structure of the target. For the input features of the detection head ,in is the training batch, The last two dimensions of the two-dimensional discrete Fourier transform are performed on the channel number. The two-dimensional discrete Fourier transform is shown in formula (16):

[0121] (16);

[0122] in are the spatial coordinates, is the frequency domain coordinate, Is the input feature map in batch ,aisle ,Location The eigenvalue at It is a batch in the frequency domain after Fourier transform ,aisle ,frequency The complex value at the frequency domain is used using torch.fft.fftshift in the python library After frequency shift, we get Then create a mask to separate low-frequency and high-frequency information. The creation of is shown in formula (17):

[0123] (17);

[0124] in , , and Controls the size of the low frequency area. Use and Respectively After multiplying the frequency domain information of , the frequency is shifted again to restore the frequency domain order, and the high-frequency features and low-frequency features are obtained using the inverse Fourier transform, as shown in formulas (18), (19), and (20):

[0125] (18);

[0126] (19);

[0127] (20);

[0128] In the formula is a low-frequency feature, is a high-frequency feature, is python's torch.fft.fftshift method, is the inverse Fourier transform.

[0129] S3.2, fusion of decoupled features and original features. The method of fusing decoupled features and original features is shown in formulas (21) and (22):

[0130] (twenty one);

[0131] (twenty two);

[0132] In the formula is the positioning branch feature after fusion, is the classification branch feature after fusion, and It is a learnable parameter used to automatically adjust the mixing ratio of frequency domain features and original features.

[0133] S4 proposes a task alignment structure based on a collection and distribution mechanism. This alignment structure ensures information exchange between the classification and localization tasks, ensuring consistency between classification and localization information, avoiding mismatches between target location and category predictions, and thus improving detection accuracy. First, the number of channels in the localization and classification features is restored to preserve task differences. Then, by collecting and distributing task features, feature information from different tasks is integrated. Finally, this information is reinjected into the two task branches to complete task alignment.

[0134] S4.1, recovery task channel. The classification and positioning features have different channel numbers, and two 1*1 convolution kernels are used to restore the channel. and Perform convolution and change the feature channel to obtain and .in The number of channels is , is the number of channels of the detection head input feature map, is the discretization parameter of positioning output; The number of channels is , Is the detection category.

[0135] S4.2, collect and distribute task features. Referring to the neck structure of the GOLD-YOLO model, the collection and distribution mechanism is introduced into the alignment of classification and positioning tasks. First, the features of the two tasks are initially fused to obtain , as shown in formula (23):

[0136] (twenty three);

[0137] in It is a 1*1 convolution, and the output channel is fusion_size. The feature maps are concatenated by channel. Next, further feature extraction is performed, as shown in formula (24):

[0138] (twenty four);

[0139] in It is the result of further extracting information from the fusion features. It is a 3*3 depth separable convolution, with the number of input channels The number of output channels D is fusion_size, and its specific implementation is as shown in formula (25):

[0140] (25);

[0141] in is the output feature map of the depthwise separable convolution at position and channel The value at For the point-wise convolution weights (and an input channel , equivalent to the 1*1 convolution kernel of the output channel D), is the weight of the depthwise convolution, . Afterwards Inter-channel information interaction , split it into positioning distribution features and classification distribution characteristics , as shown in formulas (26)(27)(28):

[0142] (26);

[0143] (27);

[0144] (28);

[0145] in The number of channels is fusion_size, and The number of channels is respectively 、 The number of channels is the same.

[0146] S4.3, re-inject the information into the two task branches, and obtain and The injection process is shown in formula (29) (30):

[0147] (29);

[0148] (30);

[0149] in is the Sigmoid function.

[0150] This completes the feature extraction for both classification and localization tasks, while also effectively taking into account their alignment. Once the detection head is built, the object detection model can be trained based on the dataset.

[0151] S5, for the text target in the target detection task, uses CRNN text recognition technology to perform end-to-end string content parsing on the detected text area.

[0152] S6, based on the primitive position information and text position information in the target detection, the drawing semantics is parsed and possible abnormal information is rejected.

[0153] S6.1, Semantic Parsing of Drawings in the Context of Power Professional Knowledge. Although the target area has been identified, interfering text still exists within it. In target detection, the detected primitives include text, device locators, and cable numbers. The text contains all the character information to be parsed, while the device locators and cable numbers assist in determining the spatial location of the parsed text. The following is a search and matching strategy for parsing:

[0154] (1) Determine the horizontal coordinate range of all search targets based on the coordinates of the device locator.

[0155] (2) Determine the longitudinal coordinate range of all search targets based on the coordinates of the optical cable number.

[0156] (3) Assuming there are 2 device locators (there are only two device locators on the cable drawing: the starting device locator and the end device locator) and N cable numbers, since the horizontal and vertical ranges have been determined, they can be divided There are N search intervals, including N starting search intervals and N ending search intervals. All parsing targets are located in these search intervals.

[0157] (4) Find all the texts in each search interval and identify which texts belong to the starting search interval and which texts belong to the ending search interval.

[0158] (5) According to the coordinates of each starting search interval, match the unique corresponding end search interval coordinates.

[0159] (6) Match the text content in the corresponding starting search interval and end search interval. Using the characteristics of the horizontal and vertical coordinates of these texts, the name of the end device corresponding to the starting device can be determined.

[0160] (7) Arrange the starting device name, end device name and number information in the optical cable number element, standardize the data format, and obtain the output Excel table.

[0161] S6.2, reject abnormal information. Drawing designs naturally have differences and design anomalies, and it is difficult to guarantee that the analysis results are completely correct. This invention has designed a rejection function to provide rejection warnings for possible problems such as text overlap and information omission. The rejection solution is as follows:

[0162] (1) If there are parentheses in the names of the starting device and the ending device, ensure that the parentheses are complete. If the parentheses are incomplete, there may be a problem of text and symbol adhesion, and a warning will be marked on the Excel analysis result.

[0163] (2) According to the statistics of drawing information, the terminal device name is generally composed of two strings. If the terminal device name in the analysis result is composed of only one string, it means that text may be missed or the drawing design method is different. The Excel analysis result will be marked with a warning.

[0164] (3) There may be cases where the optical cable number element is missed. The rejection strategy is to check whether all the optical cable number texts and optical cable number elements match one by one.

[0165] right Figure 4 The final analysis results of the target area of the optical cable drawing are as follows Figure 5 As shown. The present invention can automatically crop the target area and perform target detection on the text and graphics within the target area. Based on the correspondence between the starting device, end device, and optical cable number, it matches the text recognition content and outputs it in a standardized Excel spreadsheet. If any abnormal analysis results are found, the problematic content is filled with a special color, and rejected abnormal information requires manual review.

[0166] Those skilled in the art will clearly understand that the embodiments of the present invention can be implemented via computer programs and corresponding general-purpose hardware platforms. Based on this understanding, the key technical components of the embodiments of the present invention, or the components that contribute to the prior art, can be embodied in the form of a computer program, or software product. This computer program or software product can be stored in a storage medium and include multiple instructions to drive a device including a data processing unit (such as a personal computer, server, single-chip microcomputer, embedded microcontroller (MCU), or network device) to execute the methods described in different embodiments of the present invention or certain portions of these embodiments.

[0167] The present invention provides a method for parsing optical cable drawings based on dynamic pre-cutting and task-decoupled alignment. There are numerous methods and approaches to implementing this technical solution; the above is merely one specific embodiment of the present invention. It is worth noting that, for those skilled in the art, various improvements and optimizations are possible without departing from the principles of the present invention, and these improvements and optimizations should also be considered within the scope of protection of the present invention. Any components not explicitly described in this embodiment may be implemented using existing technologies.

Claims

1. A method for parsing optical cable drawings based on dynamic pre-cutting and task decoupling alignment, characterized in that: The following steps are involved: Step 1: Obtain substation drawing data, including optical cable drawings and terminal block drawing slices; Step 2: Analyze the characteristics of the optical cable drawing data, perform preprocessing based on the prior information of the drawing, perform prior cutting of the interference information, and use dynamic cutting based on K-Means weak edge perception to obtain the target area; Step 3: When using the detector to locate the target area information, a hybrid frequency domain decoupling structure is introduced in the detector head to fully consider the feature requirements of different tasks and enhance their respective task branches; Step 4: For different task branches, a task alignment structure based on the collection and distribution mechanism is designed to ensure the unity of the goals of classification and localization tasks; Step 5: Apply the improved detector to detect the graphic elements of the optical cable drawing and recognize the text content; Step 6: Perform semantic analysis of the drawing based on the background of power professional knowledge on the text recognition results, reject abnormal information, and output the drawing analysis results; Step 2 includes the following steps: Step 2.1, priori cutting of interference information; The effective information area in the optical cable drawing is a rectangular table, which is called the target area; the entire outline formed by the reference marks around the drawing is called the reference mark area; the rest of the area is the redundant area; The target area has the largest outer contour area on the drawing, except for the rectangle formed by the reference mark area; In order to eliminate the interference caused by complex structures, the reference mark area is dynamically cropped according to the horizontal auxiliary lines drawn from the midpoints of the left and right edges of the drawing; the original image is set to , size is , search step , pixel threshold , the upper limit of the auxiliary line length is 500; the horizontal position of the left crop is determined by the following formula (1): (1); in is the horizontal coordinate of the left crop, is the number of search steps, Indicates that the image is at height and horizontal position The pixel value at ; Indicates from all Find the smallest satisfying condition in the set ; The horizontal position of the right crop is determined by the following formula (2): (2); in is the horizontal coordinate of the right crop, Indicates from all Find the largest satisfying condition in the set ;Cut the drawing and keep the horizontal coordinates arrive part, get ; Step 2.2: Under the condition of increasing weak edges, a dynamic cropping method based on K-Means weak edge perception is designed. By analyzing the gradient amplitude, the Canny edge detection threshold is dynamically adjusted, and the target area is selected and cropped according to the edge area. Step 2.3, cut the target area; use the cv2.findContours function in the Python library to process the binary image. For all contours, only the contour endpoints are retained and the outer contour is detected; then calculate the area of each contour. The target area is the area with the largest contour area. The calculation of is shown in formula (15): (15); in are the coordinates of consecutive points on the contour, is the number of vertices on the contour.

2. The optical cable drawing parsing method based on dynamic pre-cutting and task decoupling alignment according to claim 1 is characterized in that: Step 2.2 specifically includes: The image is smoothed using a large Gaussian kernel before contour detection; The calculation of Gaussian kernel is shown in formula (3) (4) (5): (3); (4); (5); where k=11, is the standardized Gaussian convolution kernel; Gaussian smoothing is shown in formula (6): (6); Next, the image pixels are sampled, and then the weak edge characteristics are considered. The sampled gradients are clustered using the Mini Batch K-Means algorithm. Finally, the high and low thresholds of the Canny edge detection are dynamically set according to the clustering results. Assuming that the total number of image pixels is , the number of sampled pixels is , calculate the pixel gradient amplitude , and sampling Data obtained , the two Sobel operators used to calculate the gradient are shown in formulas (7) and (8): (7); (8); After convolving the smoothed image with the operator, the amplitude is further obtained. and direction , as shown in formulas (9) and (10): (9); (10); in and are images I and 、 After convolution, the obtained x-direction gradient and y-direction gradient amplitude; When using the Mini Batch K-Means algorithm for clustering, the loss function that needs to be optimized is shown in formula (11): (11); in represents the number of clusters, It is The center of the cluster, represents the Euclidean distance; Randomly select a batch , assign each gradient magnitude to the nearest cluster center, as shown in formula (12): (12); Then update the cluster center as shown in formula (13): (13); in is assigned to A clustered pixel gradient set; continuously select Repeat the above steps until the maximum number of iterations is reached or the convergence condition is met, as shown in formula (14): (14); in is the maximum number of iterations, is the minimum cluster center change, and They are The cluster centers of the first iteration and the The cluster centers of the iteration; Set the number of clusters k=3 to divide the non-edge gradient centers , weak edge gradient center and strong edge gradient center ; Set the low gradient threshold low_threshold of Canny detection to Corresponding to the right boundary of the cluster, the high gradient threshold high_threshold is The right boundary of the corresponding cluster; according to the gradient amplitude and direction obtained by formula (9) (10), the gradient amplitude is non-maximum suppressed to preliminarily obtain the contour information, and then the gradient amplitude information around the weak edge is judged according to the double gradient threshold, and it is divided into non-edge or edge.

3. The optical cable drawing parsing method based on dynamic pre-cutting and task decoupling alignment according to claim 2 is characterized in that: Step 3 includes the following steps: Step 3.1: Use Fourier transform to decouple the input features of the detection head. Fourier transform is used to separate high-frequency and low-frequency information: high-frequency information is used to enhance classification capabilities and capture the detailed features of the target; low-frequency information is used to improve positioning accuracy and capture the overall structure of the target. definition is the training batch, is the number of channels, for the input features of the detection head Perform a two-dimensional discrete Fourier transform, which is shown in formula (16): (16); in are the spatial coordinates, is the frequency domain coordinate, Is the input feature map in batch ,aisle ,Location The eigenvalue at It is a batch in the frequency domain after Fourier transform ,aisle ,frequency The complex value at the location is obtained by processing the frequency domain information using the frequency shift function torch.fft.fftshift in the python library. ; Then create the mask , as shown in formula (17): (17); in , , and Controls the size of the low-frequency area; use After processing the frequency domain information, the frequency is shifted again to restore the frequency domain order, and the inverse Fourier transform is used to restore the high and low frequency features of the spatial domain, as shown in formulas (18), (19), and (20): (18); (19); (20); In the formula is a low-frequency feature, is a high-frequency feature, is python's torch.fft.fftshift method, is the inverse Fourier transform; Step 3.2, fuse the decoupled features and the original features; through learnable parameters and , automatically learn the feature ratio relationship, as shown in formula (21) (22): (21); (22); In the formula is the positioning branch feature after fusion, It is the classification branch feature after fusion.

4. The optical cable drawing parsing method based on dynamic pre-cutting and task decoupling alignment according to claim 3 is characterized in that: Step 4 includes the following steps: Step 4.1, restore the task channel; the classification and positioning features have different numbers of channels, and two 1*1 convolution kernels are used to restore the task channel. and Perform convolution and change the feature channel to obtain and ; Step 4.2: Collect and distribute task features; first, preliminarily fuse the features of the two tasks to obtain , as shown in formula (23): (23); in It is a 1*1 convolution. Concatenate feature maps by channel; Next, further feature extraction is performed, as shown in formula (24): (24); in is the new feature extraction information, It is a 3*3 depth separable convolution with an input channel of , the number of output channels is D, and its specific implementation is as shown in formula (25): (25); in is the output feature map of the depthwise separable convolution at position and channel The value at is the point-by-point convolution weight, is the weight of the depthwise convolution, ; Afterwards Inter-channel information interaction , split it into positioning distribution features and classification distribution characteristics , as shown in formulas (26)(27)(28): (26); (27); (28); Step 4.3, re-inject the information into the two task branches to obtain and The injection process is shown in formulas (29) and (30): (29); (30); in is the Sigmoid function.

5. The optical cable drawing parsing method based on dynamic pre-cutting and task decoupling alignment according to claim 4 is characterized in that: Step 5 includes the following steps: Step 5.1: Drawing semantic parsing. Based on electrical expertise, the inspection elements defined include text, device locators, and cable numbers. Text recognition obtains all parsed text content, while the device locators and cable numbers assist in obtaining the spatial location of the parsed text. The search strategy is as follows: determine all text search intervals based on the device locator and the optical cable number element; then, match the text content within the corresponding start and end search intervals based on the matching relationship between the start and end devices in the device locator; finally, organize the numbering information within the start and end device names and optical cable numbers and output it to Excel; Step 5.2: Reject abnormal information; issue a rejection warning for any abnormal problem.

6. The optical cable drawing parsing method based on dynamic pre-cutting and task decoupling alignment according to claim 5, characterized in that: Step 5.2 rejects abnormal information, including the following steps: (1) If there are parentheses in the names of the starting device and the end device, ensure that the parentheses are complete; if the parentheses are incomplete, there will be a problem of text and symbol adhesion, and the corresponding Excel analysis results will be marked with a warning; (2) According to the statistics of drawing information, the terminal device name is generally composed of two character strings; if the terminal device name in the parsing result is composed of only one character string, it means that the text is missed or the drawing design method is different, and the Excel parsing result is marked with a warning; (3) There are cases where optical cable number graphics are missed; the rejection strategy is to check whether all optical cable number texts and optical cable number graphics match one by one.

Citation Information

Patent Citations

  • Transformer substation optical cable diagram intelligent analysis method and device based on diffusion model, and storage medium

    CN118037710A

  • Image instance detection segmentation model construction method based on edge information enhancement

    CN118762042A