A method, apparatus, and electronic device for generating sample data
By randomly setting structural diagram style parameters to generate structure diagram images and labeled data, the problems of low sample data acquisition efficiency and high cost are solved, efficient and low-cost sample data generation is achieved, and the accuracy of model training is improved.
Patent Information
- Application Number
- CN202111277679.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2041-10-29
AI Technical Summary
In the prior art, the acquisition efficiency of sample data is low, the cost is high, and it is difficult to obtain diversified sample data, which affects the accuracy of model training.
By randomly setting the style parameters of the structure diagram, the corresponding structure diagram image and label data are generated, and combined into sample data for model training.
It improves the efficiency of sample data generation, reduces the generation cost, provides diversified sample data, and improves the accuracy of model training.
Smart Images

Figure CN114092617B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and particularly to a method, apparatus, and electronic device for generating sample data. Background Art
[0002] In daily applications, users have a need to edit images of structure diagrams such as mind maps and flowcharts obtained. Since the obtained structure diagrams are just ordinary images and cannot be edited, it is necessary to reconstruct an editable structure diagram image from the uneditable structure diagram image through a trained model, and then the user can perform editing and modification.
[0003] The training of the model requires a large amount of diverse sample data so that the accuracy of the trained model will be higher. Currently, the collection of sample data is usually done by scraping from web pages or manually drawing. However, for the former, the annotation data in the scraped structure diagram images cannot be known, and for the latter, the efficiency of manually drawing structure diagram images is low, and the generation cost of sample data is relatively high. Summary of the Invention
[0004] Embodiments of the present invention provide a method for generating sample data to improve the generation efficiency of sample data and reduce the generation cost of sample data.
[0005] Correspondingly, embodiments of the present invention also provide a sample data generation apparatus and an electronic device to ensure the implementation and application of the above method.
[0006] To solve the above problems, embodiments of the present invention disclose a method for generating sample data, which specifically includes:
[0007] Randomly set the style parameters of the structure diagram;
[0008] Generate a structure diagram image corresponding to the style parameters based on the style parameters;
[0009] Generate annotation data corresponding to the structure diagram image based on the structure diagram image;
[0010] Combine the structure diagram image and the annotation data into sample data for training a model to be trained.
[0011] Optionally, the style parameters at least include one of layout style, connection line type, connection line thickness, connection line color, text, font size, node type, node box shape, thickness of the node box, node color, and image background.
[0012] Optionally, the generating a structure diagram image corresponding to the style parameters based on the style parameters includes:
[0013] Generate a descriptive file of the structure diagram based on the style parameters;
[0014] Input the descriptive file into a visualization engine for rendering to obtain a structure diagram image.
[0015] Optionally, the annotation data includes a connection line mask image; generating the annotation data corresponding to the structure diagram image based on the structure diagram image includes:
[0016] Adjust the pixel values of the background in the structure diagram image to a first pixel value, the pixel values of the connection lines to a second pixel value, set the text to be empty, and set the nodes to be empty, to generate a connection line mask image; wherein, the first pixel value is not equal to the second pixel value, and the connection line mask image is used to indicate the area where the connection lines are located in the structure diagram image.
[0017] Optionally, the annotation data includes the position information of the nodes; generating the annotation data corresponding to the structure diagram image based on the structure diagram image includes:
[0018] Set the background of the structure diagram image to be empty, the connection lines to be empty, the text to be empty, and adjust the pixel values of the nodes to a third pixel value to generate a node image;
[0019] Analyze the node image through a connected component analysis algorithm to obtain the position information of the nodes in the structure diagram.
[0020] Optionally, it further includes:
[0021] Group the sample data based on the layout style to obtain sample data groups; wherein
[0022] The sample data groups include corresponding grouping identifiers;
[0023] Sample the sample data in the corresponding sample data group according to the grouping identifier to obtain target sample data;
[0024] Input the target sample data into a model to be trained for training.
[0025] An embodiment of the present invention also discloses a sample data generation device, including:
[0026] A parameter setting module, configured to randomly set the style parameters of the structure diagram;
[0027] An image generation module, configured to generate a structure diagram image corresponding to the style parameters based on the style parameters;
[0028] A data generation module, configured to generate annotation data corresponding to the structure diagram image based on the structure diagram image;
[0029] A data combination module, configured to combine the structure diagram image and the annotation data into sample data for training a model to be trained.
[0030] Optionally, the style parameters at least include one of typesetting style, connection line type, connection line thickness, connection line color, text, font size, node type, node box shape, thickness of the node box, node color, and image background.
[0031] Optionally, the image generation module includes:
[0032] A file generation sub-module, configured to generate a descriptive file of the structure diagram based on the style parameters;
[0033] An image generation sub-module, configured to render the descriptive file into a visualization engine to obtain a structure diagram image.
[0034] Optionally, the annotation data includes a connection line mask image; the data generation module includes:
[0035] A mask image generation sub-module, configured to adjust the pixel value of the background in the structure diagram image to a first pixel value, adjust the pixel value of the connection line to a second pixel value, set the text to be empty, and set the node to be empty, to generate a connection line mask image; wherein, the first pixel value is not equal to the second pixel value, and the connection line mask image is used to indicate the area where the connection line is located in the structure diagram image.
[0036] Optionally, the annotation data includes the position information of the node; the data generation module includes:
[0037] A node image generation sub-module, configured to set the background of the structure diagram image to be empty, set the connection line to be empty, set the text to be empty, and adjust the pixel value of the node to a third pixel value, to generate a node image;
[0038] An information acquisition sub-module, configured to analyze the node image through a connected component analysis algorithm to obtain the position information of the nodes in the structure diagram.
[0039] Optionally, it further includes:
[0040] A data grouping module, configured to group the sample data based on the typesetting style to obtain sample data groups; wherein, the sample data groups include corresponding grouping identifiers;
[0041] A data sampling module, configured to sample the sample data in the corresponding sample data group according to the grouping identifier to obtain target sample data;
[0042] A model training module for inputting the target sample data into a model to be trained for training.
[0043] An embodiment of the present invention also discloses a readable storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the sample data generation method as described in any one of the embodiments of the present invention.
[0044] An embodiment of the present invention also discloses an electronic device, including a memory and one or more programs. One or more programs are stored in the memory and are configured to be executed by one or more processors. The one or more programs include those for performing the sample data generation method as described in any one of the embodiments of the present invention.
[0045] The embodiments of the present invention have the following advantages:
[0046] In the embodiments of the present invention, the style parameters of the structure diagram are randomly set, the structure diagram image corresponding to the style parameters is generated based on the style parameters, the annotation data corresponding to the structure diagram image is generated based on the structure diagram image, and the structure diagram image and the annotation data are combined into sample data for training the model to be trained. By applying the embodiments of the present invention, various structure diagram images and corresponding annotation data can be generated as sample data according to the randomly set style parameters, improving the generation efficiency of the sample data, reducing the generation cost of the sample data, effectively solving the problem of difficult acquisition of sample data, and having a good auxiliary effect on the model training effect.
[0047] In addition, various structure diagram images and corresponding annotation data generated according to the randomly set style parameters can also be used for algorithm verification and testing, providing a data basis for the structure reduction of the structure diagram. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 is a flowchart of the steps of an embodiment of a sample data generation method of the present invention;
[0049] Figure 2 is a flowchart of the steps of another embodiment of a sample data generation method of the present invention;
[0050] Figure 3 is a schematic diagram of an embodiment of structure diagram image generation of the present invention;
[0051] Figure 4 is a schematic diagram of an embodiment of connection line mask image generation of the present invention;
[0052] Figure 5 is a schematic diagram of an embodiment of node image generation of the present invention;
[0053] Figure 6It is a structural block diagram of an embodiment of a sample data generation device of the present invention;
[0054] Figure 7 A structural block diagram of an electronic device for sample data generation shown according to an exemplary embodiment;
[0055] Figure 8 It is a schematic structural diagram of an electronic device for sample data generation shown according to another exemplary embodiment of the present invention. Detailed implementation manners
[0056] To make the above objects, features, and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific implementation manners.
[0057] Refer to Figure 1 , which shows a step flowchart of an embodiment of a sample data generation method of the present invention, and specifically may include the following steps:
[0058] Step 102: Randomly set the style parameters of the structure diagram.
[0059] Among them, the style parameter theme may refer to all parameters related to the structure diagram, and may include various types, such as the layout style of the structure diagram (circular diagram, bubble diagram, tree diagram, flow chart, bridge diagram, etc.), the style parameters of the connection lines, the style parameters of the nodes, the style parameters of the text, the style parameters of the background, etc. The embodiments of the present invention do not limit this; the connection lines can also be called guiding lines, connection lines, or association lines, which are used to connect the nodes in the structure diagram or establish a certain connection between the nodes; the nodes are mainly used to emphasize the text in the nodes (central theme, branch theme, keywords, and summarized content, etc.). Different contents in the nodes result in different types of nodes, so that there is a hierarchical relationship between the nodes (for example, the relationship between the parent node and the child node, or the relationship between the first-level node and the second-level node, etc.). The shape of the node box can be a square box, a circular box, a semi-box, a generalization line, etc.
[0060] Specifically, before generating the structure diagram image, it is necessary to randomly set the style parameters of the structure diagram.
[0061] Step 104: Generate a structure diagram image corresponding to the style parameters based on the style parameters.
[0062] Specifically, after randomly setting the style parameters of the structure diagram, generate a corresponding structure diagram image according to the style parameters. For example, based on the style parameters of the structure diagram, render through a visualization engine to generate a structure diagram image corresponding to the style parameters. Among them, one set of style parameters generates one structure diagram image.
[0063] Step 106: Generate annotation data corresponding to the structure diagram image based on the structure diagram image.
[0064] Among them, the annotation data may refer to the connection line information and node information in the structure diagram image, etc. For example, the area where the connection line is located in the structure diagram image, the position of the node in the structure diagram image, etc., which are not limited in the embodiments of the present invention.
[0065] Specifically, after generating the corresponding structure diagram image based on the style parameters, since the structure diagram image is an editable image, the style parameters in the structure diagram image can be changed to generate the annotation data corresponding to the structure diagram image.
[0066] Step 108: Combine the structure diagram image and the annotation data into sample data for training the model to be trained.
[0067] Specifically, the structure diagram image and the corresponding annotation data are combined into a sample data for training the model to be trained.
[0068] In the embodiments of the present invention, various structure diagram images and corresponding annotation data can be generated as sample data according to randomly set style parameters, which improves the generation efficiency of the sample data, reduces the generation cost of the sample data, effectively solves the problem of difficult acquisition of the sample data, and has a good auxiliary effect on the model training effect.
[0069] In addition, generating various structure diagram images and corresponding annotation data according to randomly set style parameters can also be used for algorithm verification and testing, providing a data basis for the structure reduction of the structure diagram.
[0070] Refer to Figure 2 , which shows the step flowchart of another embodiment of the sample data generation method of the present invention, and specifically may include the following steps:
[0071] Step 202: Randomly set the style parameters of the structure diagram.
[0072] Among them, the style parameters at least include one of typesetting style, connection line type, connection line thickness, connection line color, text, font size, node type, hierarchical relationship of nodes, node box shape, thickness of the node box, node color, and image background. By randomly setting the style parameters of the structure diagram, a large number of different style parameters can be quickly obtained, so as to generate various structure diagram images based on a large number of different style parameters.
[0073] Step 204: Generate a descriptive file of the structure diagram based on the style parameters.
[0074] Step 206: Input the descriptive file into the visualization engine for rendering to obtain a structure diagram image.
[0075] Among them, the descriptive file is a file that can be loaded by the visualization engine, such as a JavaScript + HTML file. Specifically, a descriptive file of the structure diagram is generated using the style parameters, and then the descriptive file is passed into the visualization engine (such as the G6 graph visualization engine) for rendering, and finally the structure diagram image is obtained.
[0076] Refer to Figure 3 , which shows a schematic diagram of an embodiment for generating a structure diagram image of the present invention. As can be seen from the figure, after randomly setting the style parameters of the structure diagram and generating a JavaScript + HTML file (descriptive file) based on the style parameters, the descriptive file is then passed into the visualization engine for rendering, and finally the structure diagram image is obtained. Among them, after generating the JavaScript + HTML file based on the style parameters, a loop starts, and the style parameters of the structure diagram are randomly set continuously, so as to obtain a large number of different style parameters to generate a large number of different structure diagram images.
[0077] Step 208, generate annotation data corresponding to the structure diagram image based on the structure diagram image.
[0078] In an embodiment of the present invention, the annotation data includes a connection line mask image; generating the annotation data corresponding to the structure diagram image based on the structure diagram image includes: adjusting the pixel value of the background in the structure diagram image to a first pixel value, adjusting the pixel value of the connection line to a second pixel value, setting the text to be empty, setting the node to be empty, and generating a connection line mask image; wherein, the first pixel value is not equal to the second pixel value, and the connection line mask image is used to indicate the area where the connection line is located in the structure diagram image.
[0079] Among them, the mask image is a binary mask image. A binary mask image refers to a binary image obtained by segmenting the target area according to the pixel values of the image. In the mask image, the pixel values of the target area are different from those of other areas, so that the target area in the mask image can be distinguished.
[0080] Specifically, the pixel value of the background in the structure diagram image is adjusted to a first pixel value, the pixel value of the connection line is adjusted to a second pixel value, the text is set to be empty, the node is set to be empty, and a connection line mask image is generated. The pixel value of the connection line in the connection line mask image is different from that of other areas, and is used to indicate the area where the connection line is located in the structure diagram image. For example, refer to Figure 4, which shows a schematic diagram of an embodiment for generating a connection line mask image of the present invention. By adjusting the pixel values of the background in the original structure diagram image (a) to 0 (black), the pixel values of the connection lines to 255 (white), the text to be empty, and the nodes to be empty, a connection line mask image (b) can be obtained. Additionally, the corresponding pixel values of the background can also be adjusted to 255 (white), while the pixel values of the connection lines are adjusted to 0 (black), which is not limited herein.
[0081] In an embodiment of the present invention, the annotation data includes the position information of the nodes; generating the annotation data corresponding to the structure diagram image based on the structure diagram image includes: setting the background of the structure diagram image to be empty, the connection lines to be empty, the text to be empty, and adjusting the pixel values of the nodes to a third pixel value to generate a node image; analyzing the node image through a connected component analysis algorithm to obtain the position information of the nodes in the structure diagram.
[0082] Among them, the connected component analysis (Connected Component Analysis-Labeling) algorithm is a relatively common and basic algorithm in many application fields of image analysis and processing, which can find and label the image regions composed of foreground pixel points with the same pixel values and adjacent positions in the image.
[0083] Specifically, set the background of the structure diagram image to be empty, the connection lines to be empty, the text to be empty, and adjust the pixel values of the nodes to a third pixel value to generate a node image. For example, referring to Figure 5 , which shows a schematic diagram of an embodiment for generating a node image of the present invention. By setting the background in the original structure diagram image (a) to be empty, the connection lines to be empty, the text to be empty, and the pixel values of the nodes to 0 (black), a node image (b) can be obtained. The nodes in the node image can be boxes or underlines, etc.
[0084] The obtained node image only contains nodes, and the pixel values of the nodes are the same. Therefore, a connected component analysis algorithm can be used to analyze the node image to obtain the position information of each node in the structure diagram image.
[0085] Step 210: Combine the structure diagram image and the annotation data into sample data for training the model to be trained.
[0086] In an embodiment of the present invention, it further includes: grouping the sample data based on the layout style to obtain sample data groups; where the sample data groups include corresponding grouping identifiers; sampling the sample data in the corresponding sample data groups according to the grouping identifiers to obtain target sample data; and inputting the target sample data into the model to be trained for training.
[0087] Specifically, the layout styles specifically include various styles such as circular diagrams, bubble diagrams, tree diagrams, flowcharts, bridge diagrams, etc. The sample data can be grouped based on the layout styles to obtain multiple groups of sample data, and each group of sample data includes a corresponding grouping identifier. For example, the sample data corresponding to the structure diagram with a circular diagram layout style is divided into one group, and the sample data corresponding to the structure diagram with a bubble diagram layout style is divided into one group, etc. It should be noted that in addition to grouping the sample data based on the layout styles, the sample data can also be grouped based on other sampling parameters. For example, the sample data can be grouped based on the connection line style, node style, or background style. The embodiments of the present invention do not limit this.
[0088] After grouping the sample data, sample data is sampled in the corresponding group of sample data according to the grouping identifier to obtain target sample data. For example, sample data is randomly sampled from each group of sample data according to a certain proportion and used as the target sample data, and then the target sample data is input into the model to be trained for training.
[0089] In the embodiments of the present invention, various structure diagram images and corresponding annotation data can be generated as sample data according to randomly set style parameters, which improves the generation efficiency of sample data, reduces the generation cost of sample data, effectively solves the problem of difficult acquisition of sample data, and has a good auxiliary effect on the model training effect.
[0090] In addition, generating various structure diagram images and corresponding annotation data according to randomly set style parameters can also be used for algorithm verification and testing, providing a data basis for the structure reduction of the structure diagram.
[0091] It should be noted that for the method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the embodiments of the present invention are not limited by the described action sequences, because according to the embodiments of the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily essential for the embodiments of the present invention.
[0092] Refer to Figure 6 , which shows a structural block diagram of an embodiment of a sample data generation device of the present invention, and specifically may include the following modules:
[0093] A parameter setting module 602, configured to randomly set style parameters of the structure diagram;
[0094] An image generation module 604, configured to generate a structure diagram image corresponding to the style parameters based on the style parameters;
[0095] A data generation module 606, configured to generate annotation data corresponding to the structure diagram image based on the structure diagram image;
[0096] A data combination module 608, configured to combine the structure diagram image and the annotation data into sample data for training a model to be trained.
[0097] In an embodiment of the present invention, the style parameters at least include one of typesetting style, connection line type, connection line thickness, connection line color, text, font size, node type, node box shape, thickness of the node box, node color, and image background.
[0098] In an embodiment of the present invention, the image generation module 604 includes:
[0099] A file generation sub-module, configured to generate a descriptive file of the structure diagram based on the style parameters;
[0100] An image generation sub-module, configured to render the descriptive file into a visualization engine to obtain a structure diagram image.
[0101] In an embodiment of the present invention, the annotation data includes a connection line mask image; the data generation module 606 includes:
[0102] A mask image generation sub-module, configured to adjust the pixel value of the background in the structure diagram image to a first pixel value, adjust the pixel value of the connection line to a second pixel value, set the text to be empty, and set the node to be empty, so as to generate a connection line mask image; wherein, the first pixel value is not equal to the second pixel value, and the connection line mask image is used to indicate the area where the connection line is located in the structure diagram image.
[0103] In an embodiment of the present invention, the annotation data includes position information of nodes; the data generation module 606 includes:
[0104] A node image generation sub-module, configured to set the background of the structure diagram image to be empty, set the connection line to be empty, set the text to be empty, and adjust the pixel value of the node to a third pixel value to generate a node image;
[0105] An information acquisition sub-module, configured to analyze the node image through a connected component analysis algorithm to obtain the position information of the nodes in the structure diagram.
[0106] In an embodiment of the present invention, it further includes:
[0107] A data grouping module, configured to group the sample data based on the typesetting style to obtain sample data groups; wherein, the sample data groups include corresponding grouping identifiers;
[0108] A data sampling module, configured to sample sample data in a corresponding sample data group according to the grouping identifier to obtain target sample data;
[0109] A model training module, configured to input the target sample data into a model to be trained for training.
[0110] For the apparatus embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For related parts, please refer to the partial description of the method embodiment.
[0111] Figure 7 FIG. is a block diagram of an electronic device 700 for sample data generation according to an exemplary embodiment. For example, the electronic device 700 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, a smart wearable device, etc.
[0112] Refer to Figure 7 , the electronic device 700 may include one or more of the following components: a processing component 702, a memory 704, a power component 706, a multimedia component 708, an audio component 710, an input / output (I / O) interface 712, a sensor component 714, and a communication component 716.
[0113] The processing component 702 generally controls the overall operation of the electronic device 700, such as operations associated with display, telephone calls, data communication, camera operations, and recording operations. The processing element 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the above method. In addition, the processing component 702 may include one or more modules to facilitate the interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate the interaction between the multimedia component 708 and the processing component 702.
[0114] The memory 704 is configured to store various types of data to support the operation of the device 700. Examples of these data include instructions for any application or method operating on the electronic device 700, contact data, phone book data, messages, images, videos, etc. The memory 704 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk.
[0115] The power component 706 provides power for various components of the electronic device 700. The power component 706 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the electronic device 700.
[0116] The multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of the touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operations. In some embodiments, the multimedia component 708 includes a front camera and / or a rear camera. When the electronic device 700 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have focal length and optical zoom capabilities.
[0117] The audio component 710 is configured to output and / or input audio signals. For example, the audio component 710 includes a microphone (MIC) that is configured to receive external audio signals when the electronic device 700 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 704 or transmitted via the communication component 716. In some embodiments, the audio component 710 further includes a speaker for outputting audio signals.
[0118] The I / O interface 712 provides an interface between the processing component 702 and a peripheral interface module, which can be a keyboard, a click wheel, buttons, etc. These buttons can include, but are not limited to: a home button, a volume button, a power button, and a lock button.
[0119] The sensor assembly 714 includes one or more sensors for providing an assessment of the status of various aspects of the electronic device 700. For example, the sensor assembly 714 can detect the on / off state of the device 700, the relative positioning of components, such as the display and keypad of the electronic device 700. The sensor assembly 714 can also detect a change in the position of the electronic device 700 or a component of the electronic device 700, the presence or absence of user contact with the electronic device 700, the orientation or acceleration / deceleration of the electronic device 700, and a change in the temperature of the electronic device 700. The sensor assembly 714 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 714 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 714 can also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0120] The communication component 716 is configured to facilitate communication, either wired or wirelessly, between the electronic device 700 and other devices. The electronic device 700 can access a wireless network based on communication standards, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 714 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 714 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0121] In an exemplary embodiment, the electronic device 700 can be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above-described methods.
[0122] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions, such as the memory 704 including instructions, is also provided. The above instructions can be executed by the processor 720 of the electronic device 700 to complete the above-described methods. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, among others.
[0123] A non - transitory computer - readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute a sample data generation method, the method comprising:
[0124] Randomly set the style parameters of the structure diagram;
[0125] Generate a structure diagram image corresponding to the style parameters based on the style parameters;
[0126] Generate annotation data corresponding to the structure diagram image based on the structure diagram image;
[0127] Combine the structure diagram image and the annotation data into sample data for training a model to be trained.
[0128] Optionally, the style parameters at least include one of typesetting style, connection line type, connection line thickness, connection line color, text, font size, node type, node box shape, thickness of the node box, node color, and image background.
[0129] Optionally, the generating a structure diagram image corresponding to the style parameters based on the style parameters includes:
[0130] Generate a descriptive file of the structure diagram based on the style parameters;
[0131] Input the descriptive file into a visualization engine for rendering to obtain a structure diagram image.
[0132] Optionally, the annotation data includes a connection line mask image; the generating annotation data corresponding to the structure diagram image based on the structure diagram image includes:
[0133] Adjust the pixel value of the background in the structure diagram image to a first pixel value, the pixel value of the connection line to a second pixel value, set the text to be empty, and set the node to be empty to generate a connection line mask image; wherein the first pixel value is not equal to the second pixel value, and the connection line mask image is used to indicate the area where the connection line is located in the structure diagram image.
[0134] Optionally, the annotation data includes the position information of the nodes; the generating annotation data corresponding to the structure diagram image based on the structure diagram image includes:
[0135] Set the background of the structure diagram image to be empty, the connection line to be empty, the text to be empty, and adjust the pixel value of the node to a third pixel value to generate a node image;
[0136] Analyze the node image through a connected - component analysis algorithm to obtain the position information of the nodes in the structure diagram.
[0137] Optionally, it further includes:
[0138] Grouping the sample data based on the layout style to obtain sample data groups; where
[0139] The sample data groups include corresponding grouping identifiers;
[0140] Sampling sample data in the corresponding sample data group according to the grouping identifier to obtain target sample data;
[0141] Inputting the target sample data into the model to be trained for training.
[0142] Figure 8 FIG. 17 is a schematic structural diagram of an electronic device 800 for sample data generation according to another exemplary embodiment of the present invention. The electronic device 800 may be a server, and the server may vary greatly due to configuration or performance differences, and may include one or more central processing units (CPUs) 822 (for example, one or more processors) and a memory 832, and one or more storage media 830 for storing application programs 842 or data 844 (for example, one or more mass storage devices). Among them, the memory 832 and the storage media 830 may be transient storage or persistent storage. The program stored in the storage media 830 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Further, the central processing unit 822 may be configured to communicate with the storage media 830 and execute a series of instruction operations in the storage media 830 on the server.
[0143] The server may further include one or more power supplies 826, one or more wired or wireless network interfaces 850, one or more input / output interfaces 858, one or more keyboards 856, and / or one or more operating systems 841, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0144] An electronic device includes a memory and one or more programs, where one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include instructions for performing the following operations:
[0145] Randomly set the style parameters of the structure diagram;
[0146] Generate a structure diagram image corresponding to the style parameters based on the style parameters;
[0147] Generate the annotation data corresponding to the structure diagram image based on the structure diagram image;
[0148] Combine the structure diagram image and the annotation data into sample data for training the model to be trained.
[0149] Optionally, the style parameters at least include one of typesetting style, connection line type, connection line thickness, connection line color, text, font size, node type, node box shape, thickness of the node box, node color, and image background.
[0150] Optionally, generating the structure diagram image corresponding to the style parameters based on the style parameters includes:
[0151] Generate a descriptive file of the structure diagram based on the style parameters;
[0152] Input the descriptive file into a visualization engine for rendering to obtain a structure diagram image.
[0153] Optionally, the annotation data includes a connection line mask image; generating the annotation data corresponding to the structure diagram image based on the structure diagram image includes:
[0154] Adjust the pixel values of the background in the structure diagram image to a first pixel value, the pixel values of the connection lines to a second pixel value, set the text to be empty, and set the nodes to be empty to generate a connection line mask image; wherein the first pixel value is not equal to the second pixel value, and the connection line mask image is used to indicate the area where the connection lines are located in the structure diagram image.
[0155] Optionally, the annotation data includes the position information of the nodes; generating the annotation data corresponding to the structure diagram image based on the structure diagram image includes:
[0156] Set the background of the structure diagram image to be empty, the connection lines to be empty, the text to be empty, and adjust the pixel values of the nodes to a third pixel value to generate a node image;
[0157] Analyze the node image through a connected component analysis algorithm to obtain the position information of the nodes in the structure diagram.
[0158] Optionally, it further includes:
[0159] Group the sample data based on the typesetting style to obtain sample data groups; wherein
[0160] The sample data groups include corresponding grouping identifiers;
[0161] Sample the sample data in the corresponding sample data group according to the grouping identifier to obtain target sample data;
[0162] Input the target sample data into the model to be trained for training.
[0163] In addition, it should be noted that: The embodiments of the present application also provide a computer program product or a computer program. The computer program product or the computer program may include computer instructions, and the computer instructions may be stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor may execute the computer instructions, so that the computer device executes the foregoing Figure 1 and Figure 2 the description of the sample data generation method in the corresponding embodiments. Therefore, it will not be elaborated here. In addition, the description of the beneficial effects of using the same method will not be elaborated either. For the technical details not disclosed in the computer program product or the computer program embodiments involved in the present application, please refer to the description of the method embodiments of the present application.
[0164] Each embodiment in this specification is described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The same or similar parts among the embodiments may be referred to each other.
[0165] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, and the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal devices generate a device for implementing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0166] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device implements the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0167] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device, so that a series of operation steps are executed on the computer or other programmable terminal device to generate a computer-implemented process. Thus, the instructions executed on the computer or other programmable terminal device provide steps for implementing the functions specified in one process or multiple processes and / or blocks. Figure 1 One process or multiple processes and / or blocks Figure 1 Steps for implementing the functions specified in one block or multiple blocks.
[0168] Although the preferred embodiments of the embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications once they know the basic creative concept. Therefore, the appended claims are intended to be construed as including the preferred embodiments and all changes and modifications falling within the scope of the embodiments of the present invention.
[0169] Finally, it should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or terminal device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or terminal device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, method, article or terminal device comprising the said element.
[0170] The above has introduced in detail a method for generating sample data, a device for generating sample data and an electronic device provided by the present invention. Specific examples are used in this text to elaborate on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present invention.
Claims
1. A method for generating sample data, characterized in that, Including: Randomly set the style parameters of the structure diagram; the style parameters at least include one of typesetting style, connection line type, connection line thickness, connection line color, text, font size, node type, node box shape, node box thickness, node color, and image background; Generate a structure diagram image corresponding to the style parameters based on the style parameters, and the structure diagram image is an editable image; Generate annotation data corresponding to the structure diagram image based on the structure diagram image; The annotation data at least includes one of a connection line mask image and the position information of the nodes; Combine the structure diagram image and the annotation data into sample data for training a model to be trained.
2. The method according to claim 1, characterized in that The generating the structure diagram image corresponding to the style parameters based on the style parameters includes: Generate a descriptive file of the structure diagram based on the style parameters; Input the descriptive file into a visualization engine for rendering to obtain a structure diagram image.
3. The method according to claim 1, wherein The annotation data includes a connection line mask image; the generating the annotation data corresponding to the structure diagram image based on the structure diagram image includes: Adjust the pixel value of the background in the structure diagram image to a first pixel value, adjust the pixel value of the connection line to a second pixel value, set the text to be empty, and set the nodes to be empty to generate a connection line mask image; wherein the first pixel value is not equal to the second pixel value, and the connection line mask image is used to indicate the area where the connection line is located in the structure diagram image.
4. The method according to claim 1, wherein The annotation data includes the position information of the nodes; the generating the annotation data corresponding to the structure diagram image based on the structure diagram image includes: Set the background of the structure diagram image to be empty, set the connection lines to be empty, set the text to be empty, and adjust the pixel value of the nodes to a third pixel value to generate a node image; Analyze the node image through a connected component analysis algorithm to obtain the position information of the nodes in the structure diagram.
5. The method according to claim 1, wherein Also including: Group the sample data based on the typesetting style to obtain sample data groups; Wherein the sample data groups include corresponding grouping identifiers; Sample the sample data in the corresponding sample data group according to the grouping identifier to obtain target sample data; Input the target sample data into the model to be trained for training.
6. A sample data generation device, characterized in that, Including: A parameter setting module for randomly setting the style parameters of the structure diagram; the style parameters at least include one of typesetting style, connection line type, connection line thickness, connection line color, text, font size, node type, node box shape, node box thickness, node color, and image background; An image generation module for generating a structure diagram image corresponding to the style parameters based on the style parameters, and the structure diagram image is an editable image; A data generation module for generating annotation data corresponding to the structure diagram image based on the structure diagram image; The annotation data at least includes one of a connection line mask image and the position information of the nodes; A data combination module for combining the structure diagram image and the annotation data into sample data for training a model to be trained.
7. An electronic device, characterized in that, Comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors, and the one or more programs include a method for generating sample data as described in any one of claims 1-5 of the method claims.
8. A readable storage medium, characterized in that, When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute a method for generating sample data as described in any one of claims 1-5 of the method claims.
9. A computer program product, characterized in that, The computer program product includes computer instructions that are stored in a computer-readable storage medium and are adapted to be read and executed by a processor to cause a computer device having the processor to execute a method for generating sample data as described in any one of claims 1-5.
Citation Information
Patent Citations
Sample data generation method and device and electronic equipment
CN110210505A