A method for realizing image graphing based on topological structure
Through the topology-based image mapping method, Unet semantic segmentation network and natural language processing technology are used to automatically extract structured information in network topology images, solving the problem of time-consuming and error-prone information extraction in the existing technology, and realizing Efficient and accurate mapping results.
Patent Information
- Application Number
- CN202111447552.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-11-30
AI Technical Summary
Existing technology is difficult to quickly and accurately extract structured map information from network topology images, making manual drawing time-consuming and error-prone.
The image mapping method based on topology is used to extract semantic information through the Unet semantic segmentation network. The expansion and erosion algorithms are combined to process noise points and connecting lines. Natural language processing is used to correct recognition errors. Finally, the results are output in JSON format.
It realizes the automatic extraction of structured information from network topology images, saves manpower and material resources, and improves the accuracy and comprehensiveness of the extraction results.
Smart Images

Figure CN114398892B
Abstract
Description
Technical Field
[0001] The present invention relates to natural language processing technology, and in particular to a method for realizing image graphing based on topological structure. Background Art
[0002] Network topology refers to a network structure diagram consisting of network node devices such as routers, computers, switches, printers and communication media. In short, it is to intuitively reflect each network node device and communication medium in the diagram. Network topology diagrams have various topological structures such as star, distributed, ring, cellular, bus, tree, mesh, etc. The function of the network topology diagram is to intuitively and clearly reflect the connection relationship between each network node and interface, and reflect the structural relationship between each entity in the network. At present, there are a large number of network topology diagrams, most of which exist in the form of images. How to quickly extract useful information from these images containing network topology diagrams is very necessary. The simplest way is to manually draw the map by comparing the topological structure in the image, but this method is not only time-consuming, but also prone to drawing errors. Summary of the invention
[0003] The purpose of the present invention is to propose a method for realizing image atlasing based on topological structure.
[0004] The technical solution to achieve the purpose of the present invention is: a method for realizing image atlasing based on topological structure, comprising the following steps:
[0005] Step 1: Training data preparation
[0006] Collect relevant images of network device icons, separate single network device icons, and generate training data and verification data;
[0007] Step 2: Semantic model training
[0008] Use the Unet semantic segmentation network to train the semantic segmentation model, and use the trained model to extract the semantic information of the input image;
[0009] Step 3: Dilation and corrosion processing
[0010] The semantic result obtained in step 2 is processed by using the expansion and erosion algorithms, the noise points in the image are removed by using the erosion algorithm, and the connecting lines in the image are thickened by using the expansion algorithm;
[0011] Step 4: Connected region calibration
[0012] Use the connected region calibration method to divide the processing results in step 3 into instances, obtain different instance objects, and obtain information such as the category, size, and position of each instance object;
[0013] Step 5: Natural Language Processing
[0014] Use natural language processing methods to supplement the results of instance objects and correct possible erroneous instances identified by the semantic segmentation model;
[0015] Step 6: Mapping
[0016] Draw a graph of the results obtained in step 5, modify any error messages, and output the results in JSON format.
[0017] Furthermore, in step 1, training data is prepared, and the specific method is as follows:
[0018] Step 1.1: Collect relevant images containing network device icons, where network devices mainly refer to switches, routers, servers, etc., and then process each image to ensure that a single image contains only one device icon;
[0019] Step 1.2: Make the background part of the processed independent device icons transparent, leaving only the main body of the device icon, and then classify them according to independent icons, and store icons of the same category in the same folder;
[0020] Step 1.3: Randomly extract different numbers of icons from independent icons of different categories, uniformly crop them to a size of 512*512, and construct the training dataset and validation dataset of the image semantic segmentation model.
[0021] Furthermore, in step 3, the expansion and corrosion processing is performed in the following specific methods:
[0022] Step 3.1: Copy the semantic segmentation result obtained in step 2 as the result image, select the corrosion kernel, align the corrosion kernel with the upper left corner of the result image, and check whether there is a 0 in the position of the result image corresponding to the position of 1 in the corrosion kernel. If there is a 0, set the position of the entire kernel in the result image to 0, otherwise no processing is performed. In this way, the dark area in the result image will become larger and the noise points will be filtered out;
[0023] Step 3.2: If there is a position of 255 at the position where the erosion kernel is 1, the position of the entire kernel in the eroded result image is set to 255, otherwise no processing is done. In this way, the bright area in the result image will become larger and the connecting lines in the image will become thicker.
[0024] Furthermore, in step 4, the connected region is calibrated, and the specific method is as follows:
[0025] Step 4.1: Take the image dilated in step 3 as input, scan the first row of the image pixel by pixel, group the consecutive pixels of the same category in the row into a cluster, and record the starting point start, end point end and the row number;
[0026] Step 4.2: Scan the remaining rows of the image line by line according to the above steps. If there is no overlap with all the clusters in the previous row, give it a new label; if there is only an overlap with one cluster in the previous row, assign it the label of the cluster in the previous row, and write the labels of the current cluster and the overlapping cluster in the previous row into an equivalent pair; if there is an overlap with more than two clusters in the previous row, assign the current cluster the minimum label of the connected clusters, and write the labels of the current cluster and the overlapping cluster in the previous row into an equivalent pair;
[0027] Step 4.3: Convert the equivalent pair into an equivalent sequence. Each sequence needs to be given the same label, starting from 1. Give each equivalent sequence a label. The sequences that were not in the equivalent pair will be labeled as independent equivalent sequences.
[0028] Step 4.4: Traverse the labels of the initially obtained groups, find equivalent sequences, and give them new labels obtained in the previous step;
[0029] Step 4.5: Fill the new label of each group into the labeled image to obtain the category, size, and location information of each instance object.
[0030] Furthermore, in step 5, natural language processing, the specific method is:
[0031] Step 5.1: Traverse the instance objects obtained in step 4;
[0032] Step 5.2: For the text category instance, use regular expressions to extract the IP and MAC addresses in the text and retain them;
[0033] Step 5.3: For non-text category instances with text descriptions, named entity recognition is used to determine the category of the description text. If it is consistent with the original category, the instance is retained. If it is inconsistent, it is added to the pending list and manually verified later.
[0034] A topology-based image graphing implementation system is provided, which completes topology-based image graphing based on the topology-based image graphing implementation method.
[0035] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the image mapping based on the topological structure is completed based on the method for implementing the image mapping based on the topological structure.
[0036] A computer-readable storage medium stores a computer program, which, when executed by a processor, completes topological structure-based image mapping based on the topological structure-based image mapping implementation method.
[0037] Compared with the prior art, the present invention has the significant advantage that it can automatically extract structured graph information from images containing network topology structures through the semantic segmentation model in image recognition, thereby saving manpower and material resources. In addition, the natural language processing method is added to make the extraction results more comprehensive and accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 It is a flowchart based on the topological structure of the image atlas;
[0039] Figure 2 It is a flowchart of semantic segmentation;
[0040] Figure 3 It is a flowchart of named entity recognition.
[0041] Figure 4 It is a nuclear schematic diagram.
[0042] Figure 5 It is a test graph containing topological structure.
[0043] Figure 6 It is the semantic segmentation effect diagram of the test image.
[0044] Figure 7 This is the graph visualization result. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0046] The present invention provides a method for realizing image mapping based on topological structure, and the process involved includes the following steps:
[0047] Step 1: Training data preparation
[0048] Collect relevant images of network device icons, separate individual network device icons, classify and store them, and then use tools to generate training data and verification data from the collected images.
[0049] Step 1.1: Collect relevant images containing network device icons, where network devices mainly refer to switches, routers, servers, etc., and then process each image to ensure that a single image contains only one device icon.
[0050] Step 1.2: Make the background of the processed independent device icons transparent, leaving only the main body of the device icon, and then classify them according to independent icons. Icons of the same category are stored in the same folder.
[0051] Step 1.3: Randomly extract different numbers of icons from independent icons of different categories, uniformly crop them to a size of 512*512, and construct the training dataset and validation dataset of the image semantic segmentation model.
[0052] Step 2: Semantic model training
[0053] The deep learning semantic segmentation algorithm is used for model training, and the trained model can be used to extract semantic information from the input image.
[0054] Step 2.1: Use the Unet semantic segmentation network, which is more popular among the existing semantic models, and use the training dataset and verification dataset prepared in step 1 as data input to train the semantic segmentation model.
[0055] Step 2.2: After the semantic segmentation model is trained, the test image is used as data input for semantic segmentation. The result of semantic segmentation is also an image with the same size as the input image, and the category to which each pixel in the image belongs has been obtained.
[0056] Step 3: Dilation and corrosion processing.
[0057] The input image is processed using the dilation and erosion algorithms, mainly using the erosion algorithm to remove noise points in the image, and using the dilation algorithm to thicken the connecting lines in the image, so as to facilitate the subsequent calibration of the results. The erosion and dilation are two basic operations in digital morphology, generally used for binary images (RGB images can also be used). Erosion is similar to "domain reduction", that is, making the dark area in the image larger, while dilation is similar to "domain expansion", that is, making the bright area in the image larger.
[0058] Step 3.1: Copy the image containing semantic information obtained in step 2 as the result image, and select Figure 4 The structure shown is used as the corrosion core (other structures can also be used). Align the corrosion core with the upper left corner of the result image, and check whether there is a 0 in the position of the result image corresponding to the position of 1 in the core. If there is a 0, set the position of the entire core in the result image to 0, otherwise no processing is done. In this way, the dark area in the result image will become larger and the noise points will be filtered out.
[0059] Step 3.2: The expansion process is similar to the corrosion operation, and the same Figure 4 The kernel shown in the figure is different from corrosion in that, at the position where the kernel is 1, as long as there is one position that is 255, the position of the entire kernel in the result image after corrosion will be set to 255, otherwise no processing will be done. In this way, the bright area in the result image will become larger and the connecting lines in the image will become thicker.
[0060] Step 4: Connected region calibration.
[0061] Since the instances contained in the image may belong to multiple different categories, the binary image is no longer used to calibrate the connected domain. Instead, the category to which each pixel of the image belongs is used to determine the connected domain, thereby obtaining the category, size, and location information of each instance object.
[0062] Step 4.1: Take the image dilated in step 3 as input, scan the first row of the image pixel by pixel, group the consecutive pixels of the same category in the row into a sequence (called a run), and record the starting point start, end point end and the row number.
[0063] Step 4.2: Scan the remaining rows of the image line by line according to the above steps. If the formed sequence has no overlapping area with all the clusters in the previous row (that is, the current cluster and the previous cluster of the same pixel category have no pixels in the same column), give it a new label; if it has overlapping area with only one cluster in the previous row, assign it the label of the cluster in the previous row; if it has overlapping area with more than two clusters in the previous row, assign the current cluster the smallest label of the connected clusters, and write the labels of these clusters in the previous row and the current cluster into an equivalent pair (indicating that these clusters belong to the same category).
[0064] Step 4.3: Convert the equivalent pairs into equivalent sequences. Each sequence needs to be given the same label because they are all in the same category. Starting from 1, give each equivalent sequence a label. Here, the equivalent sequences are re-labeled. The sequences that were not in the equivalent pairs before will be labeled as independent equivalent sequences, for example
[0065] The equivalent pairs are <1,2><1,6><3,7><9,3><8,1><8,10><11,5><11,8><11,12> <11,13><11,14><15,11>,
[0066] The equivalent sequence after conversion is:
[0067] Label 1:1-2-5-6-8-10-11-12-13-14-15
[0068] Number 2:3-7-9
[0069] Number 3:4
[0070] The number 4 that is not in the equivalent pair will participate in the labeling of the equivalent sequence, and the new label is 3.
[0071] Step 4.4: Traverse the labels of the initially obtained groups, find equivalent sequences, and give them new labels obtained in the previous step.
[0072] Step 4.5: Fill the new label of each group into the labeled image to obtain the category, size, position and other information of each instance object.
[0073] Step 5: Natural Language Processing.
[0074] In order to avoid classification errors in the semantic segmentation model and to make full use of the text instance information contained in the image, natural language processing is added after instance extraction to further improve the accuracy of the results.
[0075] Step 5.1: Traverse the instance objects obtained in step 4.
[0076] Step 5.2: For the text category instance, use regular expressions to extract the IP, MAC address and other information in the text (such as " / ^([0-9a-fA-F]{2})(([ / \s:][0-9a-fA-F]{2}){5})$ / " can be used to match the MAC address). If the regular expression is matched successfully, the text instance is retained.
[0077] Step 5.3: For non-text category instances with text descriptions, use named entity recognition to determine the category. If it is consistent with the original category, continue; if it is inconsistent, make a special mark.
[0078] Step 6: Mapping
[0079] The instance results are graphed, and instance objects with special identifiers are manually verified, and the results are finally output in JSON format.
[0080] Step 6.1: Use the graph drawing tool to visualize the instance object results obtained in step 5.
[0081] Step 6.2: Manually check the instance objects with special identification, and then save the results.
[0082] Step 6.3: Output the final result in JSON format.
[0083] The present invention also proposes a topology-based image graphing implementation system, which completes the topology-based image graphing based on the topology-based image graphing implementation method.
[0084] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the image mapping based on the topological structure is completed based on the method for implementing the image mapping based on the topological structure.
[0085] A computer-readable storage medium stores a computer program, which, when executed by a processor, completes topological structure-based image mapping based on the topological structure-based image mapping implementation method.
[0086] Example
[0087] In order to verify the effectiveness of the scheme of the present invention, the following examples are carried out.
[0088] Step 1: Collect relevant training data to train the semantic segmentation model.
[0089] Step 2: Input a test image with topological structure, such as Figure 5 The figure includes terminals, routers, printers, etc.
[0090] Step 3: Use the test image as the input of the semantic segmentation model (the training process of the semantic segmentation model is the same as the training process of other deep learning algorithm models, which will not be described in detail here). After being processed by the semantic segmentation model, the semantic information of the test image is obtained.
[0091] Step 4: After being processed by the semantic segmentation model, the semantic information in the image is obtained, but it still contains some noise and needs further processing. Figure 4 The core structure shown in FIG. 1 is used to corrode and dilate the result obtained in step 3, and then the connected domain is identified using the connected region calibration method. Finally, the instance information is obtained, such as Figure 6 shown.
[0092] Step 5: After step 7, the sample information contained in the image is obtained, such as Figure 7 The instance in the lower left corner will contain information such as "Category: Terminal, Description: 192.168.0.5". At this point, the result needs to be further processed to obtain a more accurate instance object. Figure 7Each instance contained in is processed as follows: For text instances, if the IP, MAC address, etc. match successfully, they are retained, otherwise they are deleted; for the description of the instance, named entity recognition is performed, and if the recognition result is inconsistent with the original category of the instance, a special mark is given.
[0093] Step 6: After obtaining the final instance results, use the relevant visualization plug-in to visualize the extracted graph results, such as Figure 7 After manually verifying the instance results with special identifiers, the results are output in JSON format (such as {"entity":[{"id":"1","name":"192.168.0.5","type":"IP"},{"id":"2","name":"192.168.0.1","type":"router"}]},"relation":[{"from":"2","to":"1"}]).
[0094] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0095] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for realizing image graphing based on topological structure, characterized in that: The steps include: Step 1: Training data preparation Collect relevant images of network device icons, separate single network device icons, and generate training data and verification data; Step 2: Semantic model training Use the Unet semantic segmentation network to train the semantic segmentation model, and use the trained model to extract the semantic information of the input image; Step 3: Dilation and Erosion Processing The image containing semantic information obtained in step 2 is processed using the dilation and erosion algorithms, the noise points in the image are removed using the erosion algorithm, and the connecting lines in the image are thickened using the dilation algorithm; Step 4: Connected region calibration Use the connected region calibration method to divide the processing results in step 3 into instances, obtain different instance objects, and obtain the category, size, and location information of each instance object; Step 5: Natural Language Processing Use natural language processing methods to supplement the results of instance objects and correct possible erroneous instances identified by the semantic segmentation model; Step 6: Mapping Draw a graph of the results obtained in step 5 and output the results in JSON format; In step 4, the connected area is calibrated, and the specific method is as follows: Step 4.1: Take the image dilated in step 3 as input, scan the first row of the image pixel by pixel, group the consecutive pixels of the same category in the row into a cluster, and record the starting point start, end point end and the row number; Step 4.2: Scan the remaining rows of the image line by line according to the above steps. If there is no overlap with all the clusters in the previous row, give it a new label; if there is only an overlap with one cluster in the previous row, assign it the label of the cluster in the previous row, and write the labels of the current cluster and the overlapping cluster in the previous row into an equivalent pair; if there is an overlap with more than two clusters in the previous row, assign the current cluster the minimum label of the connected clusters, and write the labels of the current cluster and the overlapping cluster in the previous row into an equivalent pair; Step 4.3: Convert the equivalent pair into an equivalent sequence. Each sequence needs to be given the same label, starting from 1. Give each equivalent sequence a label. The sequences that were not in the equivalent pair will be labeled as independent equivalent sequences. Step 4.4: Traverse the labels of the initially obtained groups, find equivalent sequences, and give them new labels obtained in the previous step; Step 4.5: Fill the new label of each group into the labeled image to obtain the category, size, and location information of each instance object.
2. The method for realizing image mapping based on topological structure according to claim 1, characterized in that: In step 1, training data is prepared. The specific method is as follows: Step 1.1: Collect relevant images containing network device icons, where network devices refer to switches, routers, and servers, and then process each image to ensure that only one device icon is contained in a single image; Step 1.2: Make the background part of the processed independent device icons transparent, leaving only the main body of the device icon, and then classify them according to independent icons, and store icons of the same category in the same folder; Step 1.3: Randomly extract different numbers of icons from independent icons of different categories, uniformly crop them to a size of 512*512, and construct the training dataset and validation dataset of the image semantic segmentation model.
3. The method for realizing image mapping based on topological structure according to claim 1, characterized in that: In step 3, the expansion and corrosion process is performed as follows: Step 3.1: Copy the semantic segmentation result obtained in step 2 as the result image, select the corrosion kernel, align the corrosion kernel with the upper left corner of the result image, and check whether there is a 0 in the position of the result image corresponding to the position of 1 in the corrosion kernel. If there is a 0, set the position of the entire kernel in the result image to 0, otherwise no processing is done. In this way, the dark area in the result image will become larger and the noise points will be filtered out; Step 3.2: If there is a position of 255 at the position where the erosion kernel is 1, the position of the entire kernel in the eroded result image is set to 255, otherwise no processing is done. In this way, the bright area in the result image will become larger and the connecting lines in the image will become thicker.
4. The method for realizing image mapping based on topological structure according to claim 1, characterized in that: In step 5, natural language processing, the specific method is: Step 5.1: Traverse the instance objects obtained in step 4; Step 5.2: For the text category instance, use regular expressions to extract the IP and MAC addresses in the text and retain them; Step 5.3: For non-text category instances with text descriptions, named entity recognition is used to determine the category of the description text. If it is consistent with the original category, the instance is retained. If it is inconsistent, it is added to the pending list and manually verified later.
5. A topological structure-based image graph realization system, characterized in that: Based on the method for realizing image mapping based on topological structure as described in any one of claims 1 to 4, image mapping based on topological structure is completed.
6. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it completes topological structure-based image mapping based on the topological structure-based image mapping implementation method according to any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the topology-based image mapping is completed based on the topology-based image mapping implementation method described in any one of claims 1-4.
