Intelligent font generation method and device based on generative adversarial network and font skeleton transformation

Through an intelligent font generation method based on generative adversarial network and font skeleton transformation, the challenges of the existing technology in font structure migration and style integration are solved, and high-quality calligraphy font generation is achieved to meet the details and style needs of calligraphy art.

CN119830857APending Publication Date: 2025-04-15HUAQIAO UNIVERSITY

Patent Information

Application Number
CN202411914140.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

The existing font generation technology has great challenges in the integration of structure migration and style, and it is difficult to achieve richly detailed calligraphy font generation.

Method used

An intelligent font generation method based on generative adversarial network and glyph skeleton transformation is adopted to realize font style transfer through loop generation adversarial networks, and a multi-scale fusion of glyph features and style features is used to use the iterative feature attention interaction structure.

Benefits of technology

The effective migration of the structure and style of the font is achieved. The generated calligraphy fonts meet the needs of calligraphy art in detail and artistic expression, and overcome the limitation of scarcity of samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119830857A_ABST
    Figure CN119830857A_ABST
Patent Text Reader

Abstract

The invention discloses an intelligent font generation method and device based on a generative adversarial network and font skeleton transformation, and the method comprises the steps: obtaining a source font image and a style font image, inputting the source font image into a font skeleton extraction algorithm based on a maximum inscribed circle rule and a connectivity criterion, and carrying out the extraction to obtain a font skeleton image; a cyclic generative adversarial network composed of a font generator and a discriminator is constructed, the discriminator comprises a content discriminator and a style discriminator, the cyclic generative adversarial network is trained to obtain a trained font generator and a trained discriminator, the font generator comprises a content encoder, a style encoder and an image restoration decoder, and the trained discriminator comprises a content encoder, a style encoder and an image restoration decoder. And inputting the font skeleton image and the style font image into a trained font generator to obtain a generated font image. Through the generative adversarial network and the font skeleton transformation technology, the limitation of sample scarcity is overcome, and high-quality calligraphy fonts meeting specific structure and style requirements are generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of font generation, and in particular to an intelligent font generation method and device based on a generative adversarial network and a glyph skeleton transformation. Background Art

[0002] Chinese calligraphy is complex and varied in strokes and spatial structure, and existing font generation technologies face great challenges in structural migration and style fusion. In addition, traditional technologies focus on learning font images as a whole, while ignoring the intrinsic connection and differences between font structure and stroke morphology. Even if parameters are adjusted or noise images are added, it is difficult to achieve detailed calligraphy font generation.

[0003] Cyclic generative adversarial networks are often used for image style transfer tasks, and their core lies in cycle consistency. Compared with traditional generative adversarial networks, cyclic generative adversarial networks have two generators and discriminators. They can not only ensure the structural similarity between the generated image and the original input, but also better preserve the content information, showing good application prospects in solving sample shortages and style differences.

[0004] The attention mechanism is a technology that mimics the human ability to concentrate. Its core idea is to dynamically adjust the degree of attention to different parts according to the importance of the input data, thereby improving the performance of the model on specific tasks. Compared with the traditional convolutional neural network model, the attention mechanism reduces the complexity of the model and helps to learn long-term dependencies.

[0005] Shape skeleton is a method to abstractly represent the shape and structure of an object. Its core idea is to capture the overall shape and structural features of the object by extending along the main axis of the object. It has a wide range of applications in computer graphics and computer vision. How to extract concise and accurate glyph skeletons from the outline of Chinese characters and use their glyph structure information to guide calligraphy image generation is a key technical challenge in font generation methods. Summary of the invention

[0006] The purpose of this application is to propose an intelligent font generation method and device based on generative adversarial networks and glyph skeleton transformation in response to the above-mentioned technical problems.

[0007] In a first aspect, the present invention provides an intelligent font generation method based on a generative adversarial network and a glyph skeleton transformation, comprising the following steps:

[0008] Obtaining a source font image and a style font image, inputting the source font image into a glyph skeleton extraction algorithm based on a maximum inscribed circle rule and a connectivity criterion, and extracting a glyph skeleton image;

[0009] Constructing a recurrent generative adversarial network consisting of a font generator and a discriminator, wherein the discriminator includes a content discriminator and a style discriminator, training the recurrent generative adversarial network to obtain a trained font generator and a trained discriminator, wherein the font generator includes a content encoder, a style encoder, and an image restoration decoder, wherein the content encoder and the style encoder each include a first convolution module, a second convolution module, a third convolution module, and a self-attention module connected in sequence, and the image restoration decoder includes a first iterative feature attention interaction module, a residual module, a second iterative feature attention interaction module, a first upsampling layer, a third iterative feature attention interaction module, a second upsampling layer, a fourth iterative feature attention interaction module, and a third upsampling layer connected in sequence;

[0010] The glyph skeleton image and the style font image are input into the trained font generator, the glyph skeleton image is input into the content encoder, and passes through the first convolution module, the second convolution module, the third convolution module and the self-attention module in the content encoder in sequence to extract the glyph skeleton feature, the style font image is input into the style encoder, and passes through the first convolution module, the second convolution module, the third convolution module and the self-attention module in the style encoder in sequence to extract the font style feature, the glyph skeleton feature and the font style feature, as well as the output features of the first convolution module and the output features of the second convolution module in the content encoder are input into the image restoration decoder together, the glyph skeleton feature and the font style feature pass through the first iterative feature attention interaction module to obtain the first intermediate feature, the first intermediate feature The intermediate features pass through the residual module to obtain the output features of the residual module, the output features of the residual module and the first intermediate features pass through the second iterative feature attention interaction module to obtain the second intermediate features, the second intermediate features pass through the first upsampling layer to obtain the output features of the first upsampling layer, the output features of the first upsampling layer and the output features of the first convolution module in the content encoder pass through the third iterative feature attention interaction module to obtain the third intermediate features, the third intermediate features pass through the second upsampling layer to obtain the output features of the second upsampling layer, the output features of the second upsampling layer and the output features of the second convolution module in the content encoder pass through the fourth iterative feature attention interaction module to obtain the fourth intermediate features, the fourth intermediate features pass through the third upsampling layer to obtain the generated font image.

[0011] Preferably, the source font image is input into a font skeleton extraction algorithm based on the maximum inscribed circle rule and the connectivity criterion to extract a font skeleton image, which specifically includes:

[0012] S11, in a single-pixel glyph outline in a pixel grid of a source font image, assuming that the contour point closest to a pixel point P in the single-pixel glyph outline by a Euclidean distance is Q, and the set of eight neighborhood points of point P is {P1, P2, ..., P8},

[0013] The point set of each point in {P1,P2,...,P8} that has the closest Euclidean distance to the contour point in the shape contour is {Q1,Q2,...,Q8};

[0014] S12, for any point Q in {Q1,Q2,...,Q8} i Perform the maximum inscribed circle rule judgment, i = 1, 2, ..., 8, as shown in the following formula:

[0015] D 2 =(Q x -Q ix ) 2 +(Q y -Q iy ) 2 ;

[0016]

[0017] Where D represents the point Q and point Q i The distance between x represents the horizontal coordinate of point Q, Q y represents the ordinate of point Q, Q ix Indicates point Q i The horizontal axis, Q iy Indicates point Q i The vertical axis of β represents the dynamically adjustable residual distance threshold, D avg Represents the average value of the distance between all contour points and point P within a certain distance;

[0018] The conditions for satisfying the maximum circle rule are:

[0019] D 2 ≥β;

[0020] S13, for all points Q that satisfy the maximum circle rule in step S12 i Connectivity criteria are determined as shown in the following formula:

[0021] d x =abs(Q x -Q ix );

[0022] d y =abs(Q y -Q iy );

[0023] Among them, d x Represents point Q and point Q i The difference in the horizontal coordinates, d y Represents point Q and point Q i The difference in the ordinate of , abs represents the absolute value function;

[0024] The conditions for satisfying the connectivity criterion are:

[0025] r2 2 -r1 2 ≤max(d x ,d y );

[0026] Among them, r1 represents the distance between point Q and point P, r2 represents the distance between point Q and point P, i The distance between the point P and max means taking the maximum value. The point P that satisfies the conditions of the maximum circle rule and the connectivity criterion is the skeleton point.

[0027] S14, repeating steps S11 to S13 until skeleton points are determined for all pixels in the outline, and all skeleton points are found. The set of all skeleton points is the skeleton image of the glyph.

[0028] Preferably, the first convolution module includes a convolution layer with a convolution kernel size of 7×7, an instance normalization layer and a ReLU activation function layer connected in sequence; the structures of the second convolution module, the third convolution module, the first upsampling layer and the second upsampling layer are all 3×3 convolution layers, instance normalization layers and ReLU activation function layers connected in sequence; the third upsampling layer includes a convolution layer with a convolution kernel size of 7×7, an instance normalization layer and a Tanh activation function layer connected in sequence, and the residual module includes six residual blocks connected in sequence.

[0029] Preferably, the first iterative feature attention interaction module, the second iterative feature attention interaction module, the third iterative feature attention interaction module and the fourth iterative feature attention interaction module are all iterative feature attention interaction structures, the iterative feature attention interaction structure includes a splicing layer, a convolution layer with a convolution kernel size of 3×3, an instance normalization layer, a ReLU activation function layer and a refinement fusion module, the refinement fusion module includes a refinement MS-CAM module and a fusion module connected in sequence, and the calculation process of the refinement MS-CAM module is as follows:

[0030]

[0031] Where X represents the input feature of the refined MS-CAM module, M(X) represents the refinement operation, L(X) represents the local attention feature, σ represents the sigmoid activation function, G(X) represents the global attention feature, and Y represents the refined feature output by the refined MS-CAM module;

[0032] The calculation process of local attention features is expressed as:

[0033] L(X)=IN(PWConv2(ReLU(IN(PWConv1(X)))));

[0034] The calculation process of the global attention feature is expressed as:

[0035] G(X)=AAP(IN(PWConv2(ReLU(IN(PWConv1(AAP(X)))))));

[0036] Among them, IN represents the instance normalization layer, ReLU represents the ReLU activation function layer, and PWConv j represents the jth convolution operation with a convolution kernel of 1×1, and AAP represents the adaptive average pooling layer;

[0037] The input features of the iterative feature attention interaction structure include the first input feature X1 and the second input feature. After the second input feature and the first input feature pass through the splicing layer, the first splicing feature is obtained. The splicing feature passes through the convolution layer with a convolution kernel size of 3×3, the instance normalization layer and the ReLU activation function layer in sequence to obtain the second splicing feature X2. The first input feature X1 and the second splicing feature X2 are respectively input into the refinement MS-CAM module as input features of the refinement MS-CAM module to obtain the first refinement feature Y1 and the second refinement feature Y2.

[0038] The first refined feature Y1 and the second refined feature Y2 are input into the fusion module. The fusion module includes a first fusion module and a second fusion module. The first refined feature Y1 and the second refined feature Y2 are passed through the first fusion module to obtain a fusion feature, as shown in the following formula:

[0039]

[0040] in, represents the fusion feature, Indicates pixel-level multiplication;

[0041] The first refined feature Y1, the second refined feature Y2 and the fusion feature are passed through the second fusion module to obtain the output feature of the iterative feature attention interaction structure, as shown in the following formula:

[0042]

[0043] Among them, Z represents the output feature of the iterative feature attention interaction structure.

[0044] Preferably, both the content identifier and the style identifier adopt the PatchGAN network structure.

[0045] As a preference, during the training of the cyclic generative adversarial network, the loss function Loss used by the discriminator desc for

[0046]

[0047] Where E represents the calculation loss, MSE represents the mean square error loss function, J represents a matrix whose elements are all 1, I represents a matrix whose elements are all 0, p∈P1 represents selecting a source font image p from the source font image set P1, q∈P2 represents selecting a style font image q from the style font image set P2, p s Represents the glyph skeleton image of p, q s The glyph skeleton image of q, D c represents the content discriminator, D s represents the style discriminator; G p represents the style transfer of the font generator to the source font image p;

[0048] Loss function used by the font generator total for:

[0049] Loss total =λ1Loss adv +λ2Loss sr +λ3Loss ec +λ4Loss cyc ;

[0050] Among them, Loss adv Represents the adversarial loss function, Loss sr Represents the style reconstruction loss function, Loss ec Represents the encoder consistency loss function, Loss cyc represents the structural consistency loss function, λ1, λ2, λ3, and λ4 represent the weights corresponding to the adversarial loss function, the style reconstruction loss function, the encoder consistency loss function, and the structural consistency loss function, respectively;

[0051] The adversarial loss function is expressed as:

[0052]

[0053] Among them, G q represents the style transfer of the font generator to the style font image q;

[0054] The encoder consistency loss function is expressed as:

[0055]

[0056] Among them, p t ∈P1,q t ∈P2 means selecting two images p with the same content from the source font image set P1 and the style font image set P2 t and q t , Indicates p tThe glyph skeleton image of Indicates q t The glyph skeleton image of Indicates that the input is The output features of the content encoder when Indicates that the input is The output feature of the content encoder, ‖·‖1 represents the L1 norm;

[0057] The style reconstruction loss function is expressed as:

[0058]

[0059] The structural consistency loss function is expressed as:

[0060]

[0061] In a second aspect, the present invention provides an intelligent font generation device based on a generative adversarial network and a glyph skeleton transformation, comprising:

[0062] A data extraction module is configured to obtain a source font image and a style font image, input the source font image into a glyph skeleton extraction algorithm based on a maximum inscribed circle rule and a connectivity criterion, and extract a glyph skeleton image;

[0063] A model building module is configured to build a recurrent generative adversarial network consisting of a font generator and a discriminator, wherein the discriminator includes a content discriminator and a style discriminator, and train the recurrent generative adversarial network to obtain a trained font generator and a trained discriminator, wherein the font generator includes a content encoder, a style encoder, and an image restoration decoder, wherein the content encoder and the style encoder each include a first convolution module, a second convolution module, a third convolution module, and a self-attention module connected in sequence, and the image restoration decoder includes a first iterative feature attention interaction module, a residual module, a second iterative feature attention interaction module, a first upsampling layer, a third iterative feature attention interaction module, a second upsampling layer, a fourth iterative feature attention interaction module, and a third upsampling layer connected in sequence;

[0064] The generation module is configured to input the glyph skeleton image and the style font image into the trained font generator, the glyph skeleton image is input into the content encoder, and sequentially passes through the first convolution module, the second convolution module, the third convolution module and the self-attention module in the content encoder to extract the glyph skeleton feature, the style font image is input into the style encoder, and sequentially passes through the first convolution module, the second convolution module, the third convolution module and the self-attention module in the style encoder to extract the font style feature, the glyph skeleton feature and the font style feature as well as the output feature of the first convolution module and the output feature of the second convolution module in the content encoder are input into the image restoration decoder together, the glyph skeleton feature and the font style feature are passed through the first iterative feature attention interaction module to obtain the first intermediate feature. The first intermediate feature passes through the residual module to obtain the output feature of the residual module. The output feature of the residual module and the first intermediate feature pass through the second iterative feature attention interaction module to obtain the second intermediate feature. The second intermediate feature passes through the first upsampling layer to obtain the output feature of the first upsampling layer. The output feature of the first upsampling layer and the output feature of the first convolution module in the content encoder pass through the third iterative feature attention interaction module to obtain the third intermediate feature. The third intermediate feature passes through the second upsampling layer to obtain the output feature of the second upsampling layer. The output feature of the second upsampling layer and the output feature of the second convolution module in the content encoder pass through the fourth iterative feature attention interaction module to obtain the fourth intermediate feature. The fourth intermediate feature passes through the third upsampling layer to generate the font image.

[0065] In a third aspect, the present invention provides an electronic device comprising one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation manner in the first aspect.

[0066] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.

[0067] In a fifth aspect, the present invention provides a computer program product, comprising a computer program, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.

[0068] Compared with the prior art, the present invention has the following beneficial effects:

[0069] (1) The intelligent font generation method based on generative adversarial network and glyph skeleton transformation proposed in the present invention realizes font style transfer through a cyclic generative adversarial network, and innovatively separates the glyph structure and stroke morphology style.

[0070] (2) The intelligent font generation method based on generative adversarial networks and glyph skeleton transformation proposed in the present invention involves an iterative feature attention interaction structure to achieve multi-scale fusion of glyph features and style features, and iterative optimization is achieved by a content identifier and a style identifier, so that the generated font meets the requirements of calligraphy art in terms of structure and style.

[0071] (3) The intelligent font generation method based on generative adversarial network and glyph skeleton transformation proposed in the present invention overcomes the limitation of sample scarcity through generative adversarial network (GAN) and glyph skeleton transformation technology, and generates high-quality calligraphy fonts that meet specific structural and style requirements. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0073] Figure 1 A schematic flow chart of an intelligent font generation method based on a generative adversarial network and glyph skeleton transformation according to an embodiment of the present application;

[0074] Figure 2 A schematic diagram of a generative adversarial network of an intelligent font generation method based on a generative adversarial network and glyph skeleton transformation according to an embodiment of the present application;

[0075] Figure 3 A schematic diagram of a training process of a generative adversarial network of an intelligent font generation method based on a generative adversarial network and character skeleton transformation according to an embodiment of the present application;

[0076] Figure 4 A schematic diagram of an iterative feature attention interaction structure of an intelligent font generation method based on a generative adversarial network and glyph skeleton transformation according to an embodiment of the present application;

[0077] Figure 5 A schematic diagram of a refined MS-CAM module of an intelligent font generation method based on a generative adversarial network and glyph skeleton transformation according to an embodiment of the present application;

[0078] Figure 6 A schematic diagram of a fusion module of an intelligent font generation method based on a generative adversarial network and glyph skeleton transformation according to an embodiment of the present application;

[0079] Figure 7 A schematic diagram of an intelligent font generation device based on a generative adversarial network and a glyph skeleton transformation according to an embodiment of the present application;

[0080] Figure 8 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0081] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0082] Figure 1 An intelligent font generation method based on a generative adversarial network and glyph skeleton transformation provided by an embodiment of the present application is shown, comprising the following steps:

[0083] S1, obtaining a source font image and a style font image, inputting the source font image into a glyph skeleton extraction algorithm based on a maximum inscribed circle rule and a connectivity criterion, and extracting a glyph skeleton image.

[0084] In a specific embodiment, the source font image is input into a font skeleton extraction algorithm based on the maximum inscribed circle rule and the connectivity criterion to extract a font skeleton image, which specifically includes:

[0085] S11, in a single-pixel glyph outline in a pixel grid of a source font image, assuming that the contour point closest to a pixel point P in the single-pixel glyph outline by a Euclidean distance is Q, and the set of eight neighborhood points of point P is {P1, P2, ..., P8},

[0086] The point set of each point in {P1,P2,...,P8} that has the closest Euclidean distance to the contour point in the shape contour is {Q1,Q2,...,Q8};

[0087] S12, for any point Q in {Q1,Q2,...,Q8} i Perform the maximum inscribed circle rule judgment, i = 1, 2, ..., 8, as shown in the following formula:

[0088] D 2 =(Q x -Q ix ) 2 +(Q y -Q iy ) 2 ;

[0089]

[0090] Where D represents the point Q and point Q i The distance between x represents the horizontal coordinate of point Q, Qy represents the ordinate of point Q, Q ix Indicates point Q i The horizontal axis, Q iy Indicates point Q i The vertical axis of β represents the dynamically adjustable residual distance threshold, D avg Represents the average value of the distance between all contour points and point P within a certain distance;

[0091] Then the condition that satisfies the maximum circle rule is:

[0092] D 2 ≥β;

[0093] S13, for all points Q that satisfy the maximum circle rule in step S12 i The connectivity criteria are judged as shown in the following formula:

[0094] d x =abs(Q x -Q ix );

[0095] d y =abs(Q y -Q iy );

[0096] Among them, d x Represents point Q and point Q i The difference in the horizontal coordinates, d y Represents point Q and point Q i The difference in the ordinate of , abs represents the absolute value function;

[0097] The conditions for satisfying the connectivity criterion are:

[0098] r2 2 -r1 2 ≤max(d x ,d y );

[0099] Among them, r1 represents the distance between point Q and point P, r2 represents the distance between point Q and point P, i The distance between the point P and max means taking the maximum value. The point P that satisfies the conditions of the maximum circle rule and the connectivity criterion is the skeleton point.

[0100] S14, repeating steps S11 to S13 until skeleton points are determined for all pixels in the outline, and all skeleton points are found. The set of all skeleton points is the skeleton image of the glyph.

[0101] Specifically, font images are collected to construct a data set, in which standard Kaiti fonts are used as source fonts, and other types of calligraphy fonts are used as style fonts. The specific process is: download font packages in TTF format of different styles, and obtain each group of style font images after file conversion. The standard Kaiti font image must contain the characters required by the target style font image, but there is no requirement for the style font image. For the source font image, it is necessary to use a glyph skeleton extraction algorithm based on the maximum inscribed circle rule and connectivity criterion to extract its corresponding glyph skeleton image. In this algorithm, a certain distance can be set to 32 pixels.

[0102] S2, construct a recurrent generative adversarial network consisting of a font generator and a discriminator, the discriminator includes a content discriminator and a style discriminator, train the recurrent generative adversarial network to obtain a trained font generator and a trained discriminator, the font generator includes a content encoder, a style encoder and an image restoration decoder, the content encoder and the style encoder each include a first convolution module, a second convolution module, a third convolution module and a self-attention module connected in sequence, the image restoration decoder includes a first iterative feature attention interaction module, a residual module, a second iterative feature attention interaction module, a first upsampling layer, a third iterative feature attention interaction module, a second upsampling layer, a fourth iterative feature attention interaction module and a third upsampling layer connected in sequence.

[0103] In a specific embodiment, the first convolution module includes a convolution layer with a convolution kernel size of 7×7, an instance normalization layer, and a ReLU activation function layer connected in sequence; the structures of the second convolution module, the third convolution module, the first upsampling layer, and the second upsampling layer are all 3×3 convolution layers, instance normalization layers, and ReLU activation function layers connected in sequence; the third upsampling layer includes a convolution layer with a convolution kernel size of 7×7, an instance normalization layer, and a Tanh activation function layer connected in sequence, and the residual module includes six residual blocks connected in sequence.

[0104] In a specific embodiment, both the content identifier and the style identifier adopt the PatchGAN network structure.

[0105] In a specific embodiment, during the training process of the cyclic generative adversarial network, the loss function Loss used by the discriminator desc for

[0106]

[0107] Where E represents the calculation loss, MSE represents the mean square error loss function, J represents a matrix whose elements are all 1, I represents a matrix whose elements are all 0, p∈P1 represents selecting a source font image p from the source font image set P1, q∈P2 represents selecting a style font image q from the style font image set P2, p s Represents the glyph skeleton image of p, qs The glyph skeleton image of q, D c represents the content discriminator, D s represents the style discriminator; G p represents the style transfer of the font generator to the source font image p;

[0108] Loss function used by the font generator total for:

[0109] Loss total =λ1Loss adv +λ2Loss sr +λ3Loss ec +λ4Loss cyc ;

[0110] Among them, Loss adv Represents the adversarial loss function, Loss sr Represents the style reconstruction loss function, Loss ec Represents the encoder consistency loss function, Loss cyc represents the structural consistency loss function, λ1, λ2, λ3, and λ4 represent the weights corresponding to the adversarial loss function, the style reconstruction loss function, the encoder consistency loss function, and the structural consistency loss function, respectively;

[0111] The adversarial loss function is expressed as:

[0112]

[0113] Among them, G q represents the style transfer of the font generator to the style font image q;

[0114] The encoder consistency loss function is expressed as:

[0115]

[0116] Among them, p t ∈P1,q t ∈P2 means selecting two images p with the same content from the source font image set P1 and the style font image set P2 t and q t , Indicates p t The glyph skeleton image of Indicates q t The glyph skeleton image of Indicates that the input is The output features of the content encoder when Indicates that the input is The output feature of the content encoder, ‖·‖1 represents the L1 norm;

[0117] The style reconstruction loss function is expressed as:

[0118]

[0119] The structural consistency loss function is expressed as:

[0120]

[0121] Specifically, refer to Figure 2 , build a font generation framework, which includes a skeleton encoder, a style encoder, an image restoration decoder and a discriminator. Build a skeleton encoder and a style encoder, both of which are composed of a first convolution module, a second convolution module, a third convolution module and a self-attention module; build an image restoration decoder, which consists of a residual module with six residual blocks, four iterative feature attention interactions (IAFI) modules and three upsampling layers; build a discriminator, which uses a PatchGAN network structure and is divided into a content discriminator D c and style discriminator D s The skeleton encoder, style encoder, and image restoration decoder form the font generator, and together with the discriminator form a generative adversarial network.

[0122] Furthermore, the recurrent generative adversarial network is trained. During the training process of the recurrent generative adversarial network, all generated font images are classified and identified in terms of content and style. The game between the font generator and the discriminator is used to obtain the generation results of gradually improved calligraphy fonts. Figure 3 , content discriminator D c Receive the source font image and the generated font image, style discriminator D s Receive the style font image and the generated font image, and use the mean square error loss function MSE to construct the loss function. In the loss function of the discriminator, the adversarial loss function is used to evaluate the consistency between the generated font and the target image, the style reconstruction loss function is used to distinguish the difference between the content image and the style image, the encoder consistency loss function is used to strengthen the synergy of the content and style features, and the structural consistency loss function is used to ensure the restoration of the skeleton features. Based on the above loss functions, iterative training is performed until the loss function converges to obtain a trained font generator.

[0123] S3, input the glyph skeleton image and the style font image into the trained font generator, input the glyph skeleton image into the content encoder, and pass through the first convolution module, the second convolution module, the third convolution module and the self-attention module in the content encoder in sequence to extract the glyph skeleton features, input the style font image into the style encoder, and pass through the first convolution module, the second convolution module, the third convolution module and the self-attention module in the style encoder in sequence to extract the font style features, input the glyph skeleton features and the font style features as well as the output features of the first convolution module and the output features of the second convolution module in the content encoder into the image restoration decoder, and the glyph skeleton features and the font style features pass through the first iterative feature attention interaction module to obtain the first intermediate features, and the first iterative feature attention interaction module is used to generate the glyph skeleton features and the font style features. An intermediate feature passes through a residual module to obtain an output feature of the residual module. The output feature of the residual module and the first intermediate feature pass through a second iterative feature attention interaction module to obtain a second intermediate feature. The second intermediate feature passes through a first upsampling layer to obtain an output feature of the first upsampling layer. The output feature of the first upsampling layer and the output feature of the first convolution module in the content encoder pass through a third iterative feature attention interaction module to obtain a third intermediate feature. The third intermediate feature passes through a second upsampling layer to obtain an output feature of the second upsampling layer. The output feature of the second upsampling layer and the output feature of the second convolution module in the content encoder pass through a fourth iterative feature attention interaction module to obtain a fourth intermediate feature. The fourth intermediate feature passes through a third upsampling layer to generate a font image.

[0124] In a specific embodiment, the first iterative feature attention interaction module, the second iterative feature attention interaction module, the third iterative feature attention interaction module and the fourth iterative feature attention interaction module are all iterative feature attention interaction structures, the iterative feature attention interaction structure includes a splicing layer, a convolution layer with a convolution kernel size of 3×3, an instance normalization layer, a ReLU activation function layer and a refinement fusion module, the refinement fusion module includes a refinement MS-CAM module and a fusion module connected in sequence, and the calculation process of the refinement MS-CAM module is as follows:

[0125]

[0126] Where X represents the input feature of the refined MS-CAM module, M(X) represents the refinement operation, L(X) represents the local attention feature, σ represents the sigmoid activation function, G(X) represents the global attention feature, and Y represents the refined feature output by the refined MS-CAM module;

[0127] The calculation process of local attention features is expressed as:

[0128] L(X)=IN(PWConv2(ReLU(IN(PWConv1(X)))));

[0129] The calculation process of the global attention feature is expressed as:

[0130] G(X)=AAP(IN(PWConv2(ReLU(IN(PWConv1(AAP(X)))))));

[0131] Among them, IN represents the instance normalization layer, ReLU represents the ReLU activation function layer, and PWConv j represents the jth convolution operation with a convolution kernel of 1×1, and AAP represents the adaptive average pooling layer;

[0132] The input features of the iterative feature attention interaction structure include the first input feature X1 and the second input feature. After the second input feature and the first input feature pass through the splicing layer, the first splicing feature is obtained. The splicing feature passes through the convolution layer with a convolution kernel size of 3×3, the instance normalization layer and the ReLU activation function layer in sequence to obtain the second splicing feature X2. The first input feature X1 and the second splicing feature X2 are respectively input into the refinement MS-CAM module as input features of the refinement MS-CAM module to obtain the first refinement feature Y1 and the second refinement feature Y2.

[0133] The first refined feature Y1 and the second refined feature Y2 are input into the fusion module. The fusion module includes a first fusion module and a second fusion module. The first refined feature Y1 and the second refined feature Y2 are passed through the first fusion module to obtain a fusion feature, as shown in the following formula:

[0134]

[0135] in, represents the fusion feature, Indicates pixel-level multiplication;

[0136] The first refined feature Y1, the second refined feature Y2 and the fusion feature are passed through the second fusion module to obtain the output feature of the iterative feature attention interaction structure, as shown in the following formula:

[0137]

[0138] Among them, Z represents the output feature of the iterative feature attention interaction structure.

[0139] Specifically, a glyph skeleton image is provided to the skeleton encoder to obtain glyph skeleton features as its structural features. Each convolution module in the skeleton encoder includes three parts: a convolution layer, an instance normalization layer, and a ReLU activation function layer. The structural features of the glyph skeleton image are captured through the convolution layer to obtain the local dependency of the input image; the instance normalization layer and the ReLU activation function layer are used to improve the accuracy of structural feature extraction. The output features of the first convolution module and the output features of the second convolution module in the skeleton encoder are retained for subsequent jump connections and feature fusion; the glyph skeleton features of the input glyph skeleton image are obtained after further refining the features through the self-attention (SA) module.

[0140] Provide one or more groups of style font images to the style encoder, input multiple style font images in groups, and obtain font style features as their style characteristics. Each convolution module in the style encoder also includes a convolution layer, an instance normalization layer, and a ReLU activation function layer. The convolution layer captures the glyph structure features and stroke morphology features of the style font image to obtain the style reference of the input style font image; the instance normalization layer and the ReLU activation function layer are used to improve the accuracy of style feature extraction. The font style features of the input style font image are obtained after further refining the features through the self-attention (SA) module.

[0141] In the image restoration decoder, the glyph skeleton features and font style features are received, and a jump link with the forward skeleton encoder is established to realize hierarchical feature fusion. The glyph skeleton image of the source font image is generated through structural migration and stroke thickness expansion to generate a generated font image with the style. The glyph skeleton features and font style features are input into the first iteration feature attention interaction module for the first feature fusion to obtain the first intermediate feature; the first intermediate feature and its result after the residual module are received, and the second iteration feature attention interaction module is entered for secondary feature fusion to obtain the second intermediate feature; the output feature of the second intermediate feature of the previous level after the first upsampling and the jump link of the output feature of the second convolution module from the skeleton encoder are received, and the third iteration feature attention interaction module, the second upsampling layer, the fourth iteration feature attention interaction module and the third upsampling layer are entered to obtain clearer glyph details and obtain the generated font image. The first iteration feature attention interaction module, the second iteration feature attention interaction module, the third iteration feature attention interaction module and the fourth iteration feature attention interaction module all adopt the iterative feature attention interaction structure, refer to Figure 3The iterative feature attention interaction structure consists of a connection layer, a convolution layer with a convolution kernel size of 3×3, an instance normalization layer, a ReLU activation function layer, and an refinement and fusion (IAFF) module. The refinement and fusion module includes a refinement MS-CAM module and a fusion module. The second input feature X0 is first concatenated with the first input feature X1, and then passes through a convolution layer with a convolution kernel size of 3×3, an instance normalization layer, and a ReLU activation function layer in sequence to obtain the second concatenated feature X2. The first input feature X1 and the second concatenated feature X2 are then input into the refinement and fusion (IAFF) module, which includes a refinement MS-CAM module and a fusion module connected in sequence. Reference Figure 5 , the refined MS-CAM module contains a refinement (M) operation, which includes local attention calculation and global attention calculation. Figure 6 , the refinement (M) operation also exists in the fusion module, and fusion is performed twice.

[0142] Further references Figure 7 As an implementation of the methods shown in the above figures, the present application provides an embodiment of an intelligent font generation device based on a generative adversarial network and a glyph skeleton transformation. Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0143] The embodiment of the present application provides an intelligent font generation device based on a generative adversarial network and a glyph skeleton transformation, comprising:

[0144] The data extraction module 1 is configured to obtain a source font image and a style font image, input the source font image into a font skeleton extraction algorithm based on a maximum inscribed circle rule and a connectivity criterion, and extract a font skeleton image;

[0145] The model construction module 2 is configured to construct a recurrent generative adversarial network consisting of a font generator and a discriminator, wherein the discriminator includes a content discriminator and a style discriminator, and the recurrent generative adversarial network is trained to obtain a trained font generator and a trained discriminator, wherein the font generator includes a content encoder, a style encoder, and an image restoration decoder, wherein the content encoder and the style encoder each include a first convolution module, a second convolution module, a third convolution module, and a self-attention module connected in sequence, and the image restoration decoder includes a first iterative feature attention interaction module, a residual module, a second iterative feature attention interaction module, a first upsampling layer, a third iterative feature attention interaction module, a second upsampling layer, a fourth iterative feature attention interaction module, and a third upsampling layer connected in sequence;

[0146] The generating module 3 is configured to input the glyph skeleton image and the style font image into the trained font generator, the glyph skeleton image is input into the content encoder, and sequentially passes through the first convolution module, the second convolution module, the third convolution module and the self-attention module in the content encoder to extract the glyph skeleton feature, the style font image is input into the style encoder, and sequentially passes through the first convolution module, the second convolution module, the third convolution module and the self-attention module in the style encoder to extract the font style feature, the glyph skeleton feature and the font style feature as well as the output feature of the first convolution module and the output feature of the second convolution module in the content encoder are input into the image restoration decoder together, the glyph skeleton feature and the font style feature are passed through the first iterative feature attention interaction module to obtain the first intermediate feature. The first intermediate feature passes through the residual module to obtain the output feature of the residual module. The output feature of the residual module and the first intermediate feature pass through the second iterative feature attention interaction module to obtain the second intermediate feature. The second intermediate feature passes through the first upsampling layer to obtain the output feature of the first upsampling layer. The output feature of the first upsampling layer and the output feature of the first convolution module in the content encoder pass through the third iterative feature attention interaction module to obtain the third intermediate feature. The third intermediate feature passes through the second upsampling layer to obtain the output feature of the second upsampling layer. The output feature of the second upsampling layer and the output feature of the second convolution module in the content encoder pass through the fourth iterative feature attention interaction module to obtain the fourth intermediate feature. The fourth intermediate feature passes through the third upsampling layer to generate the font image.

[0147] Figure 8 Schematic diagram of the hardware structure of the electronic device provided by the embodiment of the present invention. Figure 8 As shown, the electronic device of this embodiment includes: a processor 801 and a memory 802; wherein the memory 802 is used to store computer-executable instructions; the processor 801 is used to execute the computer-executable instructions stored in the memory to implement the various steps performed by the electronic device in the above embodiment. For details, please refer to the relevant description in the above method embodiment.

[0148] Optionally, the memory 802 may be independent or integrated with the processor 801 .

[0149] When the memory 802 is independently provided, the electronic device further includes a bus 803 for connecting the memory 802 and the processor 801 .

[0150] The embodiment of the present invention further provides a computer storage medium, in which computer execution instructions are stored. When the processor 801 executes the computer execution instructions, the above method is implemented.

[0151] The embodiment of the present invention further provides a computer program product, including a computer program. When the computer program is executed by the processor 801, the above method is implemented.

[0152] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.

[0153] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to implement the solution of this embodiment.

[0154] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each module may exist physically separately, or two or more modules may be integrated into one unit. The unit formed by the above modules may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0155] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor 801 to perform some steps of the methods of various embodiments of the present application.

[0156] It should be understood that the processor 801 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or the processor 801 may be any conventional processor 801, etc. The steps of the method disclosed in the invention may be directly embodied in the hardware processor 801 for execution, or may be executed by a combination of hardware and software modules in the processor 801.

[0157] The memory 802 may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk.

[0158] The bus 803 may be an Industry Standard Architecture (ISA), a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus 803 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus 803 in the drawings of the present application is not limited to only one bus 803 or one type of bus 803.

[0159] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.

[0160] An exemplary storage medium is coupled to the processor 801, so that the processor 801 can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor 801. The processor 801 and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor 801 and the storage medium can also exist as discrete components in an electronic device or a main control device.

[0161] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0162] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. An intelligent font generation method based on generative adversarial network and glyph skeleton transformation, characterized in that: The following steps are involved: Acquire a source font image and a style font image, input the source font image into a glyph skeleton extraction algorithm based on a maximum inscribed circle rule and a connectivity criterion, and extract a glyph skeleton image; Constructing a recurrent generative adversarial network consisting of a font generator and a discriminator, wherein the discriminator includes a content discriminator and a style discriminator, training the recurrent generative adversarial network to obtain a trained font generator and a trained discriminator, wherein the font generator includes a content encoder, a style encoder and an image restoration decoder, wherein the content encoder and the style encoder each include a first convolution module, a second convolution module, a third convolution module and a self-attention module connected in sequence, and the image restoration decoder includes a first iterative feature attention interaction module, a residual module, a second iterative feature attention interaction module, a first upsampling layer, a third iterative feature attention interaction module, a second upsampling layer, a fourth iterative feature attention interaction module and a third upsampling layer connected in sequence; The glyph skeleton image and the style font image are input into the trained font generator, the glyph skeleton image is input into the content encoder, and sequentially passes through the first convolution module, the second convolution module, the third convolution module and the self-attention module in the content encoder to extract the glyph skeleton feature, the style font image is input into the style encoder, and sequentially passes through the first convolution module, the second convolution module, the third convolution module and the self-attention module in the style encoder to extract the font style feature, the glyph skeleton feature and the font style feature, as well as the output feature of the first convolution module and the output feature of the second convolution module in the content encoder are input into the image restoration decoder together, the glyph skeleton feature and the font style feature pass through the first iterative feature attention interaction module to obtain the first intermediate feature, and the first intermediate feature passes through The residual module obtains the output feature of the residual module, the output feature of the residual module and the first intermediate feature are passed through the second iterative feature attention interaction module to obtain the second intermediate feature, the second intermediate feature is passed through the first upsampling layer to obtain the output feature of the first upsampling layer, the output feature of the first upsampling layer and the output feature of the first convolution module in the content encoder are passed through the third iterative feature attention interaction module to obtain the third intermediate feature, the third intermediate feature is passed through the second upsampling layer to obtain the output feature of the second upsampling layer, the output feature of the second upsampling layer and the output feature of the second convolution module in the content encoder are passed through the fourth iterative feature attention interaction module to obtain the fourth intermediate feature, the fourth intermediate feature is passed through the third upsampling layer to obtain the generated font image.

2. The intelligent font generation method based on generative adversarial network and glyph skeleton transformation according to claim 1 is characterized in that: Inputting the source font image into a font skeleton extraction algorithm based on the maximum inscribed circle rule and the connectivity criterion to extract a font skeleton image specifically includes: S11, in a single-pixel glyph outline in a pixel grid of the source font image, assuming that the contour point closest to a pixel point P in the single-pixel glyph outline by Euclidean distance is Q, the 8-neighborhood point set of point P is {P1, P2, ..., P8}, and the point set of the contour point closest to each point in {P1, P2, ..., P8} by Euclidean distance in the shape outline is {Q1, Q2, ..., Q8}; S12, for any point Q in {Q1,Q2,...,Q8} i Perform the maximum inscribed circle rule judgment, i = 1, 2, ..., 8, as shown in the following formula: D 2 =(Q x -Q ix ) 2 +(Q y -Q iy ) 2 ; Where D represents the point Q and point Q i The distance between x represents the horizontal coordinate of point Q, Q y represents the ordinate of point Q, Q ix Indicates point Q i The horizontal axis, Q iy Indicates point Q i The vertical axis of β represents the dynamically adjustable residual distance threshold, D avg Represents the average value of the distance between all contour points and point P within a certain distance; The conditions for satisfying the maximum circle rule are: D 2 ≥β; S13, for all points Q that satisfy the maximum circle rule in step S12 i Connectivity criteria are determined as shown in the following formula: d x =abs(Q x -Q ix ); d y =abs(Q y -Q iy ); Among them, d x Represents point Q and point Q i The difference in the horizontal coordinates, d y Represents point Q and point Q i The difference in the ordinate of , abs represents the absolute value function; The conditions for satisfying the connectivity criterion are: r2 2 -r1 2 ≤max(d x ,d y ); Among them, r1 represents the distance between point Q and point P, r2 represents the distance between point Q and point P, i The distance between the point P and max means taking the maximum value. The point P that satisfies the conditions of the maximum circle rule and the connectivity criterion is the skeleton point. S14, repeating steps S11 to S13 until skeleton points are determined for all pixels in the outline, and all skeleton points are found. The set of all skeleton points is the skeleton image of the glyph.

3. The intelligent font generation method based on generative adversarial network and glyph skeleton transformation according to claim 1 is characterized in that: The first convolution module includes a convolution layer with a convolution kernel size of 7×7, an instance normalization layer and a ReLU activation function layer connected in sequence; the structures of the second convolution module, the third convolution module, the first upsampling layer and the second upsampling layer are all 3×3 convolution layers, instance normalization layers and ReLU activation function layers connected in sequence; the third upsampling layer includes a convolution layer with a convolution kernel size of 7×7, an instance normalization layer and a Tanh activation function layer connected in sequence, and the residual module includes six residual blocks connected in sequence.

4. The intelligent font generation method based on generative adversarial network and glyph skeleton transformation according to claim 1 is characterized in that: The first iterative feature attention interaction module, the second iterative feature attention interaction module, the third iterative feature attention interaction module and the fourth iterative feature attention interaction module are all iterative feature attention interaction structures, and the iterative feature attention interaction structure includes a splicing layer, a convolution layer with a convolution kernel size of 3×3, an instance normalization layer, a ReLU activation function layer and a refinement fusion module, and the refinement fusion module includes a refinement MS-CAM module and a fusion module connected in sequence, and the calculation process of the refinement MS-CAM module is as follows: Wherein, X represents the input feature of the refined MS-CAM module, M(X) represents the refinement operation, L(X) represents the local attention feature, σ represents the sigmoid activation function, G(X) represents the global attention feature, and Y represents the refined feature output by the refined MS-CAM module; The calculation process of the local attention feature is expressed as: L(X)=IN(PWConv2(ReLU(IN(PWConv1(X))))); The calculation process of the global attention feature is expressed as: G(X)=AAP(IN(PWConv2(ReLU(IN(PWConv1(AAP(X))))))); Among them, IN represents the instance normalization layer, ReLU represents the ReLU activation function layer, and PWConv j represents the jth convolution operation with a convolution kernel of 1×1, and AAP represents the adaptive average pooling layer; The input features of the iterative feature attention interaction structure include a first input feature X1 and a second input feature. After the second input feature and the first input feature pass through the splicing layer, a first splicing feature is obtained. The splicing feature passes through a convolution layer with a convolution kernel size of 3×3, an instance normalization layer, and a ReLU activation function layer in sequence to obtain a second splicing feature X2. The first input feature X1 and the second splicing feature X2 are respectively input into the refinement MS-CAM module as input features of the refinement MS-CAM module to obtain a first refinement feature Y1 and a second refinement feature Y2. The first refined feature Y1 and the second refined feature Y2 are input into the fusion module, which includes a first fusion module and a second fusion module. The first refined feature Y1 and the second refined feature Y2 are passed through the first fusion module to obtain a fusion feature, as shown in the following formula: in, represents the fusion feature, Indicates pixel-level multiplication; The first refined feature Y1, the second refined feature Y2 and the fusion feature are passed through the second fusion module to obtain the output feature of the iterative feature attention interaction structure, as shown in the following formula: Wherein, Z represents the output feature of the iterative feature attention interaction structure.

5. The intelligent font generation method based on generative adversarial network and glyph skeleton transformation according to claim 1, characterized in that: The content discriminator and style discriminator both adopt the PatchGAN network structure.

6. The intelligent font generation method based on generative adversarial network and glyph skeleton transformation according to claim 1, characterized in that: During the training process of the cyclic generative adversarial network, the loss function Loss used by the discriminator desc for Where E represents the calculation loss, MSE represents the mean square error loss function, J represents a matrix whose elements are all 1, I represents a matrix whose elements are all 0, p∈P1 represents selecting a source font image p from the source font image set P1, q∈P2 means selecting a style font image q from the style font image set P2, p s Represents the glyph skeleton image of p, q s The glyph skeleton image of q, D c represents the content discriminator, D s represents the style discriminator; G p represents the style transfer of the font generator to the source font image p; The loss function used by the font generator is Loss total for: Loss total =λ1Loss adv +λ2Loss sr +λ3Loss ec +λ4Loss cyc ; Among them, Loss adv Represents the adversarial loss function, Loss sr Represents the style reconstruction loss function, Loss ec Represents the encoder consistency loss function, Loss cyc represents the structural consistency loss function, λ1, λ2, λ3, and λ4 represent the weights corresponding to the adversarial loss function, the style reconstruction loss function, the encoder consistency loss function, and the structural consistency loss function, respectively; The adversarial loss function is expressed as: Among them, G q represents the style transfer of the font generator to the style font image q; The encoder consistency loss function is expressed as: Among them, p t ∈P1,q t ∈P2 means selecting two images p with the same content from the source font image set P1 and the style font image set P2 t and q t , Indicates p t The glyph skeleton image of Indicates q t The glyph skeleton image of Indicates that the input is The output features of the content encoder when Indicates that the input is The output feature of the content encoder, ‖·‖1 represents the L1 norm; The style reconstruction loss function is expressed as: The structural consistency loss function is expressed as:

7. An intelligent font generation device based on generative adversarial network and glyph skeleton transformation, characterized in that: include: A data extraction module is configured to obtain a source font image and a style font image, input the source font image into a glyph skeleton extraction algorithm based on a maximum inscribed circle rule and a connectivity criterion, and extract a glyph skeleton image; A model building module is configured to build a recurrent generative adversarial network consisting of a font generator and a discriminator, wherein the discriminator includes a content discriminator and a style discriminator, and the recurrent generative adversarial network is trained to obtain a trained font generator and a trained discriminator, wherein the font generator includes a content encoder, a style encoder, and an image restoration decoder, wherein the content encoder and the style encoder each include a first convolution module, a second convolution module, a third convolution module, and a self-attention module connected in sequence, and the image restoration decoder includes a first iterative feature attention interaction module, a residual module, a second iterative feature attention interaction module, a first upsampling layer, a third iterative feature attention interaction module, a second upsampling layer, a fourth iterative feature attention interaction module, and a third upsampling layer connected in sequence; The generation module is configured to input the glyph skeleton image and the style font image into the trained font generator, the glyph skeleton image is input into the content encoder, and sequentially passes through the first convolution module, the second convolution module, the third convolution module and the self-attention module in the content encoder to extract the glyph skeleton feature, the style font image is input into the style encoder, and sequentially passes through the first convolution module, the second convolution module, the third convolution module and the self-attention module in the style encoder to extract the font style feature, the glyph skeleton feature and the font style feature, as well as the output feature of the first convolution module and the output feature of the second convolution module in the content encoder are input into the image restoration decoder together, the glyph skeleton feature and the font style feature pass through the first iterative feature attention interaction module to obtain the first intermediate feature, and the first intermediate feature is obtained. The intermediate feature passes through the residual module to obtain the output feature of the residual module, the output feature of the residual module and the first intermediate feature pass through the second iterative feature attention interaction module to obtain the second intermediate feature, the second intermediate feature passes through the first upsampling layer to obtain the output feature of the first upsampling layer, the output feature of the first upsampling layer and the output feature of the first convolution module in the content encoder pass through the third iterative feature attention interaction module to obtain the third intermediate feature, the third intermediate feature passes through the second upsampling layer to obtain the output feature of the second upsampling layer, the output feature of the second upsampling layer and the output feature of the second convolution module in the content encoder pass through the fourth iterative feature attention interaction module to obtain the fourth intermediate feature, the fourth intermediate feature passes through the third upsampling layer to obtain the generated font image.

8. An electronic device comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Cross-language small sample font generation method and system based on external attention mechanism and storage medium

    CN118194820A

  • Interpretable few-sample font generation method based on stroke order dynamic learning

    CN118351553A

  • Method and apparatus for processing image using cycle generative adversarial network

    KR102490503B1

Cited By

  • Generative adversarial network-based few-sample font generation and copyright protection method

    CN120451332A