Method, device, electronic device and storage medium for converting dynamic image to static image
By converting the dynamic code of the dynamic graph into static code and adding custom nodes, the problem of large gaps in the process of dynamic graph to static graph is solved, and the performance of the static graph and the friendliness of user operations are improved.
Patent Information
- Application Number
- CN202210720872.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-23
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2042-06-23
AI Technical Summary
In the process of dynamic graph to static graph, the gap between dynamic graph and static graph is large. The generated static graph is average in performance, and the operation error prompts are unfriendly, and the hardware application range is narrow.
By converting the dynamic code of the dynamic graph to be converted into static code, an initial static graph is generated, and user-defined operations are compiled into custom nodes, and added to the initial static graph to generate the target static graph, narrowing the gap between the dynamic graph and the static graph.
While maintaining the flexibility of dynamic graphs, the performance of static graphs is improved, the gap between dynamic graphs and static graphs is narrowed, and the generation quality of static graphs is improved.
Smart Images

Figure CN115034960B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing and deep learning technology in the field of artificial intelligence technology, and in particular to a method, device, electronic device and storage medium for converting a dynamic image into a static image. Background Art
[0002] Currently, in the dynamic-static conversion scenario in deep learning frameworks, dynamic-static conversion can be performed through the CUDA (Compute Unified Device Architecture) Graph native API (Application Programming Interface). During the first execution, the operation on the GPU (Graphics Processing Unit) is recorded.
[0003] However, the prompts for operational errors are not friendly, and the hardware has a narrow scope of application, which leads to a large gap between dynamic images and static images, and the performance of the generated static images is average. Summary of the Invention
[0004] The present disclosure provides a method, device, electronic device, and storage medium for converting a dynamic image into a static image.
[0005] According to a first aspect, a method for converting a dynamic graph into a static graph is provided, comprising: obtaining a dynamic graph to be converted; converting the dynamic code of the dynamic graph to be converted into static code to generate an initial static graph; compiling user-defined operations into custom nodes; and adding the custom nodes to the initial static graph to generate a target static graph.
[0006] According to a second aspect, a device for converting a dynamic graph into a static graph is provided, comprising: an acquisition module for acquiring a dynamic graph to be converted; a first generation module for converting the dynamic code of the dynamic graph to be converted into static code to generate an initial static graph; a compilation module for compiling user-defined operations into custom nodes; and a second generation module for adding the custom nodes to the initial static graph to generate a target static graph.
[0007] According to a third aspect, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for converting a dynamic image into a static image described in the first aspect of the present disclosure.
[0008] According to a fourth aspect, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method for converting a dynamic image into a static image according to the first aspect of the present disclosure.
[0009] According to a fifth aspect, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the steps of the method for converting a dynamic image into a static image according to the first aspect of the present disclosure.
[0010] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure.
[0012] Figure 1 1 is a flow chart of a method for converting a dynamic image into a static image according to the first embodiment of the present disclosure;
[0013] Figure 2 is a schematic diagram of the initial static graph;
[0014] Figure 3 This is a schematic diagram of a custom node;
[0015] Figure 4 is a flowchart of a method for converting a dynamic image into a static image according to a second embodiment of the present disclosure;
[0016] Figure 5 This is a flow chart of adding custom nodes to the initial static graph;
[0017] Figure 6 is a block diagram of an apparatus for converting a dynamic image into a static image according to a first embodiment of the present disclosure;
[0018] Figure 7 is a block diagram of an apparatus for converting a dynamic image into a static image according to a second embodiment of the present disclosure;
[0019] Figure 8 It is a block diagram of an electronic device used to implement the method of converting a dynamic image into a static image according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0020] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0021] Artificial Intelligence (AI) is a discipline that studies and develops theories, methods, techniques, and application systems for simulating, extending, and expanding human intelligence. Currently, AI technology has gained widespread application due to its high degree of automation, high precision, and low cost.
[0022] Image processing, also known as image processing, is the use of computers to analyze images to achieve desired results. Image processing generally refers to digital image processing. A digital image is a large two-dimensional array captured by devices such as industrial cameras, video cameras, and scanners. The elements of this array are called pixels, and their values are called grayscale values. Image processing techniques generally include three components: image compression, enhancement and restoration, and matching, description, and recognition.
[0023] Deep learning (DL) is a new research direction in machine learning (ML). It learns the inherent patterns and representational hierarchies of sample data. The information gained from this learning process is highly helpful for interpreting data such as text, images, and sound. Its ultimate goal is to enable machines to acquire human-like analytical and learning capabilities, enabling them to recognize text, images, and sound. Specifically, this research focuses on neural network systems based on convolutional operations, known as convolutional neural networks; autoencoder neural networks based on multi-layer neurons; and deep belief networks, which use multi-layer autoencoder neural networks for pre-training and then further optimize the neural network weights by incorporating discriminant information. Deep learning has achieved significant results in search technology, data mining, machine learning, machine translation, natural language processing, multimedia learning, speech, recommendation and personalization technologies, and other related fields. Deep learning enables machines to mimic human activities such as seeing, hearing, and thinking, solving many complex pattern recognition challenges and significantly advancing AI-related technologies.
[0024] The following describes the method, device, electronic device, and storage medium for converting a dynamic image into a static image according to embodiments of the present disclosure in conjunction with the accompanying drawings.
[0025] Figure 1It is a flowchart of a method for converting a dynamic image into a static image according to the first embodiment of the present disclosure.
[0026] like Figure 1 As shown, the method for converting a dynamic image to a static image according to an embodiment of the present disclosure may specifically include the following steps:
[0027] S101, obtaining a dynamic image to be converted.
[0028] Specifically, the execution subject of the method for converting a dynamic image to a static image in the embodiment of the present disclosure may be the device for converting a dynamic image to a static image provided in the embodiment of the present disclosure. The device for converting a dynamic image to a static image may be a hardware device with data information processing capabilities and / or the necessary software required to drive the hardware device to work. Optionally, the execution subject may include a workstation, a server, a computer, a user terminal, and other devices. Among them, the user terminal includes but is not limited to a mobile phone, a computer, an intelligent voice interaction device, a smart home appliance, a vehicle-mounted terminal, etc.
[0029] It is understood by those skilled in the art that within deep learning frameworks, there are two execution modes: static graphs and dynamic graphs. A static graph refers to an execution plan generated by the deep learning framework based on a user-defined network. When the execution plan is passed to the runtime, the plan is scheduled and executed by the executor to obtain the final result. In a static graph, the code written by the upper-level developer corresponds to a node in the computational graph, but does not represent a specific execution action, so intermediate results cannot be obtained immediately. In contrast to a static graph, the code written by the upper-level developer in a dynamic graph corresponds to a specific execution action, which is relatively more flexible and convenient for algorithm engineers to perform some custom operations and algorithm innovations. Since the static graph is fully compiled and optimized to obtain the optimal execution plan, it has better performance. In order to simultaneously take into account the flexibility of dynamic graphs and the high performance of static graphs, a series of tools such as CPython (Python implemented in C language) and Numba (an open source compiler) are used, based on an automatic conversion method, to reduce the gap between dynamic graphs and static graphs, achieving both flexibility and high performance.
[0030] In the existing technology, a native API, namely CUDA Graph, can be used to record operations on the GPU during the first execution, and the recorded operations can be repeatedly executed in the subsequent process. However, the prompts for operation errors are not friendly, and the applicability of the hardware is narrow, which leads to a large gap between dynamic graphs and static graphs, and the performance of the generated static graphs is average. In addition, PyTorch (a deep learning framework) can be used to use Trace (pre-run) or AOT (source code conversion) to convert Python (a computer programming language) code into an intermediate language, which can then be deployed to the C++ (a high-level language) side and use the built-in JIT (Just In Time) executor to accelerate the calculation process. However, Trace and AOT are limited to recording only forward operations and are mainly used for inference deployment, and are not complete dynamic-to-static functions.
[0031] In order to solve the above problems, the present disclosure proposes a method for converting dynamic graphs into static graphs, which converts the dynamic code of the dynamic graph to be converted into static code to generate an initial static graph, and adds the custom nodes compiled by user-defined operations to the initial static graph to generate a target static graph, further narrowing the gap between dynamic graphs and static graphs. While ensuring the flexibility of the dynamic graph, it is converted into a static graph, thereby improving the performance of the static graph.
[0032] In the embodiment of the present disclosure, the dynamic image is the original dynamic image waiting for conversion, and the dynamic image to be converted is obtained for subsequent processing.
[0033] S102: Convert the dynamic code of the dynamic image to be converted into a static code to generate an initial static image.
[0034] Specifically, the dynamic code is the code of the dynamic graph that has been written in advance, and the static code is the code obtained by converting the dynamic code, such as Figure 2 As shown, the initial static image corresponds to the initial static code. The dynamic code of the dynamic image to be converted obtained in step S101 is converted into static code to generate the corresponding initial static image. It should be noted that the dynamic image corresponds to the dynamic code, and the static image corresponds to the static code. The dynamic code includes multiple dynamic lines of code, and the static code includes multiple static lines of code. Optionally, the dynamic code can be converted into static code using tools in a deep learning framework.
[0035] S103, compiling the user-defined operation into a custom node.
[0036] Specifically, user-defined operations refer to user-defined operations on dynamic graphs, such as custom hook functions, etc. Custom nodes are operation nodes corresponding to user-defined operations. User-defined operations are compiled into custom nodes, such as Figure 3 Optionally, users can perform customized operations by using registration hooks.
[0037] S104: Add the custom node to the initial static graph to generate a target static graph.
[0038] Specifically, the target static graph is a static graph containing custom nodes. The custom nodes compiled in step S103 are added to the initial static graph generated in step S102 to generate the corresponding target static graph. It should be noted that the target static graph is applied to the image processing model, which uses the target static graph to perform image processing operations on the input image to be processed.
[0039] In summary, the method for converting a dynamic graph to a static graph in an embodiment of the present disclosure obtains a dynamic graph to be converted, converts the dynamic code of the dynamic graph to be converted into a static code to generate an initial static graph, compiles user-defined operations into custom nodes, and adds the custom nodes to the initial static graph to generate a target static graph. The method for converting a dynamic graph to a static graph in the present disclosure further narrows the gap between dynamic graphs and static graphs by converting the dynamic code of the dynamic graph to be converted into a static code to generate an initial static graph, and adding the custom nodes compiled from user-defined operations to the initial static graph to generate a target static graph. It converts the dynamic graph into a static graph while ensuring its flexibility, thereby improving the performance of the static graph.
[0040] Figure 4 It is a flowchart of a method for converting a dynamic image into a static image according to the second embodiment of the present disclosure.
[0041] like Figure 4 As shown, in Figure 1 Based on the illustrated embodiment, the method for converting a dynamic image to a static image in the embodiment of the present disclosure may specifically include the following steps:
[0042] S401: Obtain a dynamic image to be converted.
[0043] It should be noted that step S401 in this embodiment is the same as step S101 in the above embodiment and will not be described again here.
[0044] The step S102 of “converting the dynamic code of the dynamic graphic to be converted into static code” in the above embodiment may specifically include the following step S402 .
[0045] S402 : In response to the operation corresponding to the dynamic line code being an operation not supported by the static graph, outputting modification prompt information for the user to modify the dynamic line code into a static line code according to the modification prompt information.
[0046] Specifically, the operation corresponding to the dynamic line code refers to the operation supported or not supported by the static graph. The operation not supported by the static graph is the operation that cannot be converted in the dynamic graph. The modification prompt information is the specific prompt information that the user needs to modify the dynamic line code. It is judged whether the operation corresponding to the dynamic line code is an operation not supported by the static graph. If the operation corresponding to the dynamic line code is an operation not supported by the static graph, the modification prompt information is output for the user to modify the dynamic line code to the static line code according to the modification prompt information. For example, when the operation not supported by the static graph is to convert the NumPy (NumericalPython, an open source numerical computing extension of Python) data type, the corresponding modification prompt information is to prompt the user to convert the NumPy data type into the Tensor type within the deep learning framework.
[0047] It is understood in this field that the runtime of static graphs is heavily dependent on the compilation of static graphs. In the static graph, except for defining the forward networking, other operations are managed internally by the deep learning framework and users cannot interfere. As a result, some more flexible operations corresponding to the dynamic line codes in the dynamic graph (such as custom hook functions, etc.) cannot be supported by the static graph, which brings difficulties to the conversion from dynamic graphs to static graphs.
[0048] S403: Generate an initial static image.
[0049] It should be noted that step S403 in this embodiment may refer to step S102 in the above embodiment, and will not be described in detail here.
[0050] S404: Compile the user-defined operation into a custom node.
[0051] It should be noted that step S404 in this embodiment is the same as step S103 in the above embodiment and will not be described again here.
[0052] The step S104 of “adding the custom node to the initial static graph” in the above embodiment may specifically include the following step S405 .
[0053] S405 : In response to the custom node being a newly added node, a dependency relationship is established between the custom node and a corresponding node in the initial static graph, so as to add the custom node to the initial static graph.
[0054] Specifically, the custom node may include a new node. The custom node compiled in step S403 is judged. If the custom node is a new node, a dependency relationship is established between the custom node and the corresponding node in the initial static graph generated in step S404 to add the custom node to the initial static graph.
[0055] S406: Generate a target static image.
[0056] It should be noted that step S406 in this embodiment may refer to step S104 in the above embodiment, and will not be described in detail here.
[0057] In summary, the method for converting a dynamic graph to a static graph in the embodiment of the present disclosure obtains a dynamic graph to be converted, and in response to the operation corresponding to the dynamic line code being an operation not supported by the static graph, outputs a modification prompt message for the user to modify the dynamic line code to a static line code according to the modification prompt message, generates an initial static graph, compiles the user-defined operation into a custom node, and in response to the custom node being a newly added node, establishes a dependency relationship between the custom node and the corresponding node in the initial static graph, so as to add the custom node to the initial static graph to generate a target static graph. The method for converting a dynamic graph to a static graph in the present disclosure further narrows the gap between dynamic graphs and static graphs by converting the dynamic code of the dynamic graph to be converted into static code to generate an initial static graph, and adding the custom node compiled from the user-defined operation to the initial static graph to generate a target static graph, thereby converting the dynamic graph into a static graph while ensuring its flexibility, thereby improving the performance of the static graph. At the same time, by outputting modification prompt information when the operation corresponding to the dynamic line code is not supported by the static graph, so that the user can modify the dynamic line code to the static line code, the gap between the dynamic graph and the static graph is further narrowed. In addition, by establishing a dependency relationship between the custom node and the corresponding node in the initial static graph when the custom node is a newly added node, and adding the custom node to the initial static graph, the gap between the dynamic graph and the static graph is further narrowed.
[0058] Furthermore, the step 102 of “converting the dynamic code of the dynamic graphic to be converted into static code” in the above embodiment may further specifically include the following steps.
[0059] In response to the operation corresponding to the dynamic line code being an operation supported by the static graph, the dynamic line code is modified into a static line code by modifying the syntax tree through source code conversion.
[0060] Specifically, the operations supported by the static graph are the same operations that can be converted into the dynamic graph. If the dynamic line of code corresponds to an operation supported by the static graph, the source code is converted to a static line of code by modifying the syntax tree. Optionally, the syntax tree can be an Abstract Syntax Tree (AST).
[0061] Therefore, the syntax tree is modified by source code conversion to modify the dynamic line code whose operations are not supported by the static graph into static line code, further narrowing the gap between the dynamic graph and the static graph.
[0062] Furthermore, the step 104 of “adding the custom node to the initial static graph” in the above embodiment may further specifically include the following steps.
[0063] In response to the custom node being a replacement node, a dependency relationship is established between the custom node and upstream and downstream nodes of the corresponding node in the initial static graph, so as to add the custom node to the initial static graph.
[0064] Specifically, such as Figure 5 As shown, the custom node may include a replacement node. If the custom node is a replacement node, a dependency relationship is established between the custom node and the upstream and downstream nodes of the corresponding node in the initial static graph to add the custom node to the initial static graph.
[0065] Therefore, by establishing dependency relationships between the replacement node and the upstream and downstream nodes of the corresponding node in the initial static graph and adding the replacement node to the initial static graph, the gap between the dynamic graph and the static graph is further narrowed.
[0066] Figure 6 4 is a block diagram of an apparatus for converting a dynamic image into a static image according to a first embodiment of the present disclosure.
[0067] like Figure 6 As shown, the apparatus 600 for converting a dynamic image to a static image according to an embodiment of the present disclosure includes: an acquisition module 601 , a first generation module 602 , a compilation module 603 and a second generation module 604 .
[0068] The acquisition module 601 is used to acquire the dynamic image to be converted.
[0069] The first generating module 602 is configured to convert the dynamic code of the dynamic image to be converted into a static code to generate an initial static image.
[0070] The compiling module 603 is used to compile the user-defined operation into a custom node.
[0071] The second generating module 604 is configured to add the custom node to the initial static graph to generate a target static graph.
[0072] It should be noted that the above explanation of the embodiment of the method for converting a dynamic image to a static image is also applicable to the device for converting a dynamic image to a static image in the embodiment of the present disclosure, and the specific process will not be repeated here.
[0073] In summary, the device for converting a dynamic graph to a static graph of the embodiment of the present disclosure obtains a dynamic graph to be converted, converts the dynamic code of the dynamic graph to be converted into a static code to generate an initial static graph, compiles user-defined operations into custom nodes, and adds the custom nodes to the initial static graph to generate a target static graph. The device for converting a dynamic graph to a static graph of the present disclosure further narrows the gap between dynamic graphs and static graphs by converting the dynamic code of the dynamic graph to be converted into a static code to generate an initial static graph, and adding the custom nodes compiled from user-defined operations to the initial static graph to generate a target static graph. It converts the dynamic graph into a static graph while ensuring its flexibility, thereby improving the performance of the static graph.
[0074] Figure 7 4 is a block diagram of an apparatus for converting a dynamic image into a static image according to a second embodiment of the present disclosure.
[0075] like Figure 7 As shown, the apparatus 700 for converting a dynamic image into a static image according to an embodiment of the present disclosure includes: an acquisition module 701 , a first generation module 702 , a compilation module 703 and a second generation module 794 .
[0076] Among them, the acquisition module 701 has the same structure and function as the acquisition module 601 in the previous embodiment, the first generation module 702 has the same structure and function as the first generation module 602 in the previous embodiment, the compilation module 703 has the same structure and function as the compilation module 603 in the previous embodiment, and the second generation module 704 has the same structure and function as the second generation module 604 in the previous embodiment.
[0077] Furthermore, the target static graph is applied to the image processing model, and the image processing model performs image processing operations on the input image to be processed using the target static graph.
[0078] Furthermore, the dynamic code includes multiple dynamic line codes, and the static code includes multiple static line codes. The first generation module 702 includes: a first modification unit 7021, which is used to output modification prompt information in response to the operation corresponding to the dynamic line code being an operation not supported by the static image, so that the user can modify the dynamic line code to the static line code according to the modification prompt information.
[0079] Furthermore, the dynamic code includes multiple dynamic line codes, and the static code includes multiple static line codes. The first generation module 702 includes: a second modification unit 7022, which is used to modify the dynamic line code into a static line code in response to the operation corresponding to the dynamic line code being an operation supported by the static graph, and then use source code conversion to modify the syntax tree.
[0080] Furthermore, the second generating module 704 includes: a first adding unit, configured to establish a dependency relationship between the custom node and a corresponding node in the initial static graph in response to the custom node being a newly added node, so as to add the custom node to the initial static graph.
[0081] Furthermore, the adding module 704 includes: a second adding unit for establishing a dependency relationship between the custom node and upstream and downstream nodes of the corresponding node in the initial static graph in response to the custom node being a replacement node, so as to add the custom node to the initial static graph.
[0082] It should be noted that the above explanation of the embodiment of the method for converting a dynamic image to a static image is also applicable to the device for converting a dynamic image to a static image in the embodiment of the present disclosure, and the specific process will not be repeated here.
[0083] In summary, the device for converting a dynamic graph to a static graph in the embodiment of the present disclosure obtains a dynamic graph to be converted, and in response to the operation corresponding to the dynamic line code being an operation not supported by the static graph, outputs a modification prompt message for the user to modify the dynamic line code to a static line code according to the modification prompt message, generates an initial static graph, compiles the user-defined operation into a custom node, and in response to the custom node being a newly added node, establishes a dependency relationship between the custom node and the corresponding node in the initial static graph, so as to add the custom node to the initial static graph to generate a target static graph. The device for converting a dynamic graph to a static graph in the present disclosure further narrows the gap between dynamic graphs and static graphs by converting the dynamic code of the dynamic graph to be converted into static code to generate an initial static graph, and adding the custom node compiled from the user-defined operation to the initial static graph to generate a target static graph, thereby converting the dynamic graph into a static graph while ensuring its flexibility, thereby improving the performance of the static graph. At the same time, by using source code conversion to modify the syntax tree or outputting modification prompt information to modify the dynamic line code into static line code when the operation corresponding to the dynamic line code is supported or not supported by the static graph, the gap between the dynamic graph and the static graph is further narrowed. In addition, by establishing the dependency relationship between the custom node and the corresponding node or upstream and downstream nodes in the initial static graph when the custom node is a new node or a replacement node, and adding the custom node to the initial static graph, the gap between the dynamic graph and the static graph is further narrowed.
[0084] In the technical solutions disclosed herein, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0085] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0086] Figure 8 A schematic block diagram of an example electronic device 800 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are provided as examples only and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0087] like Figure 8 As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0088] Multiple components in the electronic device 800 are connected to the I / O interface 805, including an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a magnetic disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the electronic device 800 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0089] The computing unit 801 may be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as Figures 1 to 5The method for converting a dynamic image to a static image shown in the figure. For example, in some embodiments, the method for converting a dynamic image to a static image can be implemented as a computer software program, which is tangibly contained in a machine-readable storage medium, such as a storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of the method for converting a dynamic image to a static image described above can be performed. Alternatively, in other embodiments, the computing unit 801 can be configured to execute the method for converting a dynamic image to a static image by any other appropriate means (for example, by means of firmware).
[0090] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0091] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable dynamic image to static image conversion device, so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0092] In the context of the present disclosure, a machine-readable storage medium may be a tangible storage medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or apparatus. A machine-readable storage medium may be a machine-readable signal storage medium or a machine-readable storage medium. A machine-readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0093] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0094] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by digital data communication (e.g., a communication network) in any form or storage medium. Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.
[0095] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact via a communication network. This client-server relationship is established by computer programs running on the respective computers, establishing a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host, a host product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosts and VPS services ("Virtual Private Servers" or simply "VPS"). The server may also be a server in a distributed system or a server integrated with blockchain.
[0096] According to an embodiment of the present disclosure, the present disclosure further provides a computer program product, including a computer program, wherein when the computer program is executed by a processor, it implements the steps of the method for converting a dynamic image into a static image according to the above embodiment of the present disclosure.
[0097] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not limited herein.
[0098] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.
Claims
1. A method for converting a dynamic image into a static image, comprising: Get the dynamic image to be converted; Converting the dynamic code of the dynamic image to be converted into a static code to generate an initial static image; Compiling user-defined operations into custom nodes, wherein the user-defined operations are operations customized by the user on the dynamic graph; and In response to the custom node being a newly added node, establishing a dependency relationship between the custom node and a corresponding node in the initial static graph, so as to add the custom node to the initial static graph to generate a target static graph; In response to the custom node being a replacement node, establishing a dependency relationship between the custom node and upstream and downstream nodes of a corresponding node in the initial static graph, so as to add the custom node to the initial static graph to generate a target static graph; The dynamic code includes a plurality of dynamic lines of code, the static code includes a plurality of static lines of code, and converting the dynamic code of the dynamic graph to be converted into the static code includes: In response to the operation corresponding to the dynamic line code being an operation not supported by the static image, modification prompt information is output, so that the user can modify the dynamic line code into a static line code according to the modification prompt information.
2. The method according to claim 1, wherein The target static image is applied to an image processing model, and the image processing model performs image processing operations on an input image to be processed using the target static image.
3. The method according to claim 1, wherein converting the dynamic code of the dynamic graphic to be converted into static code further comprises: In response to the operation corresponding to the dynamic line code being an operation supported by the static graph, the dynamic line code is modified into a static line code by modifying the syntax tree through source code conversion.
4. A device for converting a dynamic image into a static image, comprising: An acquisition module, used to acquire the dynamic image to be converted; A first generating module is used to convert the dynamic code of the dynamic image to be converted into a static code to generate an initial static image; A compiling module, configured to compile user-defined operations into custom nodes, wherein the user-defined operations are operations customized by the user on the dynamic graph; and A second generating module is configured to add the custom node to the initial static graph to generate a target static graph; The second generation module includes: a first adding unit, configured to, in response to the custom node being a newly added node, establish a dependency relationship between the custom node and a corresponding node in the initial static graph, so as to add the custom node to the initial static graph; a second adding unit, configured to, in response to the custom node being a replacement node, establish a dependency relationship between the custom node and upstream and downstream nodes of a corresponding node in the initial static graph, so as to add the custom node to the initial static graph; The dynamic code includes a plurality of dynamic lines of code, the static code includes a plurality of static lines of code, and the first generating module includes: The first modifying unit is configured to output modification prompt information in response to the operation corresponding to the dynamic line code being an operation not supported by the static image, so that the user can modify the dynamic line code into a static line code according to the modification prompt information.
5. The device according to claim 4, wherein The target static image is applied to an image processing model, and the image processing model performs image processing operations on an input image to be processed using the target static image.
6. The apparatus according to claim 4, wherein the first generating module further comprises: The second modifying unit is configured to modify the dynamic line code into a static line code by converting the source code and modifying the syntax tree in response to the operation corresponding to the dynamic line code being an operation supported by the static graph.
7. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 3.
8. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-3.
9. A computer program product comprising a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Code conversion method and device, equipment and storage medium
CN112764755A
Hook method and device for compiling period, equipment and storage medium
CN112799677A