A processing method, apparatus and electronic device

By extracting style codes from a small sample set through a self-attention mechanism, the problem of time-consuming and labor-intensive generation of artistic fonts in existing technologies is solved, and the effect of generating artistic fonts with high efficiency is achieved.

CN115983197BActive Publication Date: 2026-11-24LENOVO (BEIJING) LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211693680.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-28
Publication Date
2026-11-24
Estimated Expiration
2042-12-28

AI Technical Summary

Technical Problem

In the process of generating artistic font libraries, existing technologies require individual design for each Chinese character, which is time-consuming and labor-intensive. Furthermore, neural networks in deep learning have low efficiency in utilizing existing information, making it difficult to extract key style information from a small number of artistic fonts.

Method used

A self-attention mechanism is used to extract style codes from a small sample set and map them onto the content codes of the object to be transformed, thereby generating artistic fonts with specific styles.

Benefits of technology

It greatly saves the time and manpower costs of building artistic font libraries, reduces the difficulty of generating artistic font libraries, and only requires a small number of samples to generate a complete artistic font library.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115983197B_ABST
    Figure CN115983197B_ABST
Patent Text Reader

Abstract

This application discloses a processing method, apparatus, and electronic device. The method includes: obtaining a small sample set, wherein each sample object in the small sample set has a first style; performing style recognition and extraction on the sample objects in the small sample set based on a self-attention mechanism to obtain a style code; obtaining a content code of an object to be converted in a second style; and mapping the style code onto the content code to obtain a conversion object of the first style. In implementation, this solution can extract the corresponding style code of the first style from a small number of samples of the first style based on a self-attention mechanism, and then map the obtained style code onto a standard font to obtain a conversion object of the first style. Compared to the current implementation that requires a large number of samples for network training, this solution greatly saves the time and manpower costs of building an artistic font library and reduces the difficulty of building such a library.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to data processing technology, and more specifically, to a processing method, apparatus, and electronic device. Background Technology

[0002] In the course of the development of traditional culture, different calligraphic styles, such as running script, regular script, cursive script, and clerical script, gradually emerged. In today's era of rapid computer development, digitization is gradually replacing the traditional paper-and-pen method as the information carrier of the new era. How to preserve the essence of these traditional cultural elements during the digitization process has become an urgent problem to be solved.

[0003] Calligraphy art is often preserved in the form of computer fonts. In the traditional process of generating computer artistic fonts (such as fonts for specific calligraphic works), designers need to design each character individually to ensure a unified style and format. The national unified Chinese character standard GB2312 contains 6763 characters. A complete artistic font library should include all of them; therefore, the font creation process requires individual design for each character, making it a time-consuming and labor-intensive task. Summary of the Invention

[0004] In view of the above, this application provides the following technical solution:

[0005] A processing method includes:

[0006] Obtain a small sample set, wherein each sample object in the small sample set has a first style;

[0007] Style recognition and extraction are performed on sample objects in the small sample set based on a self-attention mechanism to obtain style codes;

[0008] Obtain the content encoding of the object to be converted in the second style;

[0009] The style encoding is mapped onto the content encoding to obtain the transformation object of the first style.

[0010] Optionally, the algorithm based on the self-attention structure performs style recognition and extraction on the sample objects in the small sample set to obtain style codes, including:

[0011] Style recognition and extraction are performed on the sample objects in the small sample set to obtain the encoding matrix corresponding to the self-attention structure;

[0012] The encoding matrix is ​​processed by an algorithm based on a self-attention structure to obtain style codes.

[0013] Optionally, the step of performing style recognition extraction on sample objects in the small sample set to obtain an encoding matrix corresponding to the self-attention structure includes:

[0014] For each sample object in the small sample set: style recognition extraction is performed on the sample object by three encoding structures corresponding to the query parameter, key parameter and value parameter of the self-attention structure, respectively, to obtain three encoding matrices corresponding to the query parameter, key parameter and value parameter respectively;

[0015] The mean matrix of all corresponding query parameters is obtained by averaging the encoding matrices. The mean matrix of all corresponding key parameters is obtained by averaging the encoding matrices. The mean matrix of all corresponding value parameters is obtained by averaging the encoding matrices.

[0016] Optionally, the algorithm based on the self-attention structure processes the encoding matrix to obtain style encoding, including:

[0017] The mean matrix of the query parameters and the mean matrix of the key parameters are subjected to a first processing to obtain a first processing result;

[0018] The first processing result is combined with the mean matrix of the value parameter to perform a second processing to obtain the style code.

[0019] Optionally, the first processing of the mean matrix of the query parameters and the mean matrix of the key parameters to obtain a first processing result includes:

[0020] Perform matrix multiplication on the mean matrix of the query parameters and the mean matrix of the key parameters to obtain the matrix multiplication result;

[0021] The matrix multiplication result is normalized to obtain the first processing result.

[0022] Optionally, the second processing of the first processing result and the mean matrix of the corresponding value parameter to obtain style encoding information includes:

[0023] The style code is obtained by multiplying the first processing result with the mean matrix of the value parameter.

[0024] Optionally, obtaining the content encoding of the object to be converted in the second style includes:

[0025] Content encoding is obtained by performing convolution on the object to be converted in the second style.

[0026] This application also discloses a processing apparatus, comprising:

[0027] The sample acquisition module is used to acquire a small sample set, wherein each sample object in the small sample set has a first style;

[0028] The style extraction module is used to perform style recognition and extraction on sample objects in the small sample set based on a self-attention mechanism to obtain style codes.

[0029] The content acquisition module is used to obtain the content encoding of the object to be converted in the second style;

[0030] The style conversion module is used to map the style encoding onto the content encoding to obtain the conversion object of the first style.

[0031] Optionally, the style extraction module includes:

[0032] The matrix extraction module is used to perform style recognition extraction on the sample objects in the small sample set to obtain the encoding matrix corresponding to the self-attention structure.

[0033] The style acquisition module is used to process the encoding matrix based on a self-attention structure algorithm to obtain style encoding.

[0034] Furthermore, this application also discloses an electronic device, including:

[0035] processor;

[0036] Memory for storing executable program instructions of the processor;

[0037] The executable program instructions include: obtaining a small sample set, wherein each sample object in the small sample set has a first style; performing style recognition and extraction on the sample objects in the small sample set based on a self-attention mechanism to obtain a style code; obtaining the content code of the object to be converted in a second style; and mapping the style code onto the content code to obtain the object to be converted in the first style.

[0038] As can be seen from the above technical solutions, compared with the prior art, the embodiments of this application disclose a processing method, apparatus, and electronic device. The method includes: obtaining a small sample set, wherein each sample object in the small sample set has a first style; performing style recognition and extraction on the sample objects in the small sample set based on a self-attention mechanism to obtain a style code; obtaining a content code of the object to be converted in a second style; and mapping the style code onto the content code to obtain the converted object of the first style. In the implementation process of the above solution, the style code corresponding to the first style can be extracted from a small number of samples of the first style based on a self-attention mechanism, and then the obtained style code can be mapped onto a standard font to obtain the converted object of the first style. Compared with the current implementation that requires a large number of samples for network training, this solution greatly saves the time and manpower costs of building an artistic font library and reduces the difficulty of building an artistic font library. Attached Figure Description

[0039] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0040] Figure 1 This is a flowchart of a processing method disclosed in an embodiment of this application;

[0041] Figure 2 This is a flowchart illustrating the process of obtaining style codes as disclosed in an embodiment of this application;

[0042] Figure 3 This is a flowchart illustrating the process of obtaining the encoding matrix as disclosed in an embodiment of this application;

[0043] Figure 4 This is a flowchart illustrating the process of obtaining style encoding based on an encoding matrix, as disclosed in an embodiment of this application.

[0044] Figure 5 This is a schematic diagram illustrating the implementation process of the method for generating artistic fonts disclosed in an embodiment of this application;

[0045] Figure 6 This is a schematic diagram illustrating the working principle of the artistic font style extraction disclosed in the embodiments of this application;

[0046] Figure 7 This is a schematic diagram of the structure of a processing device disclosed in an embodiment of this application;

[0047] Figure 8 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application. Detailed Implementation

[0048] 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.

[0049] The embodiments of this application can be applied to electronic devices. This application does not limit the product form of the electronic device, which may include but is not limited to smartphones, tablets, wearable devices, personal computers (PCs), netbooks, etc., and can be selected according to application requirements.

[0050] To better understand the embodiments of this application, some background information related to the implementation of this application's solution will first be introduced. Currently, one deep learning-based implementation scheme for generating artistic font libraries uses adversarial networks to transfer font styles. The adversarial network learns the style of artistic fonts and transfers this style to existing fonts, thereby generating a new artistic font library. This scheme requires training the adversarial network to learn the style of specific artistic fonts; training is required for each font. During training, to ensure good results for the artistic fonts generated after style transfer, hundreds of artistic fonts are often needed for training. However, in real life, obtaining hundreds of artistic fonts with the same style is extremely difficult; typically, only a few dozen artistic fonts can be obtained from calligraphy works. If only a few dozen artistic fonts are used for training, the resulting artistic font effect cannot meet the requirements for creating a font library.

[0051] A major reason for the aforementioned problems is that current deep learning neural networks have low efficiency in utilizing existing information, making it difficult to fully mine the deeper content of data. When extracting artistic font style information, key style information is not extracted; instead, a large amount of style-irrelevant information is included. Therefore, a large amount of data accumulation is needed, and continuous trial and error optimization is required to achieve better results. This application provides a method for obtaining a complete font library corresponding to a certain style using a small number of font samples of that style.

[0052] Figure 1 This is a flowchart illustrating a processing method disclosed in an embodiment of this application. See also... Figure 1 As shown, the processing method may include:

[0053] Step 101: Obtain a small sample set, wherein each sample object in the small sample set has a first style.

[0054] The small sample set contains only a limited number of sample objects, and there is no fixed limit to the number of sample objects. These can be font samples with a primary style obtained from one or several calligraphy works. In practice, the number of sample objects in the small sample set can be dozens. Naturally, the more sample objects there are, the more accurate the style code obtained based on them will be. To ensure at least a basic level of accuracy in style coding, the number of sample objects in the small sample set should be at least a dozen.

[0055] In this embodiment, each sample object in the small sample set has a first style, which is a font style for which a complete font library does not yet exist. The sample object can be text or a string, and can correspond to any language. Furthermore, all sample objects in the small sample set are different; that is, the sample objects in the small sample set correspond to different texts or strings, thereby ensuring that different style features can be extracted from different texts or strings.

[0056] Step 102: Based on the self-attention mechanism, perform style recognition and extraction on the sample objects in the small sample set to obtain style codes.

[0057] The self-attention mechanism allows the corresponding algorithm to focus only on the characteristics of different positions, strokes / characters of the sample object itself, while weakening the structure of each part of the font and the correlation between different fonts. Therefore, it can effectively extract the style information contained in different positions, strokes / characters from a small number of artistic fonts, remove the font structure information, and make the obtained style code more effectively used by the decoding module.

[0058] This application's embodiments are based on adversarial networks, combined with an algorithm based on a self-attention structure to extract style information from a small number of artistic fonts, forming a high-level style code corresponding to global style information. The specific implementation of obtaining the style code will be described in detail in later embodiments, and will not be elaborated on here.

[0059] Step 103: Obtain the content encoding of the object to be converted in the second style.

[0060] The second style can be understood as the standard style, that is, the original, basic style without any stylistic features. For example, if the sample object is Chinese characters, then the second style could be boldface. The style conversion of the object to be transformed involves transferring the first style to the standard boldface, making it Chinese characters with the first style.

[0061] In one implementation, obtaining the content encoding of the object to be converted in the second style may include: obtaining the content encoding by performing a convolution process on the object to be converted in the second style. The specific implementation of this part will be described in detail in later embodiments.

[0062] Step 104: mapping the style code to the content code to obtain a transformed object of the first style.

[0063] In this embodiment, after obtaining the style code of the sample object and the content code of the object to be transformed, the style code may be mapped to the content code, that is, the style characteristics of the first style are migrated to the content code of the object to be transformed, to obtain the transformed object of the first style. For example, if the object to be transformed is the Chinese character "周" and the first style is FZShuTi, then the transformed font is "周"; or, if the object to be transformed is the string "Description" and the first style is Arial Unicode MS, then the transformed string is "Description".

[0064] In practical applications, to generate a complete font library of the first style, the extracted font style (i.e., the style code) may be sequentially mapped to the content codes of all fonts in the font library that do not have a corresponding style, to obtain a font of the first style containing all Chinese characters / strings required by the font library.

[0065] This solution is used for font library generation of artistic characters, which can save time and labor costs for font library designers. With this solution, users only need to design or obtain some artistic characters with the same style, and then use this solution to generate an artistic character font library. Compared with the traditional artistic character font library generation solution based on adversarial networks, this solution greatly reduces the number of artistic characters required for training the adversarial network, and only 10 to 20 artistic characters with the same style are needed to generate an artistic character font library; in addition, compared with the traditional artistic character font library generation solution based on adversarial networks, this solution does not require separate training for different artistic character fonts, so the solution not only reduces the difficulty of generating an artistic character font library, but also greatly improves the efficiency of generating an artistic character font library.

[0066] The processing method described in this embodiment is implemented based on a self-attention mechanism, extracts a style code corresponding to the first style from a small number of samples of the first style, and then maps the obtained style code to a standard font to obtain a transformed object of the first style. Compared with current implementations that require a large number of samples for network training, this solution greatly saves the time and labor costs for constructing an artistic character font library and reduces the difficulty of constructing an artistic character font library.

[0067] Figure 2 is a flowchart illustrating obtaining a style code according to an embodiment of the present application. In conjunction with Figure 2 as shown, the performing, by the algorithm based on a self-attention structure, style recognition and extraction on sample objects in the small sample set to obtain a style code may include:

[0068] Step 201: Perform style recognition extraction on the sample objects in the small sample set to obtain the encoding matrix corresponding to the self-attention structure.

[0069] Those skilled in the art know that a self-attention structure includes three matrices: query, key, and value. In order to enable subsequent computational processing based on the self-attention algorithm, when performing style recognition extraction on sample objects in a small sample set, it is necessary to process them into encoding matrices corresponding to the three matrices of the self-attention structure.

[0070] For a detailed implementation of step 201, please refer to [link / reference]. Figure 3 . Figure 3 This is a flowchart illustrating the process of obtaining the encoding matrix as disclosed in an embodiment of this application. (In conjunction with...) Figure 3 It can include:

[0071] Step 301: For each sample object in the small sample set: perform style recognition extraction on the sample object by using three encoding structures corresponding to the query parameter, key parameter and value parameter of the self-attention structure, respectively, to obtain three encoding matrices corresponding to the query parameter, key parameter and value parameter, respectively.

[0072] Step 302: Perform an average operation on the encoding matrices of all corresponding query parameters to obtain the query parameter mean matrix; perform an average operation on the encoding matrices of all corresponding key parameters to obtain the key parameter mean matrix; and perform an average operation on the encoding matrices of all corresponding value parameters to obtain the value parameter mean matrix.

[0073] In other words, for each sample object, the query parameter, key parameter, and value parameter are extracted separately. For example, if a small sample set includes 15 sample objects, then 15 query parameters, 15 key parameters, and 15 value parameters are obtained. Then, the average of all query parameters is taken as the final query parameter value, the average of all key parameters is taken as the final key parameter value, and the average of all value parameters is taken as the final value parameter value. By taking the average, the final parameter results are made more objective and accurate, providing a foundation for obtaining more accurate style codes.

[0074] After step 201, proceed to step 202.

[0075] Step 202: Process the encoding matrix using an algorithm based on a self-attention structure to obtain style encoding.

[0076] Figure 4This is a flowchart illustrating the process of obtaining style encoding based on an encoding matrix, as disclosed in an embodiment of this application. See also... Figure 4 As shown, the algorithm based on the self-attention structure processes the encoding matrix to obtain style encoding, which may include:

[0077] Step 401: Perform a first processing on the mean matrix of the query parameters and the mean matrix of the key parameters to obtain a first processing result.

[0078] In one implementation, step 401 may include: performing matrix multiplication on the mean matrix of the query parameters and the mean matrix of the key parameters to obtain a matrix multiplication result; and normalizing the matrix multiplication result to obtain a first processing result.

[0079] Step 402: Perform a second processing on the first processing result and the mean matrix of the value parameter to obtain the style code.

[0080] In one implementation, step 402 may include: multiplying the first processing result with the mean matrix of the value parameter to obtain the style code.

[0081] This application's solution is based on adversarial networks and combines an algorithm based on a self-attention structure to extract style information from a small number of artistic fonts, forming a high-level style code. This style code is then used with a self-attention structure to obtain global style information, which is fed into a generator for decoding, thereby generating corresponding Chinese characters with the style of the artistic font. Through the self-attention structure, the model can further mine the content at different positions of the artistic font, effectively obtaining the actual style information of the font. Based on generating a single artistic font, this method can generate all 6763 Chinese characters with the style of the national standard GB2312. This saves manpower and time costs in font design and reduces the difficulty of obtaining artistic fonts.

[0082] To better understand the implementation of this application, a specific example using Chinese characters will be given below.

[0083] Figure 5 This is a schematic diagram illustrating the implementation flow of the method for generating artistic fonts disclosed in an embodiment of this application. Combined with... Figure 5 As shown, the method implementation model consists of four parts: a content encoder, a style encoder, a self-attention structure, and a generator. The style encoder-self-attention structure is used to extract the font style of the artistic font. Combined with... Figure 5The style encoder and self-attention structure extract style codes from more than a dozen artistic fonts (including "stone" and "mountain" shown in the figure); the content encoder obtains the content code of the object to be transformed, "have"; finally, the generator decodes the style code obtained by the style encoder and self-attention structure and the content code obtained by the content encoder to obtain "have" with the same style as "stone" and "mountain" in the figure.

[0084] The content encoder includes a four-convolutional-adaptive instance regularization-ReLU activation layer structure, as well as a residual module constructed from two double convolutional layers. Each residual module contains a cross-layer connection structure between the two convolutional layers. The content encoder encodes the content of words into a high-dimensional content encoding through convolution.

[0085] The style encoder comprises three sub-encoders with similar network structures but different parameters, corresponding to the query, key, and value matrices of the self-attention structure, respectively, and are called the Query sub-encoder, Key sub-encoder, and Value sub-encoder. Each sub-encoder consists of a five-layer convolutional layer-adaptive instance regularization layer-ReLU activation layer structure, and finally obtains the output through an average pooling layer. All three sub-encoders are designed for single-character encoding. After extracting the encodings of all artistic fonts, the extracted query, key, and value encoding matrices are averaged and then fed into the corresponding self-attention structures.

[0086] The self-attention structure performs matrix operations on the query, key, and value encoding matrices generated by the style encoder in a predetermined manner. First, the query matrix and the key matrix are multiplied together and divided by the square root of the number of dimensions. The result is then subjected to SoftMax (normalized exponential function, activation function) operation. Finally, it is multiplied with the value matrix to obtain the final style code used for generation.

[0087] The style encoder-self-attention structure is mainly used to extract the font style of artistic fonts; its specific implementation can be found in [link to implementation details]. Figure 6 . Figure 6 This is a schematic diagram illustrating the working principle of artistic font style extraction disclosed in the embodiments of this application, which can be combined with... Figure 6 Understand the above content.

[0088] The generator consists of a residual module constructed from an adaptive instance regularization layer and a double convolutional layer, followed by a four-layer deconvolutional-LeakyReLU activation layer structure, which decodes the style encoding and content encoding into corresponding Chinese characters with artistic font style.

[0089] Combination Figure 5 and Figure 6As shown, the methods for generating artistic fonts in the implementation can include:

[0090] 1. Select an existing complete font library (such as SimHei), send the image of each Chinese character into the content encoder to extract the Chinese character content information and form content encoding;

[0091] 2. Select 10 to 20 characters of one font from the art font library such as calligraphy works, and feed them into the style encoder and self-attention structure to extract the style information of the art font and form a style code;

[0092] 3. The generator maps style encoding to content encoding. The generator will generate Chinese characters with the style of the artistic font, thus forming the corresponding Chinese characters with the style of the artistic font.

[0093] 4. Repeat steps 1-3 above, changing the Chinese characters in step 1 each time, so that the artistic font corresponding to each Chinese character in GB2312 is generated, thus having all Chinese characters with the corresponding font style, and thus forming a font library.

[0094] In the implementation of the above scheme, the style code corresponding to the first style can be extracted from a small number of samples of the first style based on the self-attention mechanism. Then, the obtained style code is mapped to the standard font to obtain the first style conversion object. Compared with the current implementation that requires a large number of samples for network training, this scheme greatly saves the time and manpower cost of building the artistic font library and reduces the difficulty of building the artistic font library.

[0095] For the foregoing method embodiments, in order to simplify the description, they are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because according to this application, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0096] The methods described in the above-disclosed embodiments of this application are detailed in terms of the methods. The methods of this application can be implemented by various forms of apparatus. Therefore, this application also discloses an apparatus. Specific embodiments are given below for detailed description.

[0097] Figure 7 This is a schematic diagram of the structure of a processing device disclosed in an embodiment of this application. See also... Figure 7 As shown, the processing device 70 may include:

[0098] The sample acquisition module 701 is used to acquire a small sample set, wherein each sample object in the small sample set has a first style.

[0099] The style extraction module 702 is used to perform style recognition and extraction on sample objects in the small sample set based on the self-attention mechanism to obtain style codes.

[0100] Content acquisition module 703 is used to obtain the content encoding of the object to be converted in the second style.

[0101] The style conversion module 704 is used to map the style encoding onto the content encoding to obtain the conversion object of the first style.

[0102] In the implementation of the processing device described in this embodiment, the style code corresponding to the first style can be extracted from a small number of samples of the first style based on the self-attention mechanism. Then, the obtained style code is mapped to the standard font to obtain the transformation object of the first style. Compared with the current implementation that requires a large number of samples for network training, this solution greatly saves the time and manpower cost of building the artistic font library and reduces the difficulty of building the artistic font library.

[0103] In one implementation, the style extraction module may include: a matrix extraction module, used to perform style recognition extraction on sample objects in the small sample set to obtain an encoding matrix corresponding to the self-attention structure; and a style acquisition module, used to process the encoding matrix based on the self-attention structure algorithm to obtain style encoding.

[0104] In one implementation, the matrix extraction module can be specifically used for: for each sample object in the small sample set: performing style recognition extraction on the sample object through three encoding structures corresponding to the query parameter, key parameter, and value parameter of the self-attention structure, respectively, to obtain three encoding matrices corresponding to the query parameter, key parameter, and value parameter; averaging all the encoding matrices corresponding to the query parameter to obtain the query parameter mean matrix; averaging all the encoding matrices corresponding to the key parameter to obtain the key parameter mean matrix; and averaging all the encoding matrices corresponding to the value parameter to obtain the value parameter mean matrix.

[0105] In one implementation, the style acquisition module may include: a first processing module, used to perform a first processing on the mean matrix of the query parameters and the mean matrix of the key parameters to obtain a first processing result; and a second processing module, used to perform a second processing on the first processing result and the mean matrix of the value parameters to obtain a style code.

[0106] In one implementation, the first processing module can be specifically used to: perform matrix multiplication on the mean matrix of the query parameters and the mean matrix of the key parameters to obtain a matrix multiplication result; and normalize the matrix multiplication result to obtain a first processing result.

[0107] In one implementation, the second processing module can specifically be used to: multiply the first processing result by the mean matrix of the value parameter to obtain the style code.

[0108] In one implementation, the content acquisition module can be used to obtain content encoding by performing convolution processing on the object to be converted in the second style.

[0109] For details on the specific implementation of the above-mentioned processing device and its various modules, please refer to the corresponding sections of the method embodiments; they will not be repeated here.

[0110] Any of the processing devices described in the above embodiments includes a processor and a memory. The sample acquisition module, style extraction module, content acquisition module, style conversion module, matrix extraction module, style acquisition module, first processing module, second processing module, etc. in the above embodiments are all stored as program modules in the memory, and the processor executes the above program modules stored in the memory to realize the corresponding functions.

[0111] The processor contains a kernel, which retrieves the corresponding program modules from memory. One or more kernels can be configured, and the processing of accessed data can be achieved by adjusting kernel parameters.

[0112] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0113] In an exemplary embodiment, a computer-readable storage medium is also provided, which can be directly loaded into the internal memory of a computer, and contains software code that, after being loaded and executed by the computer, can implement the steps shown in any of the embodiments of the above processing method.

[0114] In an exemplary embodiment, a computer program product is also provided, which can be directly loaded into the internal memory of a computer and contains software code. After being loaded and executed by the computer, the computer program can implement the steps shown in any embodiment of the processing method described above.

[0115] Furthermore, embodiments of this application provide an electronic device. Figure 8 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application. See also... Figure 8 As shown, the electronic device includes at least one processor 801, at least one memory 802 connected to the processor, and a bus 803; wherein the processor and the memory communicate with each other through the bus; the processor is used to call program instructions in the memory to execute the above-mentioned processing method.

[0116] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.

[0117] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover 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 limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0118] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0119] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A processing method, comprising: Obtain a small sample set, wherein each sample object in the small sample set has a first style; The self-attention mechanism is used to perform style recognition and extraction on the sample objects in the small sample set to remove the structural information of the sample objects and obtain the global style code. The self-attention mechanism focuses on the characteristics of different positions, strokes and characters of the sample objects themselves, weakening the structure of each part of the font and the correlation between different fonts. Obtain the content encoding of the object to be converted in the second style; The global style encoding is mapped onto the content encoding to obtain the transformation object of the first style.

2. The processing method according to claim 1, wherein the step of performing style recognition extraction on sample objects in the small sample set based on a self-attention mechanism to remove structural information of the sample objects and obtain a global style code includes: Style recognition extraction is performed on the sample objects in the small sample set to remove the structural information of the sample objects, and an encoding matrix corresponding to the self-attention mechanism is obtained. The encoding matrix is ​​processed using a self-attention mechanism to obtain global style encoding.

3. The processing method according to claim 2, wherein performing style recognition extraction on the sample objects in the small sample set to remove the structural information of the sample objects and obtain an encoding matrix corresponding to the self-attention mechanism includes: For each sample object in the small sample set: style recognition extraction is performed on the sample object by three encoding structures corresponding to the query parameter, key parameter and value parameter of the self-attention mechanism, respectively, to obtain three encoding matrices corresponding to the query parameter, key parameter and value parameter respectively; The mean matrix of all corresponding query parameters is obtained by averaging the encoding matrices. The mean matrix of all corresponding key parameters is obtained by averaging the encoding matrices. The mean matrix of all corresponding value parameters is obtained by averaging the encoding matrices.

4. The processing method according to claim 3, wherein processing the encoding matrix based on a self-attention mechanism to obtain global style encoding includes: The mean matrix of the query parameters and the mean matrix of the key parameters are subjected to a first processing to obtain a first processing result; The first processing result is combined with the mean matrix of the value parameter to perform a second processing to obtain the global style code.

5. The processing method according to claim 4, wherein performing a first processing on the mean matrix of the query parameters and the mean matrix of the key parameters to obtain a first processing result includes: Perform matrix multiplication on the mean matrix of the query parameters and the mean matrix of the key parameters to obtain the matrix multiplication result; The matrix multiplication result is normalized to obtain the first processing result.

6. The processing method according to claim 4, wherein the second processing of the first processing result and the mean matrix of the corresponding value parameter to obtain the global style code includes: Multiply the first processing result by the mean matrix of the value parameter to obtain the global style code.

7. The processing method according to claim 1, wherein obtaining the content encoding of the object to be converted in the second style includes: Content encoding is obtained by performing convolution on the object to be converted in the second style.

8. A processing apparatus, comprising: The sample acquisition module is used to acquire a small sample set, wherein each sample object in the small sample set has a first style; The style extraction module is used to perform style recognition and extraction on sample objects in the small sample set based on the self-attention mechanism to remove the structural information of the sample objects and obtain the global style code. The self-attention mechanism focuses on the characteristics of different positions, strokes and characters of the sample objects themselves, weakening the structure of each part of the font and the correlation between different fonts. The content acquisition module is used to obtain the content encoding of the object to be converted in the second style; The style conversion module is used to map the global style code onto the content code to obtain the conversion object of the first style.

9. The processing apparatus according to claim 8, wherein the style extraction module comprises: The matrix extraction module is used to perform style recognition extraction on the sample objects in the small sample set to remove the structural information of the sample objects and obtain the encoding matrix corresponding to the self-attention mechanism. The style acquisition module is used to process the encoding matrix based on a self-attention mechanism to obtain global style encoding.

10. An electronic device, comprising: processor; Memory for storing executable program instructions of the processor; The executable program instructions include: obtaining a small sample set, wherein each sample object in the small sample set has a first style; performing style recognition and extraction on the sample objects in the small sample set based on a self-attention mechanism to remove the structural information of the sample objects and obtain a global style code, wherein the self-attention mechanism focuses on the characteristics of different positions, strokes and characters of the sample object itself, weakening the structural parts of the font and the correlation between different fonts; obtaining the content code of the object to be converted in a second style; and mapping the global style code onto the content code to obtain the object to be converted in the first style.

Citation Information

Patent Citations

  • Font generation method and device, model training method and device, equipment and medium

    CN114820871A