Picture generation method, electronic device, and computer-readable storage medium
By generating images locally on the terminal device and utilizing image slices and translated text provided by the server, the high cost and low efficiency problem caused by frequent interactions between the server and the terminal is solved, achieving more efficient multi-language image generation.
Patent Information
- Application Number
- CN202310456787.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-24
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-04-24
AI Technical Summary
In existing technologies, generating images in multiple languages results in high costs and low efficiency due to frequent interactions between the server and the user.
Images are generated locally on the terminal device, and the server retrieves the source images and translated text, reducing the number of interactions between the server and the terminal device and lowering server memory usage.
It reduces the difficulty and time cost of interactive operations, lowers server maintenance costs, and improves image generation efficiency.
Smart Images

Figure CN116719964B_ABST
Abstract
Description
Technical Field
[0001] This application relates to image processing technology, and in particular to image generation methods, electronic devices, and computer-readable storage media. Background Technology
[0002] In multilingual programs / systems, the program / system needs to support the display of most languages in the world. If it is image-text, then the corresponding language version of the image needs to be obtained.
[0003] In existing technologies, the way users obtain images in the corresponding language version is usually by sending the translated text and image materials in the corresponding language to the server, so that the server can process the translated text and image materials and then receive the multi-language images returned by the server.
[0004] However, in the above method, the image generation end is the server. If the user needs to obtain images in multiple languages, data often needs to be sent frequently between the user and the server. This not only increases the difficulty and time cost of interaction, but also occupies a lot of server memory and increases the server maintenance cost, resulting in high cost and low efficiency of image generation. Summary of the Invention
[0005] The main technical problem addressed by this application is to provide an image generation method, electronic device, and computer-readable storage medium that can solve the problems of high cost and low efficiency caused by the existing technology in generating images in multiple languages.
[0006] To address the aforementioned technical problems, the first technical solution adopted in this application is to provide an image generation method, comprising: a server receiving a material acquisition request sent by a terminal device; wherein the material acquisition request includes keywords and a target language identifier; acquiring each material slice and its annotation information based on the keywords; wherein the annotation information includes the position information of the material slice relative to the material; the material slice includes pattern slices and text slices; acquiring the translated text of the target language corresponding to the original text in each text slice according to the target language identifier; and sending each pattern slice and its corresponding annotation information, each translated text and its corresponding text slice's annotation information to the terminal device, so that the terminal device generates an image based on the pattern slices, the translated text, and the corresponding annotation information.
[0007] To address the aforementioned technical problems, the second technical solution adopted in this application is to provide an image generation method, comprising: a terminal device sending a material acquisition request to a server; wherein the material acquisition request includes keywords and target language identifiers; receiving from the server each material slice obtained based on the keywords and annotation information of the material slices; wherein the annotation information includes the position information of the material slices relative to the material; the material slices include pattern slices and text slices; and receiving from the server the translated text of the target language corresponding to the original text in each text slice obtained based on the target language identifier; and generating an image based on the pattern slices, the translated text, and the corresponding annotation information.
[0008] To solve the above-mentioned technical problems, the third technical solution adopted in this application is to provide an electronic device, including: a memory for storing program data, wherein when the stored program data is executed, the steps in the image generation method as described in any of the above claims are implemented; and a processor for executing program instructions stored in the memory to implement the steps in the image generation method as described in any of the above claims.
[0009] To solve the above-mentioned technical problems, the fourth technical solution adopted in this application is to provide a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps in the image generation method as described in any of the above claims.
[0010] The beneficial effects of this application are as follows: Unlike existing technologies, this application provides an image generation method, electronic device, and computer-readable storage medium. It receives a material acquisition request from a terminal device via a server, and sends the obtained material slices, annotation information, and corresponding target language translations to the terminal device. This allows the terminal device to generate images locally based on the received materials, reducing the number of interactions between the terminal device and the server, thereby lowering the operational difficulty and time cost during interaction. Furthermore, since the image generation end is switched from the server to the terminal device, the server's operating memory is reduced, thus lowering server maintenance costs, consequently reducing image generation costs, and improving image generation efficiency. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a principle block diagram of one embodiment of the image generation system of this application;
[0013] Figure 2 yes Figure 1 Signal flow diagram of the first embodiment of the image generation system;
[0014] Figure 3 yes Figure 1 Signal flow diagram of the second embodiment of the image generation system;
[0015] Figure 4 This is a flowchart illustrating the first embodiment of the image generation method of this application;
[0016] Figure 5 This is a flowchart illustrating the second embodiment of the image generation method of this application;
[0017] Figure 6 yes Figure 5 A flowchart illustrating a specific implementation method in S21;
[0018] Figure 7 yes Figure 5 A flowchart illustrating a specific implementation method in S22;
[0019] Figure 8 This is a flowchart illustrating the workflow of building the resource library and multilingual library on the server in this application;
[0020] Figure 9 This is a flowchart illustrating the third embodiment of the image generation method of this application;
[0021] Figure 10 This is a flowchart illustrating the fourth embodiment of the image generation method of this application;
[0022] Figure 11 This is a flowchart illustrating the application scenario of the image generation method one in this application;
[0023] Figure 12 This is a flowchart illustrating the fifth embodiment of the image generation method of this application;
[0024] Figure 13 This is a schematic diagram of the terminal device of this application generating corresponding images based on material slices and translated text;
[0025] Figure 14 This is a schematic diagram of the structure of one embodiment of the server in this application;
[0026] Figure 15 This is a schematic diagram of the structure of one embodiment of the terminal device of this application;
[0027] Figure 16 This is a schematic diagram of the structure of one embodiment of the electronic device of this application;
[0028] Figure 17This is a schematic diagram of one embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0029] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0030] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the application. The singular forms “a,” “said,” and “the” used in the embodiments of this application and the appended claims are also intended to include the plural forms, unless otherwise clearly indicated above. “Multiple” generally includes at least two, but does not exclude the inclusion of at least one.
[0031] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0032] It should be understood that the terms "comprising," "including," or any other variations used herein are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0033] This application first provides an image generation system.
[0034] Specifically, please refer to Figure 1 , Figure 1 This is a schematic diagram illustrating one embodiment of the image generation system of this application. In this embodiment, the image generation system 100 includes a connected terminal device 101 and a server 102.
[0035] In this embodiment, terminal device 101 refers to a client that has standard web page display capabilities and supports Hypertext Markup Language, such as any one or more of personal computers (PCs), tablet computers (PADs), mobile phones, and smart displays.
[0036] In this embodiment, server 102 is a cloud platform based on cloud computing, which can provide application programming interfaces (APIs) for terminal device 101. The cloud platform supports online storage and database services, data processing and analysis, secure access control, etc. This application mainly relates to the database services and data processing functions of the cloud platform.
[0037] Please see Figure 2 , Figure 2 yes Figure 1 The signal flow diagram of the first embodiment of the image generation system is shown. In this embodiment, the terminal device 101 sends a material acquisition request to the server 102. The server 102 sends the material slices and annotation information obtained based on the request, as well as the translated text in the corresponding target language, to the terminal device 101, so that the terminal device 101 can generate an image locally based on the received material.
[0038] Optionally, server 102 is also used to receive language switching requests sent by terminal device 101. See also... Figure 3 , Figure 3 yes Figure 1 Signal flow diagram of the second embodiment of the image generation system.
[0039] In this embodiment, terminal device 101 sends a material acquisition request to server 102. Server 102 sends the material slices and annotation information obtained based on the request, along with the corresponding translated text in the target language, to terminal device 101, enabling terminal device 101 to generate images locally based on the received materials. Further, terminal device 101 sends a language switching request to server 102. Server 102 sends the newly translated text obtained based on the language switching request to terminal device 101, enabling terminal device 101 to generate new multi-language images based on the previously acquired material slices, annotation information, and the new translated text.
[0040] Please see Figure 4 , Figure 4 This is a flowchart illustrating the first embodiment of the image generation method of this application. In this embodiment, the execution entity of the method is a server, and the method includes:
[0041] S11: The server receives a material acquisition request sent by the terminal device; the material acquisition request includes keywords and target language identifiers.
[0042] In this embodiment, keywords refer to the descriptive language of the requested material, and target language identifier refers to the parameters for obtaining the target language.
[0043] The target language can be any language corresponding to any country, such as Chinese, English, Arabic, etc., and this application does not limit it.
[0044] S12: Obtain each material slice and its annotation information based on the keyword; the annotation information includes the position information of the material slice relative to the material; the material slice includes pattern slices and text slices.
[0045] In this embodiment, the server retrieves the material with the highest matching degree from the stored materials based on keywords, and obtains each material slice and its annotation information.
[0046] Here, "materials" refers to UI (User Interface) design drafts, and "material slices" refers to each sliced element obtained after slicing the UI design drafts.
[0047] The location information can be a specific location feature vector or the relative distance of the material slice relative to a preset anchor point (such as the top left corner of the page or two adjacent sides of the page). This application does not limit this.
[0048] Among them, image slices refer to slice elements that are primarily graphic, while text slices refer to slice elements that are primarily text. Understandably, only text slices need to support multilingual display.
[0049] S13: Obtain the translated text of the target language corresponding to the original text in each text slice based on the target language identifier.
[0050] In this embodiment, the server parses and identifies the target language identifier to determine the corresponding target language, and obtains the translated text of the target language corresponding to the original text in each text slice based on the type of the target language.
[0051] S14: Send each pattern slice and its corresponding annotation information, each translated text and its corresponding text slice annotation information to the terminal device, so that the terminal device can generate an image based on the pattern slice, the translated text and its corresponding annotation information.
[0052] Understandably, the annotation information corresponding to the original text slice is also the annotation information corresponding to the translated text, and the location information of the translated text can be obtained based on this annotation information.
[0053] In this embodiment, the server sends each image slice and its corresponding annotation information, each translated text and its corresponding text slice annotation information to the terminal device, so that the terminal device can arrange each image slice and each translated text on the page based on the position information corresponding to each image slice and the position information corresponding to each translated text, thereby generating an image with the target language.
[0054] Understandably, since image generation is implemented on the terminal device, the server is only used to store the materials, the corresponding image slices, the translated text of the text slices, and the data transmission, which can greatly reduce the server's operating memory.
[0055] Unlike existing technologies, this implementation method involves a server receiving a material acquisition request from a terminal device and then sending the acquired material slices, annotation information, and corresponding target language translations to the terminal device. This allows the terminal device to generate images locally based on the received materials, reducing the number of interactions between the terminal device and the server, thereby lowering the operational complexity and time cost during interactions. Furthermore, since the image generation endpoint is switched from the server to the terminal device, the server's operating memory is reduced, thus lowering server maintenance costs, which in turn reduces the cost of image generation and improves image generation efficiency.
[0056] Please see Figure 5 , Figure 5 This is a flowchart illustrating the second embodiment of the image generation method of this application. In this embodiment, the execution entity of the method is a server, and the method includes:
[0057] S21: Establish a material library on the server; the material library stores multiple materials and their corresponding material slices and annotation information, and each material carries at least one category tag.
[0058] Specifically, please refer to Figure 6 , Figure 6 yes Figure 5 A flowchart illustrating a specific implementation method in S21.
[0059] S211: Import multiple materials and their corresponding material slices into the server.
[0060] Here, "materials" refers to UI (User Interface) design drafts, and "material slices" refers to each sliced element obtained after slicing the UI design drafts.
[0061] Each image slice corresponds to an ID (Identification) information.
[0062] S212: Categorize each piece of material; whereby each piece of material corresponds to at least one category label.
[0063] In this embodiment, a target detection model is used to detect targets in each image to be classified, and the identified objects are classified, with each object corresponding to a classification word.
[0064] The process involves calculating the area percentage of each object in the materials to be classified, sorting the multiple area percentages, and using the classification words of the objects corresponding to at least one of the top area percentages as the classification labels for the materials to be classified, thus obtaining multiple classification materials.
[0065] The training method for the object detection model is as follows: input multiple labeled sample materials into a preset deep learning model; use the preset deep learning model to classify and predict objects in the sample materials; determine whether to retrain the preset deep learning model based on the loss function corresponding to the prediction results and the labeled type of the sample materials, and determine the trained preset deep learning model as the object detection model.
[0066] S213: Obtain the size information and position information relative to the material for each material slice, and determine the type of each material slice; the type includes pattern slices and text slices.
[0067] In this embodiment, the size and position information of the material slices are determined by obtaining the position feature vector of each material slice or its page distance relative to the page.
[0068] The position feature vector can be represented by (x, yw, h), where x is the horizontal coordinate of the center of the cut image, y is the vertical coordinate of the center of the cut image, w is the width of the cut image, and h is the height of the cut image.
[0069] The margins can be determined by the distance between the top left and bottom right corners of the image and the page margins.
[0070] Furthermore, the type of each material image slice is distinguished.
[0071] In a specific implementation scenario, image slices containing only text are classified as text slices, and the remaining image slices are classified as pattern slices.
[0072] In another specific implementation scenario, the material slices with longer strings corresponding to the text are classified as text slices, and the remaining material slices are classified as pattern slices.
[0073] S214: Use size information, location information, and type as annotation information for material slices, and store the material, category tags, material slices, and annotation information to build a material library.
[0074] In some implementations, it is also used to determine whether each material slice overlaps with other material slices.
[0075] Specifically, the size and position information of each material slice are used to determine whether there are overlapping areas among the other material slices. In response to the existence of overlapping areas, the ID information of other material slices that overlap with this material slice is recorded in the annotation information of this material slice.
[0076] Understandably, multiple image slices with overlapping areas are different in terms of layering, but visually they overlap. By recording the ID information of other image slices with overlapping areas in the annotation information of each image slice, the image can be restored and displayed when the terminal device generates the image.
[0077] S22: Establish a multilingual library on the server; wherein, the multilingual library stores multiple translated texts of different language types corresponding to the original text in each text slice.
[0078] Specifically, please refer to Figure 7 , Figure 7 yes Figure 5 A flowchart illustrating a specific implementation method in S22.
[0079] S221: Generate multiple translated texts corresponding to different language types based on the original text of each text slice.
[0080] In this embodiment, a text recognition plugin can be used to recognize the text slice to obtain the original text contained in the text slice.
[0081] Among them, the text recognition plugin can be OCR (Optical Character Recognition) text recognition technology, which is a plugin that uses OCR technology to recognize text on images and locate text coordinates.
[0082] Furthermore, each identified original text is translated into multiple languages to obtain translated texts in different language versions for each original text.
[0083] Specifically, the size information of the translated text is set based on the size information corresponding to each original text.
[0084] S222: Determine whether each translated text is written in the same order as the original text.
[0085] Specifically, writing order refers to the direction in which the text is arranged, from left to right or from right to left.
[0086] For example, most languages, such as Chinese, English, Japanese, and Korean, are written from left to right, while a few languages, such as Arabic, are written from right to left.
[0087] In one specific implementation scenario, if the original text is in English and the translated text is in Chinese, then the writing order of both is the same. In another specific implementation scenario, if the original text is in English and the translated text is in Arabic, then the writing order of both is different.
[0088] S223: In response to a different writing order, add first adjustment information to the translated text; wherein the first adjustment information indicates that the translated text needs to be flipped.
[0089] In this embodiment, when the order of writing the book is different, the terminal device needs to flip the translated text based on the first adjustment information when generating the image to meet the reading order.
[0090] Among them, flipping can keep the position information unchanged and only flip the text slice corresponding to the translated text, or it can be a horizontal flip based on the center line of the page layout.
[0091] If the flip is a horizontal flip based on the center line of the page layout, then the remaining patterns that are on the same horizontal line as the translated text will be cut off. Figure 1 Then flip them so that their relative positions remain consistent.
[0092] In some implementations, the first adjustment information is not added in response to the same writing order.
[0093] Understandably, when the server saves the translated text, it adds initial adjustment information to it. This allows the generated image to accommodate both left-to-right and right-to-left writing layouts, avoiding the need to design multiple sets of UI material images and thus saving significant manpower costs.
[0094] S224: Determine whether each translated text overflows relative to the original text.
[0095] In this embodiment, overflow refers to the situation where the same original text occupies different amounts of space in different languages. For example, original text that displays normally in a Chinese environment may overflow in other language environments.
[0096] S225: In response to translation text overflow, add second adjustment information to the translation text; wherein the second adjustment information represents adjustments to the size and / or position of the translation text based on size information and / or position information.
[0097] Understandably, the size information of the newly obtained translated text is consistent with the size information of the original text. If the translated text overflows, the display space corresponding to the original size information cannot fully display the translated text. Therefore, it is necessary to adjust the size information of the translated text to expand the display space of the translated text. At the same time, due to the expansion of the display space, it is also necessary to adjust the position information of the translated text to avoid it occupying the display space of other material slices as much as possible.
[0098] Understandably, dynamically adjusting the size and position information of the translated text based on its overflow can make the generated image clearer and more aesthetically pleasing.
[0099] In some implementations, no second adjustment information is added in response to the translated text not overflowing.
[0100] S226: Store the translated text, first adjustment information, and second adjustment information to build a multilingual library.
[0101] In this embodiment, each translated text and its corresponding adjustment information are stored.
[0102] In this embodiment, after receiving the corresponding user instruction, the server can modify the multilingual library during its use.
[0103] Modification refers to adding or deleting translated text, as well as adjusting the content of translated text.
[0104] S23: Search the material library based on keywords to determine the category tag with the highest matching degree to the keywords.
[0105] In this embodiment, the keyword is compared with multiple category tags stored in the material library of the server to obtain the similarity threshold between each category tag and the keyword, and the category tag with the highest similarity threshold is determined as the category tag with the highest matching degree with the keyword.
[0106] The matching degree between each classification label and keyword can be determined by any of the following similarity algorithms: Cosine Similarity, Euclidean Distance, Pearson Correlation Coefficient, Kullback-Leibler Divergence, Jaccard Coefficient, Tanimoto Coefficient (Generalized Jaccard Similarity Coefficient), and Mutual Information. This application does not limit the specific algorithm used.
[0107] S24: Obtain the corresponding material based on the category tag with the highest matching degree, and obtain the corresponding slice of each material and the annotation information of the slice of the material based on the material.
[0108] S25: Based on the target language identifier, parse out the type of the target language and determine whether there is a corresponding translated text in the multilingual library.
[0109] In this embodiment, after the server parses the type of the target language, it sends a query request to the multilingual library. The query request includes the original text and the corresponding translated text in the target language, so that the multilingual library can determine whether the corresponding translated text exists based on the received query request.
[0110] S26: In response to the existence of translated text in the target language, obtain the translated text in the target language corresponding to the original text in each text slice from the multilingual library.
[0111] In some implementations, in response to the absence of a corresponding target translation text in the multilingual library, a translation request is sent to a preset translation software, so that the translation software converts the original text into the corresponding target language translation text based on the translation request, and the translation text transmitted by the translation software is received.
[0112] The translation software can be Baidu Translate or Google Translate; this application does not limit the choice.
[0113] In some implementations, the translated text transmitted by the translation software can be imported into an Excel file, and then the generated Excel file can be imported into a multilingual library to expand the multilingual library.
[0114] S27: Send each pattern slice and its corresponding annotation information, each translated text and its corresponding text slice annotation information to the terminal device, so that the terminal device can generate an image based on the pattern slice, the translated text and its corresponding annotation information.
[0115] In this embodiment, in response to the translation text corresponding to the first adjustment information and / or the second adjustment information, each pattern slice and its corresponding annotation information, each translation text and its corresponding text slice annotation information, and the first adjustment information and / or the second adjustment information corresponding to the translation text are sent to the terminal device, so that the terminal device generates an image based on the pattern slice, the translation text and its corresponding annotation information, and the first adjustment information and / or the second adjustment information.
[0116] Understandably, the terminal device flips the translated text based on the first adjustment information to make it conform to the reading order of the corresponding language; and adjusts the size and position information of the translated text based on the second adjustment information to make the presentation of the translated text more intuitive and specific, without affecting the overall aesthetics of the image.
[0117] Please see Figure 8 , Figure 8 This is a flowchart illustrating the workflow of building a resource library and a multilingual library on a server in this application. In this embodiment, multiple resources and their corresponding image slices are first imported into the server, and each resource is categorized, with each resource corresponding to at least one category tag. Next, the size information and position information relative to the resource slices are obtained, and the type of each resource slice is determined. The types include image slices and text slices. Then, the size information, position information, and type are used as annotation information for the resource slices, and the resources, category tags, resource slices, and annotation information are stored to build the resource library. Then, based on the original text of each text slice, multiple translated texts corresponding to different language types are generated, and it is determined whether the writing order of each translated text is the same as the original text. In response to a different writing order, first adjustment information is added to the translated text; the first adjustment information indicates that the translated text needs to be flipped. In response to the same writing order, no first adjustment information is added. Finally, it is determined whether each translated text overflows relative to the original text. In response to translation text overflow, second adjustment information is added to the translation text; wherein, the second adjustment information represents adjustments to the size and / or position of the translation text based on size information and / or position information. In response to translation text not overflowing, no second adjustment information is added. The translation text, first adjustment information, and second adjustment information are stored to construct a multilingual library.
[0118] Unlike existing technologies, this implementation method involves a server receiving a material acquisition request from a terminal device and sending the acquired material slices, annotation information, and corresponding target language translations to the terminal device. This allows the terminal device to generate images locally based on the received materials, reducing the number of interactions between the terminal device and the server, thereby lowering the operational complexity and time cost. Furthermore, since the image generation endpoint is switched from the server to the terminal device, server memory usage is reduced, lowering server maintenance costs and consequently reducing image generation costs and improving efficiency. Additionally, by adding first and / or second adjustment information to the translations, the writing order of different languages and the display effect of the translations can be considered simultaneously, thus better supporting the generation of images in multiple languages.
[0119] Please see Figure 9 , Figure 9This is a flowchart illustrating the third embodiment of the image generation method of this application. In this embodiment, the execution subject of the method is a terminal device, and the method includes:
[0120] S31: The terminal device sends a material acquisition request to the server; the material acquisition request includes keywords and target language identifiers.
[0121] In this embodiment, keywords refer to the descriptive language of content that the user is interested in, which is received by the terminal device, and target language identifier refers to the parameters for obtaining the target language.
[0122] The target language can be any language corresponding to any country, such as Chinese, English, Arabic, etc., and this application does not limit it.
[0123] Specifically, the terminal device generates a request header carrying target language identifiers and keywords based on the user's input instructions, and sends the request header as a material acquisition request to the server.
[0124] The request header refers to the parameter description of the transmitted resources by the client and the server during the transmission process.
[0125] Specifically, the terminal device sends a material acquisition request to the server, so that the server can obtain each material slice and its annotation information based on keywords, and obtain the translated text of the target language corresponding to the original text in each text slice based on the target language identifier.
[0126] S32: Receive each material slice and its annotation information from the server, which are obtained based on keywords. The annotation information includes the position information of the material slice relative to the material. The material slice includes pattern slices and text slices.
[0127] Here, "materials" refers to UI (User Interface) design drafts, and "material slices" refers to each sliced element obtained after slicing the UI design drafts.
[0128] The location information can be a specific location feature vector or the relative distance of the material slice relative to a preset anchor point (such as the top left corner of the page or two adjacent sides of the page). This application does not limit this.
[0129] Among them, image slices refer to slice elements that are primarily graphic, while text slices refer to slice elements that are primarily text. Understandably, only text slices need to support multilingual display.
[0130] S33: Receive the translated text of the target language corresponding to the original text in each text slice obtained based on the target language identifier sent by the server.
[0131] S34: Generate an image based on pattern cutouts, translated text, and corresponding annotation information.
[0132] In this embodiment, the terminal device arranges each pattern slice and each translated text on the page based on the position information corresponding to each pattern slice and the position information corresponding to each translated text, thereby generating an image with the target language.
[0133] Understandably, since image generation is implemented on the terminal device, the server is only used to store the materials, the corresponding image slices, the translated text of the text slices, and the data transmission, which can greatly reduce the server's operating memory.
[0134] Unlike existing technologies, this implementation method involves a server receiving a material acquisition request from a terminal device and then sending the acquired material slices, annotation information, and corresponding target language translations to the terminal device. This allows the terminal device to generate images locally based on the received materials, reducing the number of interactions between the terminal device and the server, thereby lowering the operational complexity and time cost during interactions. Furthermore, since the image generation endpoint is switched from the server to the terminal device, the server's operating memory is reduced, thus lowering server maintenance costs, which in turn reduces the cost of image generation and improves image generation efficiency.
[0135] Please see Figure 10 , Figure 10 This is a flowchart illustrating the fourth embodiment of the image generation method of this application. In this embodiment, the execution subject of the method is a terminal device, and the method includes:
[0136] S41: The terminal device sends a material acquisition request to the server; the material acquisition request includes keywords and target language identifiers.
[0137] Please refer to the description in S31 for the specific process, which will not be repeated here.
[0138] S42: Receive each material slice and its annotation information from the server, which are obtained based on keywords. The annotation information includes the position information of the material slice relative to the material. The material slice includes pattern slices and text slices.
[0139] Please refer to the description in S32 for the specific process, which will not be repeated here.
[0140] S43: Receive the translated text of the target language corresponding to the original text in each text slice obtained based on the target language identifier sent by the server.
[0141] S44: Generate an image based on pattern cutouts, translated text, and corresponding annotation information.
[0142] Please refer to the description in S34 for the specific process, which will not be repeated here.
[0143] S45: Received user instruction; wherein the user instruction includes adding a new pattern at a preset position in the image to be generated.
[0144] In this embodiment, the user instruction includes user-inputted custom data, namely, adding a new pattern to a preset position in the image to be generated. The new pattern can be a watermark or a QR code; this application does not limit this.
[0145] S46: Add the new pattern to the preset position according to the user's instructions.
[0146] In existing technologies, if custom data needs to be added to an image, the terminal device needs to send the custom data to the server so that the server can generate an image based on the custom data and the original material images, and then return the image to the terminal device. This requires multiple interactions between the terminal device and the server.
[0147] Please see Figure 11 , Figure 11 This is a flowchart illustrating the application scenario of the image generation method of this application. In this embodiment, the terminal device first sends a material acquisition request to the server. The material acquisition request includes keywords and a target language identifier, enabling the server to obtain each material slice and its annotation information based on the keywords, and to obtain the translated text in the target language corresponding to the original text in each text slice based on the target language identifier. The terminal device then receives each material slice and its annotation information obtained based on the keywords. The annotation information includes the position information of the material slice relative to the material, and the material slice includes pattern slices and text slices. The terminal device also receives the translated text in the target language corresponding to the original text in each text slice obtained based on the target language identifier from the server. Next, an image is generated based on the pattern slices, the translated text, and the corresponding annotation information. Then, it determines whether a user instruction has been received, whereby the user instruction includes adding a new pattern to a preset position in the image to be generated. In response to receiving the user instruction, the new pattern is added to the preset position according to the user instruction to generate the image.
[0148] Unlike existing technologies, in this embodiment, after receiving custom data, the terminal device can directly generate images based on the materials returned by the server and the custom data. This reduces the number of interactions between the terminal device and the server, thereby reducing the operational difficulty and time cost during interaction. Furthermore, since the image generation end is switched from the server to the terminal device, the server's operating memory can be reduced, thus lowering server maintenance costs, which in turn reduces the cost of image generation and improves image generation efficiency.
[0149] Please see Figure 12 , Figure 12 This is a flowchart illustrating the fifth embodiment of the image generation method of this application. In this embodiment, the executing entity of the method is a terminal device, and the method includes:
[0150] S51: The terminal device sends a material acquisition request to the server; the material acquisition request includes keywords and target language identifiers.
[0151] Please refer to the description in S31 for the specific process, which will not be repeated here.
[0152] S52: Receive each material slice and its annotation information from the server, which are obtained based on keywords. The annotation information includes the position information of the material slice relative to the material. The material slice includes pattern slices and text slices.
[0153] Please refer to the description in S32 for the specific process, which will not be repeated here.
[0154] S53: Receive the translated text of the target language corresponding to the original text in each text slice obtained based on the target language identifier sent by the server.
[0155] S54: Generate images based on pattern cutouts, translated text, and corresponding annotation information.
[0156] Please refer to the description in S34 for the specific process, which will not be repeated here.
[0157] S55: Send a language switching request to the server; the language switching request includes a new target language identifier.
[0158] In this embodiment, after the terminal device generates an image in the corresponding language based on the previously acquired material images and translated text, if it needs to generate an image in a new language, it sends a language switching request to the server.
[0159] The language switching request only includes the new target language identifier, so that the server can obtain the new translated text in the corresponding new target language based on the new target language identifier.
[0160] S56: Receive the new translated text in the new target language for each original text obtained based on the new target language identifier sent by the server.
[0161] S57: Generate images based on pattern cutouts, new translated text, and corresponding annotation information.
[0162] In this embodiment, the terminal device generates an image based on the previously received pattern slices and the newly received translated text, thus obtaining a new version of the language image.
[0163] Understandably, since when switching languages, the terminal device only needs to send a request to the server to obtain the new translation version, without having to re-obtain the source images, the process of generating images for the new language version can be simplified, thereby improving the efficiency of image generation.
[0164] In this embodiment, if the translated text received by the terminal device includes first adjustment information and / or second adjustment information, the translated text is flipped based on the first adjustment information to make it conform to the reading order of the corresponding language, and / or the size information and position information of the translated text are adjusted based on the second adjustment information to make the presentation of the translated text more intuitive and specific, without affecting the overall aesthetics of the image.
[0165] Specifically, please refer to Figure 13 , Figure 13 This is a schematic diagram illustrating how the terminal device of this application generates corresponding images based on material slices and translated text. In this embodiment, the left side represents the material (UI design drawing) stored on the server. The material includes two pattern slices on the right and three text slices on the left, with the original text in the text slices being in English. In response to the target language identifier being Arabic, since the writing order of Arabic is reversed compared to English, the acquired translated text is flipped. The flipping of the translated text in the lower left and middle left maintains the positional information and only flips itself. The translated text in the upper left is horizontally flipped based on the center line of the page layout, changing from the left to the right. Therefore, the pattern slice originally located in the upper right on the same horizontal line is also flipped, changing from the right to the left, but the relative positional relationship between the two remains consistent.
[0166] Unlike existing technologies, this implementation method involves a server receiving a material acquisition request from a terminal device and then sending the acquired material slices, annotation information, and corresponding target language translations to the terminal device. This allows the terminal device to generate images locally based on the received materials, reducing the number of interactions between the terminal device and the server, thereby lowering the operational complexity and time cost during interactions. Furthermore, since the image generation endpoint is switched from the server to the terminal device, the server's operating memory is reduced, thus lowering server maintenance costs, which in turn reduces the cost of image generation and improves image generation efficiency.
[0167] Correspondingly, this application provides related apparatus for an image generation method.
[0168] Please see Figure 14 , Figure 14 This is a schematic diagram of one embodiment of the server in this application. In this embodiment, the server 60 includes a first receiving module 61, a material image acquisition module 62, a translated text acquisition module 63, and a first sending module 64.
[0169] The first receiving module 61 is used to receive a material acquisition request sent by the terminal device; wherein the material acquisition request includes keywords and target language identifiers.
[0170] The material slice acquisition module 62 retrieves each material slice and its annotation information based on keywords; the annotation information includes the position information of the material slice relative to the material; the material slices include pattern slices and text slices.
[0171] The translation text acquisition module 63 is used to obtain the translation text of the target language corresponding to the original text in each text slice based on the target language identifier.
[0172] The first sending module 64 is used to send each pattern slice and its corresponding annotation information, each translated text and its corresponding text slice annotation information to the terminal device, so that the terminal device can generate an image based on the pattern slice, the translated text and its corresponding annotation information.
[0173] For details of the process, please refer to the relevant textual descriptions in S11~S14, S21~S27, S211~S214 and S221~S226, which will not be repeated here.
[0174] Please see Figure 15 , Figure 15 This is a schematic diagram of one embodiment of the terminal device of this application. In this embodiment, the terminal device 70 includes a second sending module 71, a material image receiving module 72, a translated text receiving module 73, and a generation module 74.
[0175] The second sending module 71 is used to send a material acquisition request to the server; wherein, the material acquisition request includes keywords and target language identifiers.
[0176] The material slice receiving module 72 is used to receive each material slice of the corresponding material obtained based on keywords and the annotation information of the material slice sent by the server; wherein, the annotation information includes the position information of the material slice relative to the material; the material slice includes pattern slices and text slices.
[0177] The translation text receiving module 73 is used to receive the translated text in the target language corresponding to the original text in each text slice obtained based on the target language identifier sent by the server.
[0178] The generation module 74 is used to generate images based on pattern cutouts, translated text, and corresponding annotation information.
[0179] Unlike existing technologies, this application receives material acquisition requests from terminal device 70 via server 60, and sends the obtained material slices, annotation information, and corresponding target language translations to terminal device 70. This allows terminal device 70 to generate images locally based on the received materials, reducing the number of interactions between terminal device 70 and server 60, thereby lowering the operational difficulty and time cost during interactions. Furthermore, since the image generation endpoint is switched from server 60 to terminal device 70, the operating memory of server 60 can be reduced, thereby lowering the maintenance cost of server 60, which in turn reduces the cost of image generation and improves the efficiency of image generation.
[0180] Correspondingly, this application provides an electronic device.
[0181] Please see Figure 16 , Figure 16 This is a schematic diagram of one embodiment of the electronic device of this application. For example... Figure 16 As shown, in this embodiment, the electronic device 80 includes a memory 81 and a processor 82.
[0182] In this embodiment, the memory 81 is used to store program data, and when the program data is executed, it implements the steps in the image generation method described above; the processor 82 is used to execute the program instructions stored in the memory 81 to implement the steps in the image generation method described above.
[0183] Specifically, processor 82 controls itself and memory 81 to implement the steps in the image generation method described above. Processor 82 can also be called a CPU (Central Processing Unit). Processor 82 may be an integrated circuit chip with signal processing capabilities. Processor 82 can also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. Furthermore, processor 82 can be implemented using multiple integrated circuit chips.
[0184] Unlike existing technologies, this implementation receives material acquisition requests from terminal devices via processor 82, and sends the obtained material slices, annotation information, and corresponding target language translations to the terminal devices. This allows the terminal devices to generate images locally based on the received materials, reducing the number of interactions between the terminal devices and the server, thereby lowering the operational complexity and time costs during interactions. Furthermore, since the image generation endpoint is switched from the server to the terminal device, the server's operating memory is reduced, thus lowering server maintenance costs, which in turn reduces image generation costs and improves image generation efficiency.
[0185] Correspondingly, this application provides a computer-readable storage medium.
[0186] Please see Figure 17 , Figure 17 This is a schematic diagram of one embodiment of the computer-readable storage medium of this application.
[0187] The computer-readable storage medium 90 includes a computer program 901 stored on it. When executed by the aforementioned processor, the computer program 901 implements the steps in the image generation method described above. Specifically, if the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium 90. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a computer-readable storage medium 90 and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned computer-readable storage medium 90 includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0188] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0189] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0190] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0191] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0192] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
[0193] If the technical solution of this application involves personal information, the product using this technical solution has clearly informed the user of the personal information processing rules and obtained the user's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using this technical solution has obtained the user's separate consent before processing the sensitive personal information, and also meets the requirement of "express consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set up to inform users that they have entered the scope of personal information collection and that personal information will be collected. If an individual voluntarily enters the collection scope, it is deemed that they have agreed to the collection of their personal information; or on the personal information processing device, with clear signs / information informing users of the personal information processing rules, authorization is obtained from the individual through pop-up information or by asking the individual to upload their personal information; wherein, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the types of personal information processed.
Claims
1. A method for generating an image, characterized in that, include: The server receives a material acquisition request sent by the terminal device; wherein the material acquisition request includes keywords and target language identifiers; the server includes a material library and a multilingual library; the material library stores multiple materials and corresponding material slices and annotation information, the material slices include image slices and text slices; the multilingual library stores multiple translated texts in different languages corresponding to the original text in each text slice; wherein, in response to the translation text having a different writing order from the original text and / or the translation text overflowing relative to the original text, the multilingual library stores first adjustment information and / or second adjustment information corresponding to the translation text; Based on the keywords, each slice of the corresponding material and the annotation information of the slice are obtained; wherein, the annotation information includes the position information of the slice relative to the material; Based on the target language identifier, obtain the translated text of the target language corresponding to the original text in each text slice; Sending each of the pattern slices and the corresponding annotation information, each of the translated texts and the annotation information of the text slices corresponding to the translated texts to the terminal device, so that the terminal device generates an image based on the pattern slices, the translated texts and the corresponding annotation information, including: in response to the translated texts corresponding to the first adjustment information and / or the second adjustment information, causing the terminal device to generate an image based on the pattern slices, the translated texts and the corresponding annotation information, the first adjustment information and / or the second adjustment information.
2. The image generation method according to claim 1, characterized in that, Before the server receives the material acquisition request sent by the terminal device, the following steps are included: The material library is established on the server; wherein the material library stores multiple materials, as well as the corresponding material slices and annotation information, and each material carries at least one category tag; and, The multilingual library is established in the server; wherein, the multilingual library stores multiple translated texts of different types of languages corresponding to the original text in each text slice; The step of obtaining each material slice and its annotation information based on the keyword includes: Based on the keywords, a query is performed in the material library to determine the category tag with the highest matching degree to the keywords; The corresponding material is obtained based on the category tag with the highest matching degree, and the corresponding slice of each material and the annotation information of the material slice are obtained based on the material; The step of obtaining the translated text of the target language corresponding to the original text in each text slice based on the target language identifier includes: Based on the target language identifier, the type of the target language is parsed, and it is determined whether there is translated text corresponding to the target language in the multilingual library; In response to the existence of the translated text corresponding to the target language, the translated text corresponding to the target language of the original text in each text slice is obtained from the multilingual library.
3. The image generation method according to claim 2, characterized in that, The step of establishing the material library in the server includes: Import multiple images of the aforementioned materials and corresponding slices of those materials into the server. Each of the aforementioned materials is categorized; wherein each of the aforementioned materials corresponds to at least one of the aforementioned category tags; The size information and position information of each material slice are obtained, and the type of each material slice is determined; wherein, the type includes the pattern slice and the text slice; The size information, location information, and type are used as the annotation information for the material slices, and the material, the category tags, the material slices, and the annotation information are stored to construct the material library.
4. The image generation method according to claim 3, characterized in that, The step of establishing the multilingual library in the server includes: Based on each of the text slices, generate multiple translated texts corresponding to different types of languages from the original text; Determine whether the writing order of each translated text is the same as that of the original text; In response to the different writing order, the first adjustment information is added to the translated text; wherein the first adjustment information indicates that the translated text needs to be flipped. Determine whether each translated text overflows relative to the original text; In response to the overflow of the translated text, the second adjustment information is added to the translated text; wherein, the second adjustment information represents an adjustment of the size and / or position of the translated text based on the size information and / or the position information; The translated text, the first adjustment information, and the second adjustment information are stored to construct the multilingual library.
5. The image generation method according to claim 4, characterized in that, After obtaining the translated text of the target language corresponding to the original text in each text slice based on the target language identifier, the process includes: Determine whether the translated text corresponds to the first adjustment information and / or the second adjustment information; In response to the translated text corresponding to the first adjustment information and / or the second adjustment information, the step of sending each of the pattern slices and the corresponding annotation information, each of the translated texts and the annotation information of the text slices corresponding to the translated texts to the terminal device, so that the terminal device generates an image based on the pattern slices, the translated texts and the corresponding annotation information, includes: Each of the pattern slices and the corresponding annotation information, each of the translated texts and the annotation information of the text slices corresponding to the translated texts, the first adjustment information and / or the second adjustment information corresponding to the translated texts are sent to the terminal device, so that the terminal device generates an image based on the pattern slices, the translated texts and the corresponding annotation information, the first adjustment information and / or the second adjustment information.
6. A method for generating an image, characterized in that, include: The terminal device sends a material acquisition request to the server; wherein, the material acquisition request includes keywords and target language identifiers; the server includes a material library and a multilingual library; the material library stores multiple materials and corresponding material slices and annotation information, the material slices include image slices and text slices; the multilingual library stores multiple translated texts in different languages corresponding to the original text in each text slice; wherein, in response to the translated text having a different writing order from the original and / or the translated text overflowing relative to the original text, the multilingual library stores first adjustment information and / or second adjustment information corresponding to the translated text; The system receives each image slice of the corresponding material obtained based on the keyword, along with annotation information for the image slices, sent by the server. The annotation information includes the positional information of the image slice relative to the material. The image slices include both pattern slices and text slices. Receive the translated text of the target language corresponding to the original text in each text slice obtained based on the target language identifier, sent by the server; Image generation based on the pattern cutout, the translated text, and the corresponding annotation information includes: if the translated text received by the terminal device includes the first adjustment information and / or the second adjustment information, image generation is performed based on the pattern cutout, the translated text, the corresponding annotation information, the first adjustment information, and / or the second adjustment information.
7. The image generation method according to claim 6, characterized in that, After the step of generating an image based on the pattern cutout, the translated text, and the corresponding annotation information, the following steps are included: A user instruction is received; wherein the user instruction includes adding a new pattern at a preset position in the image to be generated; The new pattern is added to the preset position according to the user's instructions.
8. The image generation method according to claim 6, characterized in that, After the step of generating an image based on the pattern cutout, the translated text, and the corresponding annotation information, the following steps are included: Send a language switching request to the server; wherein the language switching request includes a new target language identifier; Receive new translated text in the new target language for each original text obtained based on the new target language identifier from the server; An image is generated based on the pattern cutout, the new translated text, and the corresponding annotation information.
9. An electronic device, characterized in that, include: A memory for storing program data, wherein the stored program data, when executed, implements the steps of the image generation method as described in any one of claims 1 to 5 or the image generation method as described in any one of claims 6 to 8; A processor is configured to execute program instructions stored in the memory to implement the steps of the image generation method as described in any one of claims 1 to 5 or the image generation method as described in any one of claims 6 to 8.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the image generation method as described in any one of claims 1 to 5 or the image generation method as described in any one of claims 6 to 8.
Citation Information
Patent Citations
Webpage translation method and related equipment
CN114791987A
