12
CHANG ET. AL: CHINESE HANDWRITING IMITATION WITH HIERARCHICAL-GAN 1 Chinese Handwriting Imitation with Hierarchical Generative Adversarial Network Jie Chang [email protected] Yujun Gu [email protected] Ya Zhang [email protected] Yanfeng Wang [email protected] Cooperative Medianet Innovation Center(CMIC). Shanghai Jiao Tong University, Shanghai, CHINA Abstract Automatic character generation, expected to save much time and labor, is an appeal- ing solution for new typeface design. Inspired by the recent advancement in Generative Adversarial Networks (GANs), this paper proposes a Hierarchical Generative Adversar- ial Network (HGAN) for typeface transformation. The proposed HGAN consists of two sub-networks: (1) a transfer network mapping characters from one typeface to another preserving the corresponding structural information, which includes a content encoder and a hierarchical generator. (2) a hierarchical adversarial discriminator which distin- guishes samples generated by the transfer network from real samples. Considering the unique properties of characters, different from original GANs, a hierarchical structure is proposed, which output the transferred characters in different phase of generator and at the same time, making the True/False judgment not only based on the final extract- ing features but also intermediate features in discriminator. Experimenting with Chinese typeface transformation, we show that HGAN is an effective framework for font style transfer, from standard printed typeface to personal handwriting styles. 1 Introduction Designing a new Chinese Typeface is a very time-consuming task, requiring considerable efforts on manual design of benchmark characters. Automated typeface synthesis, i.e. syn- thesizing characters of a certain typeface given few manually designed samples, has been explored, however, usually based on manually extracted features [17, 18, 19, 22, 24]. These manual features heavily relies on preceding structural segmentation of characters, which it- self is a non-trivial task and heavily affected by prior knowledge. In this paper, we model typeface-transfer as an image-to-image transformation problem and attempt to directly learn the transformation end-to-end. Typically, image-to-image trans- formation involves a transfer network to map the source images to target images. A set of losses are proposed in learning the transfer network. Pixel loss is defined as pixel-wise differ- ence between the output and the corresponding ground-truth [6, 21]. The perceptual loss [7], c 2018. The copyright of this document resides with its authors. It may be distributed unchanged freely in print or electronic forms.

Chinese Handwriting Imitation with Hierarchical Generative Adversarial … · 2018. 8. 2. · ant of generative adversarial networks (e.g CycleGAN [25]), which introduce a discriminant

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Chinese Handwriting Imitation with Hierarchical Generative Adversarial … · 2018. 8. 2. · ant of generative adversarial networks (e.g CycleGAN [25]), which introduce a discriminant

CHANG ET. AL: CHINESE HANDWRITING IMITATION WITH HIERARCHICAL-GAN 1

Chinese Handwriting Imitation withHierarchical Generative Adversarial NetworkJie [email protected]

Yujun [email protected]

Ya Zhang�[email protected]

Yanfeng [email protected]

Cooperative Medianet InnovationCenter(CMIC).Shanghai Jiao Tong University,Shanghai, CHINA

Abstract

Automatic character generation, expected to save much time and labor, is an appeal-ing solution for new typeface design. Inspired by the recent advancement in GenerativeAdversarial Networks (GANs), this paper proposes a Hierarchical Generative Adversar-ial Network (HGAN) for typeface transformation. The proposed HGAN consists of twosub-networks: (1) a transfer network mapping characters from one typeface to anotherpreserving the corresponding structural information, which includes a content encoderand a hierarchical generator. (2) a hierarchical adversarial discriminator which distin-guishes samples generated by the transfer network from real samples. Considering theunique properties of characters, different from original GANs, a hierarchical structureis proposed, which output the transferred characters in different phase of generator andat the same time, making the True/False judgment not only based on the final extract-ing features but also intermediate features in discriminator. Experimenting with Chinesetypeface transformation, we show that HGAN is an effective framework for font styletransfer, from standard printed typeface to personal handwriting styles.

1 IntroductionDesigning a new Chinese Typeface is a very time-consuming task, requiring considerableefforts on manual design of benchmark characters. Automated typeface synthesis, i.e. syn-thesizing characters of a certain typeface given few manually designed samples, has beenexplored, however, usually based on manually extracted features [17, 18, 19, 22, 24]. Thesemanual features heavily relies on preceding structural segmentation of characters, which it-self is a non-trivial task and heavily affected by prior knowledge.

In this paper, we model typeface-transfer as an image-to-image transformation problemand attempt to directly learn the transformation end-to-end. Typically, image-to-image trans-formation involves a transfer network to map the source images to target images. A set oflosses are proposed in learning the transfer network. Pixel loss is defined as pixel-wise differ-ence between the output and the corresponding ground-truth [6, 21]. The perceptual loss [7],

c© 2018. The copyright of this document resides with its authors.It may be distributed unchanged freely in print or electronic forms.

Citation
Citation
{Xiao, Xiao, and Xiao} 2016
Citation
Citation
{Xu, Jiang, Jin, Lau, and Pan} 2009
Citation
Citation
{Xu, Jin, Jiang, and Lau} 2010
Citation
Citation
{Zhang, Yin, Zhang, Liu, and Bengio} 2017{}
Citation
Citation
{Zhou, Wang, and Chen} 2011
Citation
Citation
{Isola, Zhu, Zhou, and Efros} 2016
Citation
Citation
{Zhang, Isola, and Efros} 2016
Citation
Citation
{Johnson, Alahi, and Li} 2016
Page 2: Chinese Handwriting Imitation with Hierarchical Generative Adversarial … · 2018. 8. 2. · ant of generative adversarial networks (e.g CycleGAN [25]), which introduce a discriminant

2 CHANG ET. AL: CHINESE HANDWRITING IMITATION WITH HIERARCHICAL-GAN

Source Character Cycle-GAN(Unsupervised)

Ours(Supervised)

Groud-truth

source

target

a b

Left Right

Figure 1: Left: (a) target style twists strokes in source character, making they do not sharethe invariant high-frequency features though they are the same character semantically. (b)The components in blue dotted box share the same radicals but their corresponding ones (inred dotted box) with target style are quite different. Right: CycleGAN [25] captures thecorrect style but completely fail in reconstructing the topological structure between strokes,demonstrating the supervised learning manner is necessary in this specific task.

perceptual similarity [3], style&content loss [1] and VGG loss [8] are proposed to evaluatethe differences between hidden-level features and all are based on the ideology of featurematching [15]. More recently, with the proposal of GAN [4] and DCGAN [13], several vari-ant of generative adversarial networks (e.g CycleGAN [25]), which introduce a discriminantnetwork in addition to the transfer network for adversarial learning, have been successfullyapplied to image-to-image transformation including in-painting [12], de-noising [20], super-resolution [8] and others [3, 16]. While the above methods have shown great promise forvarious applications, they are not directly applicable to typeface transformation due to thefollowing domain specific characteristics.

• Different from style-transfer between natural images where the source image shareshigh-frequency features with the target image, the transformation between two differ-ent typefaces usually leads to distortion of strokes or radicals (e.g Fig 1 Left), meaningchange between different styles leads to change of high-level representations.

• For typeface transformation task, different characters may share the same radicals.This is a nice peculiarity that typeface transformation methods can leverage. However,sometimes in one certain typeface, the same radicals may appear quite differently indifferent characters. Fig 1 also presents two examples where certain radicals havedifferent appearance in different styles. It will leads to severe over-fitting if we justconsidering the global property while ignore detailed local information.

Above characteristics in this specific task leads to the complete failure of existing state-of-the-art unsupervised image transformation method: CycleGAN [25](see Fig 1 Right). Whilethe existing supervised image transformation methods can not directly apply to typefacetransformation since their poor performance on recovering the more complicated and subtledetail in Chinese characters.

To overcome the above problems, we design a Hierarchical Generative Adversarial Net-work(HGAN) for Chinese typeface transformation, consisting of a transfer network and ahierarchical discriminator (Fig. 2), both of which are fully convolutional neural networks.First, in transfer network, a hierarchical generator which generates artificial images in mul-tiple decoding layers, is proposed to help the decoder learn better representations in its hid-den layers. Specially, the hierarchical generator attempts to maximally preserve the globaltopological structure in different decoding layers simultaneously considers the local features

Citation
Citation
{Zhu, Park, Isola, and Efros} 2017
Citation
Citation
{Dosovitskiy and Brox} 2016
Citation
Citation
{Chen, Yuan, Liao, Yu, and Hua} 2017
Citation
Citation
{Ledig, Theis, Huszar, Caballero, Cunningham, Acosta, Aitken, Tejani, Totz, and Wang} 2016
Citation
Citation
{Salimans, Goodfellow, Zaremba, Cheung, Radford, and Chen} 2016
Citation
Citation
{Goodfellow, Pouget-Abadie, Mirza, Xu, Warde-Farley, Ozair, Courville, and Bengio} 2014
Citation
Citation
{Radford, Metz, and Chintala} 2015
Citation
Citation
{Zhu, Park, Isola, and Efros} 2017
Citation
Citation
{Pathak, Krahenbuhl, Donahue, Darrell, and Efros} 2016
Citation
Citation
{Zhang, Sindagi, and Patel} 2017{}
Citation
Citation
{Ledig, Theis, Huszar, Caballero, Cunningham, Acosta, Aitken, Tejani, Totz, and Wang} 2016
Citation
Citation
{Dosovitskiy and Brox} 2016
Citation
Citation
{Wang, Xu, Wang, and Tao} 2017
Citation
Citation
{Zhu, Park, Isola, and Efros} 2017
Page 3: Chinese Handwriting Imitation with Hierarchical Generative Adversarial … · 2018. 8. 2. · ant of generative adversarial networks (e.g CycleGAN [25]), which introduce a discriminant

CHANG ET. AL: CHINESE HANDWRITING IMITATION WITH HIERARCHICAL-GAN 3

decoded in hidden layers, thus enabling the transfer network to generate close to authenticcharacters instead of disordered strokes. Second, we propose a hierarchical discriminator foradversarial learning. Specifically, the discriminator introduce additional adversarial losses,each of which employs feature representations from different hidden layers. The multi-adversarial losses constitute a hierarchical form, enabling the discriminator to dynamicallymeasure the discrepancy in distribution between the generated domain and target domain,so that the hierarchical generator is trained to generate outputs with more similar statisticalcharacteristics to the targets on different level of feature representation. The main contribu-tion of our work is summarized as follows.

• We introduce a hierarchical generator in transfer network which generates multiplesets of characters based on different layers of decoded information, capturing both theglobal and local information for transfer. Correspondingly, a hierarchical discrimina-tor which involves a cascade of adversarial losses at different layers of the network,is proposed to provide complementary adversarial capability. We have experimen-tally shown that the hierarchical discriminator leads to faster model convergence andgenerates more realistic samples.

• The proposed hierarchical generative adversarial network (HGAN) is shown to besuccessful for both Chinese handwriting imitation and character restoration throughextensive experimental studies. The impact of proposed hierarchical adversarial lossis further investigated from different perspective including gradient propagation andthe ideology of adversarial training.

• Last, experiments shows HGAN can be generalize to style-transfer in natural images.

Target Domain

FC

Conv

BN ELU

ReLU

Concate

C64

C128C128

C256

C256

C512

C64

Hierarchical GeneratorContent Encoder

Generated Domain

Hierarchical Adversarial Discriminator

Ground-truth

Shuffle

𝓛𝒑𝒊𝒙𝒆𝒍'𝒘𝒊𝒔𝒆

𝓛*+,-./*.0*12𝓛*+,-./*.0*13𝓛*+,-./*.0*14

𝓛*+,-./*.0*15

Conv/Deconv

Batch Normalize

Exponential Linear Unit

Rectangle Linear Unit

Concatenate

Skip Connection

Fully Connected

𝑻𝟏 𝑻𝟐

𝑻𝟑C512

C512+ 512

C512

C256 C256+

256

C256 C128

C128+

128

C128

C64

C64+64

C64

Figure 2: The proposed Hierarchical Generatvie Adversarial Network (HGAN). HGAN con-sists of an content encoder, a hierarchical generator and a Hierarchical Adversarial Dis-criminator. The content encoder follows the Conv-BatchNorm [5]-ELU [2] architecture.The hierarchical generator follows the Conv-BatchNorm-ReLU while two extra transformedcharacters are decoded from two intermediate features. The hierarchical adversarial discrim-inator is used to distinguish the transformed characters and the ground-truth from multi-levelfeatures.

Citation
Citation
{Ioffe and Szegedy} 2015
Citation
Citation
{Clevert, Unterthiner, and Hochreiter} 2015
Page 4: Chinese Handwriting Imitation with Hierarchical Generative Adversarial … · 2018. 8. 2. · ant of generative adversarial networks (e.g CycleGAN [25]), which introduce a discriminant

4 CHANG ET. AL: CHINESE HANDWRITING IMITATION WITH HIERARCHICAL-GAN

2 MethodsIn this section, we present the proposed Hierarchical Generative Adversarial Network (HGAN)for typeface transformation task. HGAN consists of a transfer network and a hierarchicaldiscriminator. The former is further consists of an Content Encoder and a Hierarchical Gen-erator.

2.1 FCN-Based Transfer NetworkContent Encoder The Content Encoder maps a specified source characters to a contentembedding. It shares a similar architecture to that of [14] with some modification. Becauseany information of relative-location is critical for Chinese character synthesis, we replacepooling operation with strided convolution in down-sampling since pooling helps reducedimension and retains only robust activations in a receptive fields, however leading to theloss of spatial information in some degree (see Fig 2).

Hierarchical Generator Considering the domain insight of our task in Section 1. A Hi-erarchial Generator helps us model hierarchical representations of characters including theglobal topological structure and local topological of complicated Chinese characters. Specif-ically, different intermediate features of decoder are utilized to generate characters (T1, T2)too. Together with the last generated characters (T3), all of them will be sent to the dis-criminator(see Fig 2). We only measure the pixel-wise difference between the last generatedcharacters (T3) and corresponding ground-truth. The adversarial loss produced by T1 andT2 helps to refine the transfer network. Meanwhile, the loss produced by the intermediatelayers of decoder may provide regularization for the parameters in transfer network, whichwill relieves the over-fitting problem in some degree. In addition, for typeface transforma-tion, the input character and the desired output are expected to share underlying topologicalstructure, but differ in appearance or style. Skip connection [14] is utilized to supplementpartial invariant skeleton information of characters with encoded features concatenated ondecoded features. Both content encoder and hierarchical generator are fully convolutionalnetworks [10].

2.2 Hierarchical Adversarial DiscriminatorAs mentioned in Section 1, adversarial loss introduced by discriminator is widely used inexisting GAN-based image transformation task while all of them estimate the distributionconsistency of two domain merely based on the final extracted features of discriminator.It is actually uncertain whether the learned features in last layers will provide rich and ro-bust representations for discriminator. Additionally, We know the perceptual loss whichpenalizes the discrepancy between representations in different hidden space of images, isrecently used in existing image-relative works. We combine the thought of perceptual lossand GANs, proposing a hierarchical adversarial discriminator which leverage the percep-tual representations extracted from different intermediate layers of discriminator D and thendistinguishes real/fake distribution between generated domain Gdomain and target domainTdomain(See Fig 2). Each adversarial loss is defined as:

Ldi =−E f it∼ptarget ( ft )[logDi( f i

t )]+Es∼psource(s)[logDi( f is(T (s))] (1)

Lgi =−Es∼psource(s)[logDi( f is(T (s))] (2)

Citation
Citation
{Ronneberger, Fischer, and Brox} 2015
Citation
Citation
{Ronneberger, Fischer, and Brox} 2015
Citation
Citation
{Long, Shelhamer, and Darrell} 2015
Page 5: Chinese Handwriting Imitation with Hierarchical Generative Adversarial … · 2018. 8. 2. · ant of generative adversarial networks (e.g CycleGAN [25]), which introduce a discriminant

CHANG ET. AL: CHINESE HANDWRITING IMITATION WITH HIERARCHICAL-GAN 5

where f it and f i

s(T (s)) are ith perceptual representations learned in Discriminator from tar-get domain and generated domain respectively. Di is branch discriminator cascaded afterevery intermediate layer and i = 1,2, ..4 which depends on the number of convolutional lay-ers in our discriminator D. This variation brings a complementary adversarial training forour model, which urges discriminator to find more detailed local discrepancy beyond theglobal distribution. Assuming Ld4 and its corresponding Lg4 reach nash equilibrium, whichmeans the the perceptual representations f 4

t and f 4s (T (s)) are considered sharing the similar

distribution, however other adversarial losses (Ldi , Lgi), i 6= 4 may have not reach nash equi-librium since these losses produced by shallow losses pay more attention on regional infor-mation during training. The still high loss promotes the model to be continuously optimizeduntil all perceptual representations pairs ( f 4

t , f 4s (T (s))), i = 1,2, ..4 are indistinguishable by

discriminator. Experiments shows this strategy makes the discriminator to dynamically andautomatically discover the un-optimized space from various perspectives.

2.3 LossesPixel-level Loss L1- or L2-norm are often used to measure the pixel distance between pairedimages. For our typeface transformation task, each pixel in character is normalized near 0 or1 value. So cross entropy function is selected as per-pixel loss since this character generationproblem can be viewed as a logistic regression problem:

Lpix−wise(T ) = E(s,t)[−tλw · (logσ(T (s)))− (1− t) · log(1−σ(T (s)))], (3)

where T denotes the transformation of transfer network, (s, t) is pair-wise samples wheres∼ psource_domain(s) and t ∼ ptarget_domain(t). σ is sigmoid activation.

Particularly, a weighted parameter λw is introduced into pixel-wise loss for balancing theratio of positive(value 0) to negative(value 1) pixels in every typeface style. We add thistrade-off parameter based on the observation that some typefaces are thin (i.e. more negativepixels) while some may be relatively thick (i.e. more positive pixels). λw is not a parameterdetermined by cross validation, it is explicitly defined by:

λw = 1− ∑Kk=1 ∑

Nn=11

{tnk ≥ 0.5

}∑

Kk=1 ∑

Nn=11

{tnk < 0.5

} , (4)

where N the is the resolution of one character image(here N = 64), K denotes the number oftarget characters in training set and tn

k denotes the nth pixel value of kth target character.Hierarchical Adversarial Loss For our proposed HGAN, each adversarial loss is de-

fined by Eq 1 and Eq 2:Li

adversarial(Di,T ) = Ldi +Lgi . (5)

Noted that here we integrate original t ∼ ptarget(t) and s∼ psource(s) into Eq. 5 for a unifiedformulation, then the total adversarial losses is

Ltotal_adversarial(D,T ) =k

∑i=1

λi ·Liadversarial(Di,T ), (6)

where λi are weighted parameters to control the effect of every branch discriminator. Thetotal loss function is formulated as follows:

Ltotal = λpLpix−wise(T )+λaLtotal_adversarial(D,T ), (7)

where λp and λa are the trade-off parameters.We optimize transfer network and hierarchical adversarial discriminator by turns.

Page 6: Chinese Handwriting Imitation with Hierarchical Generative Adversarial … · 2018. 8. 2. · ant of generative adversarial networks (e.g CycleGAN [25]), which introduce a discriminant

6 CHANG ET. AL: CHINESE HANDWRITING IMITATION WITH HIERARCHICAL-GAN

3 Experiments

3.1 Data SetWe build a Chinese character data set by downloading large amount of .ttf scripts denotingdifferent typefaces from the the website http://www.foundertype.com/. After pre-processing, each typeface ends up with 6000 grey-scale images in 64×64.png format.

3.2 Network SetupThe hyper-parameters relevant to our proposed network are annotated in Fig 2. The contentencoder includes 8 conv-layers while the hierarchical generator is more deeper including4 transform-conv layers and 8 con-layers. Every conv and deconv are followed by Conv-BatchNorm(BN) [5]-ELU [2]/ReLU structure. 4 skip connections are used on mirror layersboth in encoder and staged-decoder. For the trade-off parameters in Section 2.3, λw is deter-mined by Eq 4. The number of adversarial loss of HAN l is 4 and weighted parameter {λi}3

1is decay from 1 to 0.5 with rate 0.9, λ4 = 1.0. λp and λa are both set to 1.0 to weight thepixel loss and adversarial loss.

3.3 Performance ComparisonTo validate the proposed HGAN model, we experimentally compare the transfer performanceof HGAN with two specialized Chinese calligraphy synthesis method (AEGG [11] andEMD [23]), a state-of-the-art supervised image-to-image transformation method (Pix2Pix [6])and an unsupervised image-to-image transformation method (CycleGAN [25])Qualitatively Performance All baselines except CycleGAN need pair the generated imageswith corresponding ground-truths for training. The transfer network of Pix2Pix shares theidentical framework with that in our HGAN(see Fig 2) and the network architecture usedin AEGG follows the instructions of their paper with some tiny adjustment for dimensionadaptation. 50%(3̃000) characters randomly selected from FS typeface as well as 50% cor-responding target style characters selected from other handwriting-style typefaces are usedas training set. The remaining 50% of FS typefaces is used for testing. We illustrate experi-mental results by transferring FS typeface to other 5 personal Chinese handwriting-style(seeFig 3). Both AEGG and Pix2Pix can capture coarse style of handwriting, however in testset, they failed to synthesize recognizable characters because most strokes in generated char-acter are disordered even chaotic. While we observed that both of them perform well ontraining set but far worse on test set, which suggests the proposed hierarchical adversar-ial loss makes our model less prone to over-fitting in some degree. Experimental resultsdemonstrate HGAN is superior in generating detailed component of characters so that it sig-nificantly outperforms previous work, especially on transferring cursive handwriting style.

We also compare the our HGAN with the most state-of-the-art Chinese typeface trans-formation model: EMD [23], a generalized style transfer framework which can even begeneralized to new unseen style by separating style and content of the specified typeface.Actually, HGAN and EMD are two different learning pattern: HGAN encodes the fixedstyle-information in the network, while EMD dynamically encodes the style-information inthe network according to the inputted target typeface denoting the specified style. For a faircomparison, we evaluate the performance of both EMD and HGAN on the training type-faces. Fig 4 shows us they perform equally well on legible typeface, while HGAN captures

Citation
Citation
{Ioffe and Szegedy} 2015
Citation
Citation
{Clevert, Unterthiner, and Hochreiter} 2015
Citation
Citation
{Lyu, Bai, Yao, Zhu, Huang, and Liu} 2017
Citation
Citation
{Zhang, Zhang, and Cai} 2018
Citation
Citation
{Isola, Zhu, Zhou, and Efros} 2016
Citation
Citation
{Zhu, Park, Isola, and Efros} 2017
Citation
Citation
{Zhang, Zhang, and Cai} 2018
Page 7: Chinese Handwriting Imitation with Hierarchical Generative Adversarial … · 2018. 8. 2. · ant of generative adversarial networks (e.g CycleGAN [25]), which introduce a discriminant

CHANG ET. AL: CHINESE HANDWRITING IMITATION WITH HIERARCHICAL-GAN 7

more accurate style and more subtle stroke detail than EMD in cursive handwriting style.Quantitative Evaluation. Beyond directly illustrating qualitative results of comparison ex-periments, two quantitative measurements: Root Mean Square Error(RMSE) and AveragePixel Disagreement Ration [9](APDR) are utilized as evaluation criterion. As shown inTable 1, our HGAN leads to the lowest RMSE and APDR value compared with existingmethods.

Model FS→hw1 FS→hw2 FS→hw3 FS→hw4

RMSE APDR RMSE APDR RMSE APDR RMSE APDR

AEGG [11] 22.671 0.143 28.010 0.211 24.083 0.171 22.110 0.131Pix2Pix [6] 29.731 0.231 27.117 0.225 26.580 0.187 24.135 0.180CycleG [25] 29.602 0.253 29.145 0.234 28.845 0.241 25.632 0.191EMD [23] 21.435 0.163 25.230 0.207 25.190 0.180 22.005 0.130HAN(strong) 19.498 0.118 23.303 0.181 22.266 0.162 19.528 0.110

Table 1: Quantitative Measurements

3.4 Analysis of Hierarchical Generative Adversarial LossWe analyze each adversarial loss, {Ldi}4

i=1 and {Lgi}4i=1, defined in Section 2.2. As shown in

Fig 5, the generator loss gen_4 produced by the last conv-layer in hierarchical discriminatorfluctuates greatly and then gen_3 produced by the penultimate layer, {gen_2,gen_1} pro-duced by shallower conv-layers are relatively gentle because λ4 is set larger than {λi}3

i=1 sothat network mainly optimizes gen_4. However for discriminator loss, {dis_4,dis_3,dis_1}derived from D4, D3,D1 are mostly numerical approach. We further observed that the trendof increase or reduction among various discriminator losses are not always consistent. Weexperimentally conclude that adversarial losses produced by intermediate layers can assisttraining: when D4 is severely cheated by real/fake characters, D3 or D2 or D1 can still give ahigh confidence of differentiating, which means True/False discrimination based on differentrepresentations can be compensated each other(see Fig 5 for more details) during training.Our hierarchical adversarial discriminator actually plays an implicitly role of fitting distribu-tion from two domains instead of fitting hidden features from paired images to be identicalcompared with existing methods, which can relieve over-fitting during training.

We further explore the influence brought by our hierarchical adversarial loss. By remov-ing the effect of hierarchical architecture from our HGAN model, we run another contrastexperiment, Single Generative Adversarial Network (SGAN). The detail of network followsFig 2 and we set trade-off parameters λ1 = λ2 = λ3 = 0.5 and λ4 = 1 in loss function ofHGAN, while we set λ1 = λ2 = λ3 = 0, λ4 = 1 as well as cutting off the data flow of T1,T2 for SGAN in order to remove the influence of extra 3 adversarial losses and hierarchicalgenerator. Characters generated during different training period are illustrated in Fig 7 fromwhich we can see qualitative effect of proposed hierarchical GAN. Our proposed HGANgenerates more clear characters compared with SGAN at the same phase of training period,which suggests HGAN converge greatly faster than SGAN. We also run 3 parallel typeface-transfer experiments then calculate RMSE along with the iterations of training on train set.Left loss-curves in Fig 7 demonstrates that hierarchical adversarial architecture assists toaccelerate convergence and leads to lower RMSE value.

Citation
Citation
{Liu and Tuzel} 2016
Citation
Citation
{Lyu, Bai, Yao, Zhu, Huang, and Liu} 2017
Citation
Citation
{Isola, Zhu, Zhou, and Efros} 2016
Citation
Citation
{Zhu, Park, Isola, and Efros} 2017
Citation
Citation
{Zhang, Zhang, and Cai} 2018
Page 8: Chinese Handwriting Imitation with Hierarchical Generative Adversarial … · 2018. 8. 2. · ant of generative adversarial networks (e.g CycleGAN [25]), which introduce a discriminant

8 CHANG ET. AL: CHINESE HANDWRITING IMITATION WITH HIERARCHICAL-GAN

Test-set Result Train-set Result

SourceAEGGPix2PixOursTarget

SourceAEGGPix2PixOursTarget

SourceAEGGPix2PixOursTarget

SourceAEGGPix2PixOursTarget

SourceAEGGPix2PixOursTarget

SourceAEGGPix2PixOursTarget

Transfer FS-typeface to 5 personal handwriting-styles typeface

Figure 3: Performance of transferring FS typeface (Source) to other 5 personal handwriting-style typefaces. We compare our HGAN with a specialized model proposed for Chinesetypeface transformation: AEGG [18] and a state-of-the-art image-to-image transformationmodel: Pix2Pix [6].

Citation
Citation
{Xu, Jiang, Jin, Lau, and Pan} 2009
Citation
Citation
{Isola, Zhu, Zhou, and Efros} 2016
Page 9: Chinese Handwriting Imitation with Hierarchical Generative Adversarial … · 2018. 8. 2. · ant of generative adversarial networks (e.g CycleGAN [25]), which introduce a discriminant

CHANG ET. AL: CHINESE HANDWRITING IMITATION WITH HIERARCHICAL-GAN 9

Source

EMD

Ours

Target

EMD

Ours

Target

EMD

Ours

Target

Figure 4: Performance of transferring FS typeface (Source) to other 3 personal handwriting-style typefaces. Our HGAN performs as well as EMD [23] on legible typeface (top column),while HGAN greatly performs better than EMD on cursive typefaces (middle and bottomcolumns).

700 725 750 775 800 825 850 875 900Iterations of training

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1.0

Loss

for G

ener

ator

Loss Curvesgen_4gen_3

gen_2gen_1

0.55

0.60

0.65

0.70

0.75

0.80

0.85

0.90

0.95

Loss

for D

iscrim

inat

or

dis_4dis_3

dis_2dis_1

Figure 5: Each generator loss and discrimi-nator loss during ste 700 to 900.

Groundtruth

500

100

1500

2500

Figure 6: The RMSE evaluation under dif-ferent size of trainging samples.

3.5 Impact of Training Set SizeLast, we experiment at least how many handwriting characters should be given in training toensure a satisfied transfer performance. So we experiment three typeface-transfer tasks(type-1, type-2 and type-3) with different proportion of training samples and then evaluate on eachsame test set. As the synthesized characters shown in Fig ??, the performance improvesalong with increase size of training samples. RMSE evaluation curves suggest when thetraining size is not less than 35%(2000 samples) of whole dataset, the performance will notbe greatly improved.

3.6 Character Restoration and Image Style TransferAs illustrated in Fig 6, we also applied our HGAN model to character restoration and art-styletransfer for natural images. We randomly mask 30% region on every handwriting charactersin one typeface’s training set and our HGAN is able to correctly reconstruct the missing part

Citation
Citation
{Zhang, Zhang, and Cai} 2018
Page 10: Chinese Handwriting Imitation with Hierarchical Generative Adversarial … · 2018. 8. 2. · ant of generative adversarial networks (e.g CycleGAN [25]), which introduce a discriminant

10 CHANG ET. AL: CHINESE HANDWRITING IMITATION WITH HIERARCHICAL-GAN

S Hepo-1

epo-3

epo-4

epo-5

epo-8

epo-11

epo-24

epo-18

epo-2

HANconverge

Target

Source

S H S H S H

S : SGAN structure(without HA framework)H: HGAN structure

Figure 7: Contrast experiments for HGAN and SGAN. Left: Characters generated by HGANare far more better than that by SGAN in same training epoch. HGAN converge row showscharacters generated when our HGAN model converges. Right: The RMSE evaluation lossalong with the training iterations under HGAN and SGAN which shows HGAN leads tomore lower value than SGAN.

of one character on test set. HGAN also obtains good performance on art-style transfer.

Incompletecharacters

HAN restoration

Groundtruth

Original

Style-1

Style-2

Figure 8: Performance of character restoration (Left) and art-style transfer (Right).

4 Conclusion and Future WorkIn this paper, we propose a hierarchical generative adversarial network for typeface trans-formation. The proposed hierarchical generator and hierarchical adversarial discriminatorcan dynamically estimate the consistency of two domains from different-level perceptualrepresentations, which helps our HGAN converge faster and better. Experimental resultsshow our HGAN can synthesize most handwriting-style typeface compared with existingnatural image-to-image transformation methods. Additionally, our HGAN can be applied tohandwriting character restoration.

AcknowledgementsThis work is supported by The High Technology Research and Development Program ofChina (2015AA015801), NSFC (61521062), and STCSM (18DZ2270700).

Page 11: Chinese Handwriting Imitation with Hierarchical Generative Adversarial … · 2018. 8. 2. · ant of generative adversarial networks (e.g CycleGAN [25]), which introduce a discriminant

CHANG ET. AL: CHINESE HANDWRITING IMITATION WITH HIERARCHICAL-GAN 11

References[1] Dongdong Chen, Lu Yuan, Jing Liao, Nenghai Yu, and Gang Hua. Stylebank: An ex-

plicit representation for neural image style transfer. arXiv preprint arXiv:1703.09210,2017.

[2] Djork-ArnÃl’ Clevert, Thomas Unterthiner, and Sepp Hochreiter. Fast and accuratedeep network learning by exponential linear units (elus). Computer Science, 2015.

[3] Alexey Dosovitskiy and Thomas Brox. Generating images with perceptual similar-ity metrics based on deep networks. In Advances in Neural Information ProcessingSystems, 2016.

[4] Ian J. Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley,Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Generative adversarial nets. In In-ternational Conference on Neural Information Processing Systems, pages 2672–2680,2014.

[5] Sergey Ioffe and Christian Szegedy. Batch normalization: Accelerating deep networktraining by reducing internal covariate shift. Computer Science, 2015.

[6] Phillip Isola, Jun Yan Zhu, Tinghui Zhou, and Alexei A Efros. Image-to-image trans-lation with conditional adversarial networks. arXiv preprint arXiv:1611.07004, 2016.

[7] Justin Johnson, Alexandre Alahi, and Fei Fei Li. Perceptual losses for real-time styletransfer and super-resolution. In European Conference on Computer Vision, pages694–711, 2016.

[8] Christian Ledig, Lucas Theis, Ferenc Huszar, Jose Caballero, Andrew Cunningham,Alejandro Acosta, Andrew Aitken, Alykhan Tejani, Johannes Totz, and Zehan Wang.Photo-realistic single image super-resolution using a generative adversarial network.arXiv preprint arXiv:1609.04802, 2016.

[9] Ming-Yu Liu and Oncel Tuzel. Coupled generative adversarial networks. In Advancesin neural information processing systems, pages 469–477, 2016.

[10] Jonathan Long, Evan Shelhamer, and Trevor Darrell. Fully convolutional networksfor semantic segmentation. In Computer Vision and Pattern Recognition, pages 3431–3440, 2015.

[11] Pengyuan Lyu, Xiang Bai, Cong Yao, Zhen Zhu, Tengteng Huang, and WenyuLiu. Auto-encoder guided gan for chinese calligraphy synthesis. arXiv preprintarXiv:1706.08789, 2017.

[12] Deepak Pathak, Philipp Krahenbuhl, Jeff Donahue, Trevor Darrell, and Alexei A. Efros.Context encoders: Feature learning by inpainting. In Proceedings of the IEEE Confer-ence on Computer Vision and Pattern Recognition, pages 2536–2544, 2016.

[13] Alec Radford, Luke Metz, and Soumith Chintala. Unsupervised representation learningwith deep convolutional generative adversarial networks. Computer Science, 2015.

Page 12: Chinese Handwriting Imitation with Hierarchical Generative Adversarial … · 2018. 8. 2. · ant of generative adversarial networks (e.g CycleGAN [25]), which introduce a discriminant

12 CHANG ET. AL: CHINESE HANDWRITING IMITATION WITH HIERARCHICAL-GAN

[14] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networksfor biomedical image segmentation. In International Conference on Medical ImageComputing and Computer-Assisted Intervention, volume 9351, pages 234–241, 2015.

[15] Tim Salimans, Ian Goodfellow, Wojciech Zaremba, Vicki Cheung, Alec Radford, andXi Chen. Improved techniques for training gans. In Advances in Neural InformationProcessing Systems, 2016.

[16] Chaoyue Wang, Chang Xu, Chaohui Wang, and Dacheng Tao. Perceptual adversarialnetworks for image-to-image transformation. arXiv preprint arXiv:1706.09138, 2017.

[17] Jianguo Xiao, Jianguo Xiao, and Jianguo Xiao. Automatic generation of large-scalehandwriting fonts via style learning. In SIGGRAPH ASIA 2016 Technical Briefs,page 12, 2016.

[18] Songhua Xu, Hao Jiang, Tao Jin, Francis C. M. Lau, and Yunhe Pan. Automatic gen-eration of chinese calligraphic writings with style imitation. IEEE Intelligent Systems,24(2):44–53, 2009.

[19] Songhua Xu, Tao Jin, Hao Jiang, and Francis C. M. Lau. Automatic generation ofpersonal chinese handwriting by capturing the characteristics of personal handwriting.In Conference on Innovative Applications of Artificial Intelligence, July 14-16, 2009,Pasadena, California, Usa, 2010.

[20] He Zhang, Vishwanath Sindagi, and Vishal M. Patel. Image de-raining using a condi-tional generative adversarial network. arXiv preprint arXiv:1701.05957, 2017.

[21] Richard Zhang, Phillip Isola, and Alexei A. Efros. Colorful image colorization. InEuropean Conference on Computer Vision, pages 649–666, 2016.

[22] Xu-Yao Zhang, Fei Yin, Yan-Ming Zhang, Cheng-Lin Liu, and Yoshua Bengio. Draw-ing and recognizing chinese characters with recurrent neural network. IEEE Transac-tions on Pattern Analysis and Machine Intelligence, 2017.

[23] Yexun Zhang, Ya Zhang, and Wenbin Cai. Separating style and content for generalizedstyle transfer. In Proceedings of the IEEE Conference on Computer Vision and PatternRecognition, volume 1, 2018.

[24] Baoyao Zhou, Weihong Wang, and Zhanghui Chen. Easy generation of personal chi-nese handwritten fonts. In IEEE International Conference on Multimedia and Expo,pages 1–6, 2011.

[25] Jun Yan Zhu, Taesung Park, Phillip Isola, and Alexei A Efros. Unpaired image-to-image translation using cycle-consistent adversarial networks. arXiv preprintarXiv:1703.10593, 2017.