Generative adversarial network-based few-sample font generation and copyright protection method
By optimizing the self-attention mechanism and introducing spatial relationship embedding vectors, combining style encoder and content encoder to generate high-quality Chinese character fonts, and copyright protection is carried out through watermark decoding networks, the structural accuracy and style consistency problems in the generation of few-sample fonts are solved, and component-level supervision and copyright protection are achieved.
Patent Information
- Application Number
- CN202510592111.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2045-05-09
AI Technical Summary
The existing font generation technology is difficult to effectively capture the fine structural characteristics of Chinese characters in a small sample scenario, and lacks flexible and effective decoupling methods of style and content features, resulting in insufficient structural accuracy and style consistency of generated fonts. At the same time, it lacks perfect copyright protection methods, making it difficult to effectively protect the intellectual property rights of the generative model.
Optimize the self-attention mechanism by introducing learnable spatial relationship embedding vectors and shape size correction factors, combine the style encoder and the content encoder to extract features, use the feature mixer to generate the target font image, and copyright protection is carried out through the watermark decoding network, ensuring that the generated font image is accurate and style unified at the component level.
It improves the quality and style generalization performance of Chinese character font generation, realizes component-level supervision and refined optimization, ensures that the generated font images are accurate in component structure, reasonable layout and unified in style, and provides effective copyright protection to prevent model intellectual property rights from being infringed.
Smart Images

Figure CN120451332A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of font generation technology, and in particular to a method for generating and copyright protecting a small number of font samples based on a generative adversarial network. Background Art
[0002] In recent years, generative adversarial networks (GANs) have made significant progress in the field of image generation and are widely used in tasks such as image synthesis, style transfer, and image restoration. In the field of font generation, GAN technology has shown great potential, achieving high-quality font image generation by learning and imitating different font styles. However, existing font generation technologies generally only achieve good results with the support of large-scale training data, and their performance in scenarios with few samples is significantly insufficient. In addition, traditional GAN models have difficulty effectively capturing the fine structural features of complex characters such as Chinese characters, resulting in the structural accuracy and style consistency of generated fonts failing to meet the requirements of practical applications.
[0003] At the same time, with the widespread application of generative models, copyright protection issues have gradually become prominent. Because the development of generative models usually requires a large amount of data, computing resources and expertise, these models themselves have become important intellectual property assets. Currently, digital watermarking technology has been widely used in the field of digital media copyright protection and is gradually being used to protect the intellectual property rights of deep neural network models. Existing neural network watermarking technologies are mainly divided into two categories: white box and black box. White box watermarks require access to the internal parameters of the model, while black box watermarks only need to check the model's output in response to specific trigger signals. Therefore, black box watermarks are more practical in practical applications. However, current watermarking technologies are mostly focused on discriminative neural networks, and watermark protection for generative models, especially GANs, still faces challenges.
[0004] Existing methods have difficulty effectively extracting fine-grained style features of fonts under few-shot conditions, and lack a flexible and effective method for decoupling style and content features, resulting in insufficient cross-language generalization performance of the model. Secondly, traditional attention mechanisms mainly focus on feature similarity, ignoring the complex spatial relationships and shape and size information between font components, making it difficult to achieve high-precision structure generation and style consistency control. In addition, existing font generation methods lack a refined component-level supervision mechanism, and it is difficult to effectively guarantee the accuracy of the generated font structure through overall image-level judgment alone. Finally, current generative model copyright protection methods are not perfect, and research on black-box watermarking technology for generative models is limited, making the model's intellectual property rights extremely vulnerable to infringement, severely limiting the practical application value of generative models. Therefore, there is an urgent need to propose a technical solution that can effectively solve the problems of few-shot font generation quality, precise supervision of font component structure, and copyright protection. Summary of the Invention
[0005] In view of this, the present invention aims to propose a few-shot font generation and copyright protection method based on generative adversarial networks to solve the problems of low font generation quality and font component structure accuracy of generative adversarial networks and imperfect copyright protection measures.
[0006] To achieve the above object, the technical solution of the present invention is achieved as follows:
[0007] A method for generating and protecting copyrights of a few-shot fonts based on a generative adversarial network, comprising:
[0008] Step 1: Optimize the attention mechanism based on spatial perception by introducing a learnable spatial relationship embedding vector and a shape and size correction factor to optimize the original self-attention mechanism;
[0009] Step 2: Attention-enhanced style and content feature extraction. Based on the optimized spatially aware attention mechanism, the style encoder and content encoder are used to extract style features and component-level content features from the reference font and content image, respectively.
[0010] Step 3: Feature fusion and target font generation: Use the feature mixer to fuse the extracted style features with the content features, and generate the target font image through feature mapping and decoding processes;
[0011] Step 4: Pre-training and optimization of the watermark decoding network. The encoder-decoder architecture is used to pre-train the watermark decoding network for embedding and extracting watermark information.
[0012] Step 5: Watermark embedding and font generation model copyright protection. Integrate the pre-trained watermark decoding network into the font generation model, and optimize the generator through backpropagation so that the generated font image contains a digital watermark.
[0013] Furthermore, according to the optimization of the attention mechanism based on spatial perception in step 1, the original self-attention mechanism is optimized by introducing a learnable spatial relationship embedding vector and a shape size correction factor. The specific steps include:
[0014] By measuring the difference in area, perimeter and aspect ratio between components, a shape size correction factor is obtained. The component distance measurement is optimized and evaluated using the shape size correction factor to obtain the optimized component distance.
[0015] The spatial relationship weights are obtained by evaluating the spatial relationship of component distances through a multi-layer perceptron. The spatial relationship weights are then combined with the original attention weights to obtain the optimized attention weights.
[0016] Furthermore, according to the above, by measuring the difference in area, perimeter and aspect ratio between the components, a shape size correction factor is obtained, and the specific steps include:
[0017] Obtain the area, perimeter, and aspect ratio of any two font components, and calculate the result of dividing the absolute value of the subtraction of the areas of the any two font components by the maximum value of the areas of the any two font components as the first area difference of the any two font components; calculate the result of dividing the absolute value of the subtraction of the perimeters of the any two font components by the maximum value of the perimeters of the any two font components as the first perimeter difference of the any two font components; and calculate the result of dividing the absolute value of the subtraction of the aspect ratios of the any two font components by the maximum value of the aspect ratios of the any two font components as the first aspect ratio difference of the any two font components;
[0018] Respectively obtain learnable weight parameters of the first area difference, the first perimeter difference, and the first aspect ratio difference of the font components, perform weighted summation on the first area difference, the first perimeter difference, and the first aspect ratio difference between the font components using the learnable weight parameters of the first area difference, the first perimeter difference, and the first aspect ratio difference, and perform Sigmoid activation function mapping on the result of the weighted summation and the learnable bias term as a calculation result of the shape size difference measure of any two font components; and use the shape size difference measure of any two font components plus a constant 1 as a shape size correction factor.
[0019] Furthermore, the component distance metric is optimized and evaluated based on the shape and size correction factor to obtain the optimized component distance, and the specific steps include:
[0020] The center point coordinates of any two font components are obtained through the component perception module, and the Euclidean distance of the center point coordinates of any two font components is divided by the diagonal length of the glyph image as the relative distance between the any two font components; the shape and size correction factors of the any two font components are obtained, and the result of multiplying the relative distance between the any two font components by the shape and size correction factor is used as the optimized component distance between the any two font components.
[0021] Furthermore, the spatial relationship weights are obtained by evaluating the spatial relationship of the component distances using a multi-layer perceptron, and the optimized attention weights are obtained by combining the spatial relationship weights with the original attention weights. The specific steps include:
[0022] Obtain the spatial relationship embedding vector between any two font components, map the spatial relationship embedding vector to the optimized component distance between the two components through a multi-layer perceptron, and use the mapping result to perform Sigmoid activation function mapping as the result of the spatial relationship weight between the two font components; the calculation formula for obtaining the optimized attention weight by combining the spatial relationship weight with the original attention weight is:
[0023] ;
[0024] in, represents the query vector matrix; key vector matrix; represents a matrix of value vectors; represents the scaling factor; express Normalization function; represents the transpose of the key vector matrix; Represents the dot product of matrices; Represents the spatial relationship weight matrix.
[0025] Furthermore, the multilayer perceptron includes two hidden layers, wherein the input of the input layer is the spatial relationship embedding vector and the distance between components, the dimension of the first hidden layer is 32, the dimension of the second hidden layer is 16, the dimension of the output layer is 1, and the output value of the output layer is mapped through the Sigmoid activation function, and the mapped value is used as the spatial relationship weight.
[0026] Furthermore, according to the feature fusion and target font generation in step 3, the extracted style features and content features are fused using a feature mixer, and a target font image is generated through feature mapping and decoding processes, including:
[0027] The font generator is supervised by the component extraction part and the multi-component level discriminator in the component perception module; the style features and content features of the reference font and content image are obtained, the style features and the content features are fused through the mixer, and the target glyph is generated through the generator.
[0028] Compared with the prior art, the present invention has the following advantages:
[0029] The present invention discloses a method for generating and protecting fonts using a generative adversarial network (GAN) based on a few-shot approach. By optimizing the self-attention mechanism and introducing learnable spatial relationship embedding and shape size correction factors, the method improves the network model's ability to capture the structural features of Chinese fonts, thereby enhancing the quality and style generalization performance of font generation in few-shot scenarios. The introduction of a component perception module in the present invention implements component-level supervision and refined optimization of the font generation process. Through component extraction and multi-component-level discriminators, the method ensures that the generated font image is accurate in component structure, reasonably laid out, and has a unified style, effectively avoiding the structural errors and style inconsistencies common in traditional GAN font generation methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The accompanying drawings, which constitute part of the present invention, are provided to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are provided to explain the present invention and do not constitute an undue limitation of the present invention. In the accompanying drawings:
[0031] Figure 1 A flowchart of a method for font generation and copyright protection based on a generative adversarial network according to an embodiment of the present invention;
[0032] Figure 2 This is a diagram illustrating the model generalization capability experiment of the font generation and copyright protection method using the Generative Adversarial Network according to an embodiment of the present invention;
[0033] Figure 3 A qualitative evaluation diagram of font generation and copyright protection method using a generative adversarial network according to an embodiment of the present invention;
[0034] Figure 4 A robustness evaluation diagram of the font generation and copyright protection method using the generative adversarial network according to an embodiment of the present invention; DETAILED DESCRIPTION
[0035] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0036] In the description of the present invention, it should be noted that the terms "upper," "lower," "inner," and "back" and other terms indicating orientations or positional relationships are based on the orientations or positional relationships shown in the accompanying drawings and are intended solely to facilitate and simplify the description of the present invention. They are not intended to indicate or imply that the devices or components referred to must have, be constructed, or operate in a specific orientation, and therefore should not be construed as limitations on the present invention. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0037] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0038] See also Figure 1 , is a flow chart of a method for generating a few-sample font and copyright protection based on a generative adversarial network provided in the first embodiment of the present invention, such as Figure 1 As shown, a method for generating and protecting copyrights using a few-shot font generation method based on a generative adversarial network may include:
[0039] Step S1: Optimize the original self-attention mechanism by introducing a learnable spatial relationship embedding vector and a shape size correction factor.
[0040] Based on In the few-shot font generation task, both the style encoder and the content encoder adopt the self-attention mechanism ( ) to capture the dependencies between different regions in the input image. The core of the self-attention mechanism is the scaled dot-product attention ( ), and this formula determines the attention weights by calculating the dot product between the query vector ( , the key vector ( ), and the value vector ( ). However, there is an obvious limitation when the standard scaled dot-product attention formula is applied to Chinese character font generation: it mainly focuses on the similarity between feature vectors and ignores the spatial position relationship between features.
[0041] Specifically, when calculating the attention weights, the standard scaled dot-product attention formula only considers the dot product between the query vector and the key vector, and this dot product reflects the feature similarity of the two vectors. However, in Chinese character font generation, only considering feature similarity is not enough. Chinese characters are composed of multiple components combined according to a certain spatial structure. For example, the character "明" is composed of two components, "日" and "月", arranged side by side, and the character "字" is composed of two components, "宀" and "子", arranged one above the other. The spatial relationship between these components is crucial for the structure of the font. If the attention mechanism cannot effectively capture these spatial relationships, it will lead to chaotic structures in some of the generated fonts or incorrect relative positions between components.
[0042] Step S1.1: By performing difference measurements on the area difference, perimeter difference, and aspect ratio difference between components, a shape and size correction factor is obtained, and the component distance measurement is optimized and evaluated through the shape and size correction factor to obtain the optimized component distance.
[0043] In Chinese character fonts, the shape and size of components are important factors affecting visual perception. Even if the center points of two components are very close, if their shapes or sizes are very different, they will still give people different visual feelings, and their spatial relationships should also be different. For example, a long and thin vertical line component and a short and thick square component, even if their center points coincide, their roles in the glyph and their interactions with other components are completely different. Therefore, it is necessary to further improve the distance measurement method so that it can reflect the shape and size information of components.
[0044] First, the area, perimeter and aspect ratio of any two font components are obtained, and the absolute value of the subtraction of the areas of the any two font components is divided by the maximum area of the any two font components as the first area difference of the any two font components; the absolute value of the subtraction of the perimeters of the any two font components is divided by the maximum perimeter of the any two font components as the first perimeter difference of the any two font components; the absolute value of the subtraction of the aspect ratios of the any two font components is divided by the maximum aspect ratio of the any two font components as the first aspect ratio difference of the any two font components; respectively obtain the learnable weight parameters of the first area difference, first perimeter difference and first aspect ratio difference of the font components, and perform weighted summation on the first area difference, first perimeter difference and first aspect ratio difference between the font components using the learnable weight parameters of the first area difference, first perimeter difference and first aspect ratio difference of the font components. The result of the weighted summation and the learnable bias term are mapped to the Sigmoid activation function, and the result of the calculation is used as the shape size difference measure of any two font components; the result of the shape size difference measure of any two font components plus the constant 1 is used as the shape size correction factor.
[0045] In one embodiment, assuming that The area of a font component is , the perimeter is , with an aspect ratio of ;No. The area of a font component is , the perimeter is , with an aspect ratio of ; Area difference weight parameter is , the weight parameter of the perimeter difference is , the weight parameter of the aspect ratio is , then The font component and The calculation expression of the shape size correction factor between font components is:
[0046] ;
[0047] in, Indicates the The font component and Shape size correction factors between font components; express Activation function; A weight parameter representing the difference in perimeter between font components; Indicates the The area of each font component; Indicates the The area of each font component; represents the maximum value function; A weight parameter representing the difference in perimeter between font components; Indicates the The perimeter of each font component; Indicates the The perimeter of each font component; A weight parameter representing the aspect ratio between font components; Indicates the The aspect ratio of each font component; Indicates the The aspect ratio of each font component; represents the learnable bias term; Indicates absolute value calculation; Indicates the The font component and a first area difference between the font components; Indicates the The font component and The difference in first perimeter between font components; Indicates the The font component and The first aspect ratio difference between the font components.
[0048] It should be noted that in Chinese fonts, the shape and size of components are important factors influencing visual perception. Even if two components are very close in center, if their shapes or sizes differ significantly, they will still appear visually distinct, and their spatial relationships should also be distinct. For example, a thin vertical line component and a thick square component, even if their centers coincide, play completely different roles in the glyph and interact with other components. Therefore, improved distance metrics are needed to reflect component shape and size information. The more similar the shapes and sizes of two components, the closer the correction factor is to 1, reducing the impact on distance. The greater the difference in shape and size between the two components, the larger the correction factor, increasing the distance. Furthermore, the area, perimeter, and aspect ratio of the font components described above are determined based on the bounding box information provided by the component perception module for each component. The component's minimum bounding rectangle is calculated, and the area of the minimum bounding rectangle is used as the component's area, the perimeter of the minimum bounding rectangle is used as the component's perimeter, and the aspect ratio of the minimum bounding rectangle is used as the component's aspect ratio.
[0049] After obtaining the shape and size correction factor, the component distance metric can be optimized and evaluated using the shape and size correction factor to obtain the optimized component distance, including:
[0050] The center point coordinates of any two font components are obtained through the component perception module, and the Euclidean distance of the center point coordinates of any two font components is divided by the diagonal length of the glyph image as the relative distance between the any two font components; the shape and size correction factors of the any two font components are obtained, and the result of multiplying the relative distance between the any two font components by the shape and size correction factor is used as the optimized component distance between the any two font components.
[0051] In one embodiment, assuming that The center point coordinates of the font component are With the The center point coordinates of the font component are , then the calculation expression of the optimized component distance is:
[0052] ;
[0053] in, Indicates the The font component and Optimized component distance between font components; Indicates the The font component and Shape size correction factors between font components; Indicates the The center point coordinates of each font component; Indicates the The center point coordinates of each font component; Indicates the diagonal length of the glyph image; Indicates the The font component and The Euclidean distance between font components.
[0054] After obtaining the optimized component distance, the spatial relationship of the component distance can be evaluated through a multi-layer perceptron to obtain the spatial relationship weight. The spatial relationship weight is then combined with the original attention weight to obtain the optimized attention weight. The specific steps include:
[0055] Obtain a spatial relationship embedding vector between any two font components, map the spatial relationship embedding vector to the optimized component distance between the any two components through a multi-layer perceptron, and perform Sigmoid activation function mapping on the mapping result as the spatial relationship weight between the any two font components.
[0056] In one embodiment, the The font component and The calculation expression of the spatial relationship weight between font components is:
[0057] ;
[0058] in, Indicates the The font component and The weight of the spatial relationship between font components; Presentation Component and components The spatial relationship between them is embedded in a vector, which is automatically learned through the feedback propagation process of the neural network and does not need to be set; Indicates the The font component and Optimized component distance between font components; represents a multilayer perceptron; express Activation function.
[0059] It should be noted that the multilayer perceptron contains two hidden layers, where the input of the input layer is the spatial relationship embedding vector and the distance between components. The dimension of the first hidden layer is 32, the dimension of the second hidden layer is 16, and the dimension of the output layer is 1. The output value of the output layer is mapped through the Sigmoid activation function, and the mapped value is used as the spatial relationship weight.
[0060] After obtaining the spatial relationship weight, the optimized attention weight can be obtained by combining the spatial relationship weight with the original attention weight. The calculation expression of the attention weight is:
[0061] ;
[0062] in, represents the query vector matrix; key vector matrix; represents a matrix of value vectors; represents the scaling factor; express Normalization function; represents the transpose of the key vector matrix; Represents the dot product of matrices; Represents the spatial relationship weight.
[0063] It should be noted that in order to integrate the learned spatial relationship embedding vector into the attention calculation, a small neural network (multi-layer perceptron, ).this It takes as input the spatial relationship embedding vector and the relative distance between components and outputs a scalar value as the spatial relationship weight. This combines the spatial relationship embedding vector and relative distance information to determine the attention weight. Finally, the calculated spatial relationship weight is element-wise multiplied with the original attention weight (i.e., the result of the scaled dot product attention calculation), incorporating the spatial relationship information into the final attention weight. This allows the attention mechanism to consider not only the similarity of feature vectors but also the spatial relationship between components when calculating the weight. This allows it to more accurately capture the structural characteristics of Chinese characters and improve the quality of generated fonts.
[0064] In step S2, based on the optimized spatial-aware attention mechanism, the style encoder and content encoder are used to extract style features and content features from the reference font and content image respectively.
[0065] First, a style encoder uses a convolutional neural network (CNN) to extract features. The network architecture can include multiple convolutional layers, pooling layers, and fully connected layers. Convolutional layers extract low-level and high-level features, pooling layers reduce the dimensionality of the feature map, and fully connected layers output the final style feature vector. Furthermore, to enhance the expressiveness of style features, the present invention introduces the attention mechanism optimized in step S1 into the network. The main task of the style encoder is to extract style features from reference font images and learn font style similarity in an embedding space through metric learning.
[0066] The content encoder also uses a convolutional neural network (CNN) to extract features. The network structure consists of multiple convolutional and pooling layers, and an attention mechanism is applied after each convolutional layer to enhance focus on important components. Ultimately, the content encoder outputs a content feature map for subsequent feature fusion. The content encoder is responsible for extracting component-level content features from the content image. Through the attention mechanism, the content encoder achieves fine-grained feature extraction at the component level. The content encoder converts the content image into a content feature map.
[0067] In step S3, the extracted style features and content features are fused using a feature mixer, and a target font image is generated through a feature mapping and decoding process.
[0068] The font generator is supervised by the component extraction part of the component perception module and a multi-component-level discriminator. The style and content features of the reference font and content image are obtained, fused by a mixer, and the target glyph is generated by the generator. The discriminator guides the generator to produce realistic glyph images through adversarial learning. The discriminator not only distinguishes the generated images from real images but also provides style guidance to the generator through an integrated style encoder.
[0069] In step S4, an encoder-decoder architecture is used to pre-train a watermark decoding network for embedding and extracting watermark information.
[0070] Pre-train a watermark decoding network. The main task of this network is to successfully embed watermark information into the generated image without significantly affecting the image quality, and to be able to accurately extract the watermark information when needed. The watermark decoding network adopts an encoder-decoder architecture and is implemented using the StegaStamp network.
[0071] In step S5, the pre-trained watermark decoding network is integrated into the font generation model, and the generator is optimized through back propagation so that the generated font image contains a digital watermark to protect the model copyright.
[0072] The pre-trained watermark decoding network is effectively integrated with the font generation model. Specifically, the encoder portion of the watermark decoding network is added after the font generator output layer. The generator parameters are jointly optimized through backpropagation, so that the generated font images are automatically and covertly embedded with the predefined digital watermark information. This approach ensures that the generated font images are visually indistinguishable from the unwatermarked images, while still containing robust and covert digital watermark information. This effectively protects the copyright of the generated font model and prevents unauthorized misuse or infringement of the model's intellectual property.
[0073] To evaluate our approach on the Chinese font generation task and to more easily demonstrate the effectiveness of our proposed method, we used a dataset of 423 fonts collected using CG-GAN. Following the experimental design used in CG-GAN, we randomly selected 399 fonts as the training set (i.e., seen fonts), each containing 800 Chinese characters that can be decomposed into 385 components (i.e., seen characters). Our one-shot Chinese font generation capabilities were evaluated on two test sets: one consisting of the 399 seen fonts, each containing 150 unseen characters; and the other consisting of the remaining 24 unseen fonts, each containing 200 unseen characters. We also used a Korean glyph test set consisting of 24 unseen fonts, each containing 200 Korean characters, to evaluate generalization to glyphs from unseen languages.
[0074] The proposed model is compared with four state-of-the-art methods, including three few-shot Chinese font generation methods (LF-font, MX-Font, CG-GAN) and an unsupervised image-to-image translation method (FUNIT). For fair comparison, the proposed model uses Songti as the source font, which is a common setting in font generation tasks. LF-Font has low visual quality if only one reference sample is provided during inference. Therefore, its performance is evaluated under an eight-sample setting (its original setting) and a single-sample setting. All models are trained from scratch using their official codes. In each iteration, a sample containing and Mini-batch samples of . Select and , so that they belong to the same font style , but the character content is different. Select , so that it has Different font styles , but the character content is the same. In order to calculate ,use As an anchor point, As a positive sample, As negative samples, we reused As a generator By inputting Feed into the discriminator And from the style head Extract the characteristics and obtain the style features . Used to update the discriminator The adversarial loss is obtained by (fake sample) and (true samples) calculated and used to update the generator The adversarial loss is obtained by (True sample) calculated and reused Image as and The true value of the loss. R1 regularization is used for the discriminator. For stable training, the learning rate of the Adam optimizer is set to 0.002. and .
[0075] We conducted this experiment to verify whether the proposed method can produce high-quality results on characters from languages that have not been seen before. The model was trained on Chinese character images, but during inference, the trained model was fed with Korean (Hangul) characters, which the model had not seen before. Figure 2As shown, the proposed model is also effective for Korean character generation, and the network is able to transfer the style of the Chinese reference glyphs to the unseen Korean source glyphs. This experiment shows that the proposed model has strong generalization capabilities and can effectively separate the content and style of glyph images.
[0076] In the watermark protection experiment, the goal was to apply the proposed watermark embedding method for protecting intellectual property rights using generative adversarial networks (GANs) to the combined font generation model to verify its effectiveness and robustness. Specifically, the method's watermark embedding performance in the font generation task was evaluated, and its robustness and watermark bit accuracy under various post-processing operations were tested. To optimize watermark embedding and extraction for the generated fonts, pre-training was performed using multiple publicly available image datasets. These datasets included 200k CelebA (128×128 resolution), 70k FFHQ (256×256 resolution), 500k LSUN-bedroom (256×256 resolution), and 8k VGG flowers (128×128 resolution). The goal of pre-training was to leverage the rich information and complex features of these large image datasets to enhance the model's generalization and robustness across diverse image styles and content. However, the small size of the font datasets did not provide sufficient samples to effectively train complex deep learning models, which limited their performance. Public image datasets such as CelebA, FFHQ, LSUN-bedroom, and VGG flowers cover a wide variety of image content and styles, providing rich training samples for the model and promoting the model's learning of various visual features.
[0077] By pre-training on these public datasets, the model is able to learn rich visual features and complex structural information, allowing it to maintain good performance even when faced with a relatively small and single font dataset. After pre-training, the model is fine-tuned to adapt to the font generation task, ensuring that an invisible watermark is embedded in the generated font image while maintaining high image quality. This pre-training and fine-tuning strategy not only improves the model's adaptability on different datasets, but also enhances the stability and robustness of watermark embedding. Specifically, pre-training enables the model to perform well when processing diverse images, while fine-tuning ensures the model's optimization effect on the Chinese and Korean font datasets used in this article. Ultimately, this method achieves the goal of embedding and extracting watermarks during the font generation process, providing an effective means of copyright protection.
[0078] The experimental results of the proposed model are based on comparing the performance of the font generation model under different settings to evaluate the effectiveness and robustness of the watermark embedding method. To objectively evaluate the effectiveness of watermark embedding, the proposed model experiments used the following quantitative metrics: peak signal-to-noise ratio (PSNR), channel peak signal-to-noise ratio (CPSNR), per-pixel mean squared error (MSE), structural similarity index (SSIM), and watermark extraction accuracy (WEA). The generative model was trained and evaluated in both few-shot and single-shot settings. In each setting, experiments were conducted with and without a watermark, and the quality of the generated images and the watermark extraction accuracy were compared. The following table summarizes the quantitative evaluation results under different experimental settings. The experimental data includes PSNR, CPSNR, MSE, SSIM, and WEA metrics for both few-shot and single-shot settings.
[0079]
[0080] The results in the table above show that the embedded watermark has little impact on the quality of the generated image. The PSNR and CPSNR values decrease slightly but remain at a high level, indicating that the visual quality of the generated image is similar to that of the unwatermarked image. The slight increase in the MSE value reflects subtle changes in the generated image at the pixel level, but is generally within an acceptable range. The SSIM value decreases slightly but remains high, indicating that the generated image has a high structural similarity to the real image. The WEA (Watermark Extraction Accuracy) metric shows that the embedded watermark can be reliably extracted, with a watermark extraction accuracy of 98.7% in the few-sample setting and 98.9% in the single-sample setting. This shows that the proposed method can effectively protect the intellectual property rights of generated images under different training conditions.
[0081] In order to more intuitively evaluate the quality of the generated images and the effect of watermark embedding, a qualitative analysis was conducted. The qualitative evaluation mainly uses visual comparison between the generated images and the real images to confirm whether the watermark embedding has a significant impact on the image quality and the invisibility of the watermark embedding. The font images generated by the generative model under the conditions of no watermark embedding and watermark embedding were qualitatively evaluated. Under each setting, the generator generates a set of font images from random noise, and the image quality and the concealment of the watermark are evaluated by visual comparison. The experimental results are shown in the figure below. Figure 3 shown.
[0082] Testing the impact of different image processing methods on bit accuracy and peak signal-to-noise ratio (PSNR) reveals that when trained using the processing layers, the watermark embedded in the generated images via the proposed GAN is highly robust to the processing, demonstrating improved robustness compared to methods in the literature. In particular, the watermark's bit accuracy in the proposed approach remains above 75% over a relatively wide range of perturbations, whereas when the image is subjected to very high distortion (low PSNR), the bit accuracy drops below this value, rendering the image unusable. For example, when the generated image is compressed using JPEG with a quality factor of 50, the bit accuracy is approximately 70%, which is equivalent to a single recompression in practice. Figure 4 Some examples of processed font images are shown, along with the bit accuracy of the retrieved watermarks under various very strong attacks. Figure 4 The paper presents the watermark bit accuracy and PSNR values generated using the proposed GAN embedding method for images after various image processing steps. The robustness and image quality of the watermark were evaluated after the images were subjected to various processing steps (e.g., JPEG compression, noise addition, blurring, brightness adjustment, inversion, and downsampling). The results show that the bit accuracy after JPEG compression is 65%, the bit accuracy after noise addition is 77%, the bit accuracy after blurring is 92%, the bit accuracy after brightness increase is 78%, the bit accuracy after color inversion is 90%, and the bit accuracy after downsampling is 88%. These results demonstrate that the proposed GAN embedding method maintains a watermark bit accuracy above 75% over a wide range of perturbations, with a significant drop in bit accuracy only occurring when extremely high distortion is introduced into the image. For example, the bit accuracy after JPEG compression (quality factor 50) is approximately 70%. Overall, blurring and color inversion have the least impact on the watermark, while brightness adjustment and noise addition have a greater impact. These results demonstrate that the proposed GAN embedding method can embed a robust watermark while maintaining generated image quality, effectively improving image copyright protection capabilities.
[0083] In summary, the method for few-shot font generation and copyright protection based on generative adversarial networks described in the present invention optimizes the self-attention mechanism and introduces learnable spatial relationship embedding and shape size correction factors, thereby improving the network model's ability to capture the structural features of Chinese fonts and improving the quality and style generalization performance of font generation in few-shot scenarios; the introduction of the component perception module described in the present invention realizes component-level supervision and refined optimization of the font generation process, and through component extraction and multi-component-level discriminators, ensures that the generated font image is accurate in component structure, reasonably laid out, and unified in style, effectively avoiding the common structural errors and style inconsistencies in traditional GAN font generation methods.
[0084] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for generating and protecting copyrights using a few-shot font generation method based on a generative adversarial network, characterized by: Step 1: Optimize the attention mechanism based on spatial perception by introducing a learnable spatial relationship embedding vector and a shape and size correction factor to optimize the original self-attention mechanism; Step 2: Attention-enhanced style and content feature extraction. Based on the optimized spatially aware attention mechanism, the style encoder and content encoder are used to extract style features and component-level content features from the reference font and content image, respectively. Step 3: Feature fusion and target font generation: Use the feature mixer to fuse the extracted style features with the content features, and generate the target font image through feature mapping and decoding. Step 4: Pre-training and optimization of the watermark decoding network. The encoder-decoder architecture is used to pre-train the watermark decoding network for embedding and extracting watermark information. Step 5: Watermark embedding and font generation model copyright protection. Integrate the pre-trained watermark decoding network into the font generation model, and optimize the generator through backpropagation so that the generated font image contains a digital watermark.
2. The method for generating a few-shot font and protecting copyright based on a generative adversarial network according to claim 1, wherein: According to the spatial perception-based attention mechanism optimization in step 1, the original self-attention mechanism is optimized by introducing a learnable spatial relationship embedding vector and a shape size correction factor. The specific steps include: By measuring the difference in area, perimeter and aspect ratio between components, a shape size correction factor is obtained. The component distance measurement is optimized and evaluated using the shape size correction factor to obtain the optimized component distance. The spatial relationship weights are obtained by evaluating the spatial relationship of component distances through a multi-layer perceptron. The spatial relationship weights are then combined with the original attention weights to obtain the optimized attention weights.
3. The method for generating a few-shot font and protecting copyright based on a generative adversarial network according to claim 2, wherein: According to the above, by measuring the difference in area, perimeter and aspect ratio between components, a shape size correction factor is obtained, and the specific steps include: Obtain the area, perimeter, and aspect ratio of any two font components, and calculate the result of dividing the absolute value of the subtraction of the areas of the any two font components by the maximum value of the areas of the any two font components as the first area difference of the any two font components; calculate the result of dividing the absolute value of the subtraction of the perimeters of the any two font components by the maximum value of the perimeters of the any two font components as the first perimeter difference of the any two font components; and calculate the result of dividing the absolute value of the subtraction of the aspect ratios of the any two font components by the maximum value of the aspect ratios of the any two font components as the first aspect ratio difference of the any two font components; Respectively obtain learnable weight parameters of the first area difference, the first perimeter difference, and the first aspect ratio difference of the font components, perform weighted summation on the first area difference, the first perimeter difference, and the first aspect ratio difference between the font components using the learnable weight parameters of the first area difference, the first perimeter difference, and the first aspect ratio difference, and perform Sigmoid activation function mapping on the result of the weighted summation and the learnable bias term as a calculation result of the shape size difference measure of any two font components; and use the shape size difference measure of any two font components plus a constant 1 as a shape size correction factor.
4. The method for generating a few-shot font and protecting copyright based on a generative adversarial network according to claim 3, wherein: The optimized component distance is obtained by optimizing and evaluating the component distance metric using the shape and size correction factor, and the specific steps include: The center point coordinates of any two font components are obtained through the component perception module, and the Euclidean distance of the center point coordinates of any two font components is divided by the diagonal length of the glyph image as the relative distance between the any two font components; the shape and size correction factors of the any two font components are obtained, and the result of multiplying the relative distance between the any two font components by the shape and size correction factor is used as the optimized component distance between the any two font components.
5. The method for generating a few-shot font and protecting copyright based on a generative adversarial network according to claim 2, wherein: According to the above, the spatial relationship weight is obtained by evaluating the component distance through the multi-layer perceptron, and the optimized attention weight is obtained by combining the spatial relationship weight with the original attention weight. The specific steps include: Obtain the spatial relationship embedding vector between any two font components, map the spatial relationship embedding vector to the optimized component distance between the two components through a multi-layer perceptron, and use the mapping result to perform Sigmoid activation function mapping as the result of the spatial relationship weight between the two font components; the calculation formula for obtaining the optimized attention weight by combining the spatial relationship weight with the original attention weight is: ; in, represents the query vector matrix; key vector matrix; represents a matrix of value vectors; represents the scaling factor; express Normalization function; represents the transpose of the key vector matrix; Represents the dot product of matrices; Represents the spatial relationship weight matrix.
6. The method for generating a few-shot font and protecting copyright based on a generative adversarial network according to claim 5, characterized in that: The multilayer perceptron includes two hidden layers, wherein the input of the input layer is the spatial relationship embedding vector and the distance between components, the number of dimensions of the first hidden layer is 32, the number of dimensions of the second hidden layer is 16, the number of dimensions of the output layer is 1, and the output value of the output layer is mapped through the Sigmoid activation function, and the mapped value is used as the spatial relationship weight.
7. The method for generating a few-shot font and protecting copyright based on a generative adversarial network according to claim 1, wherein: According to the feature fusion and target font generation in step 3, the extracted style features and content features are fused using a feature mixer, and a target font image is generated through feature mapping and decoding processes, including: The font generator is supervised by the component extraction part and the multi-component level discriminator in the component perception module; the style features and content features of the reference font and content image are obtained, the style features and the content features are fused through the mixer, and the target glyph is generated through the generator.
Citation Information
Patent Citations
Multi-style font generation method
CN113837366A
Method for generating image by sensing combined space attention text
CN114387366A
Less-sample character style migration method based on associated attention
CN114742014A
Method for generating Chinese character style with natural writing property
CN116935406A
Shielding handwritten medical record Chinese character image restoration method based on gating convolution and SCPAM attention module
CN117455813A