new arxiv:1910.03634v1 [cs.cv] 8 oct 2019 · 2019. 10. 10. · samrat phatale columbia university...

4
Prose for a Painting Prerna Kashyap Columbia University [email protected] Samrat Phatale Columbia University [email protected] Iddo Drori Columbia University [email protected] Abstract Painting captions are often dry and simplistic which mo- tivates us to describe a painting creatively in the style of Shakespearean prose. This is a difficult problem, since there does not exist a large supervised dataset from paintings to Shakespearean prose. Our solution is to use an intermedi- ate English poem description of the painting and then ap- ply language style transfer which results in Shakespearean prose describing the painting. We rate our results by hu- man evaluation on a Likert scale, and evaluate the quality of language style transfer using BLEU score as a function of prose length. We demonstrate the applicability and limi- tations of our approach by generating Shakespearean prose for famous paintings. We make our models and code pub- licly available. 1. Introduction Neural networks have been successfully used to describe images with text using sequence-to-sequence models [12]. However, the results are simple and dry captions which are one or two phrases long. Humans looking at a painting see more than just objects. Paintings stimulate sentiments, metaphors and stories as well. Therefore, our goal is to have a neural network describe the painting artistically in a style of choice. As a proof of concept, we present a model which generates Shakespearean prose for a given painting as shown in Figure 1. Accomplishing this task is difficult with traditional sequence to sequence models since there does not exist a large collection of Shakespearean prose which describes paintings: Shakespeare’s works describes a single painting shown in Figure 2. Fortunately we have a dataset of modern English poems which describe images [7] and line-by-line modern paraphrases of Shakespeare’s plays [4]. Our solution is therefore to combine two sepa- rately trained models to synthesize Shakespearean prose for a given painting. Figure 1. Sample result: Input painting and output synthesized Shakespeare prose. 1.1. Related work A general end-to-end approach to sequence learning [11] makes minimal assumptions on the sequence structure. This model is widely used in tasks such as machine translation, text summarization, conversational modeling, and image captioning. A generative model using a deep recurrent ar- chitecture [12] has also beeen used for generating phrases describing an image. The task of synthesizing multiple lines of poetry for a given image [7] is accomplished by extract- ing poetic clues from images. Given the context image, the network associates image attributes with poetic descriptions using a convolutional neural net. The poem is generated using a recurrent neural net which is trained using multi- adversarial training via policy gradient. Transforming text from modern English to Shake- spearean English using text ”style transfer” is challeng- ing. An end to end approach using a sequence-to-sequence model over a parallel text corpus [4] has been proposed based on machine translation. In the absence of a parallel text corpus, generative adversarial networks (GANs) have been used, which simultaneously train two models: a gen- erative model which captures the data distribution, and a discriminative model which evaluates the performance of arXiv:1910.03634v1 [cs.CV] 8 Oct 2019

Upload: others

Post on 12-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: New arXiv:1910.03634v1 [cs.CV] 8 Oct 2019 · 2019. 10. 10. · Samrat Phatale Columbia University shp2139@columbia.edu Iddo Drori Columbia University idrori@cs.columbia.edu Abstract

Prose for a Painting

Prerna KashyapColumbia University

[email protected]

Samrat PhataleColumbia University

[email protected]

Iddo DroriColumbia University

[email protected]

Abstract

Painting captions are often dry and simplistic which mo-tivates us to describe a painting creatively in the style ofShakespearean prose. This is a difficult problem, since theredoes not exist a large supervised dataset from paintings toShakespearean prose. Our solution is to use an intermedi-ate English poem description of the painting and then ap-ply language style transfer which results in Shakespeareanprose describing the painting. We rate our results by hu-man evaluation on a Likert scale, and evaluate the qualityof language style transfer using BLEU score as a functionof prose length. We demonstrate the applicability and limi-tations of our approach by generating Shakespearean prosefor famous paintings. We make our models and code pub-licly available.

1. Introduction

Neural networks have been successfully used to describeimages with text using sequence-to-sequence models [12].However, the results are simple and dry captions which areone or two phrases long. Humans looking at a paintingsee more than just objects. Paintings stimulate sentiments,metaphors and stories as well. Therefore, our goal is tohave a neural network describe the painting artistically in astyle of choice. As a proof of concept, we present a modelwhich generates Shakespearean prose for a given paintingas shown in Figure 1. Accomplishing this task is difficultwith traditional sequence to sequence models since theredoes not exist a large collection of Shakespearean prosewhich describes paintings: Shakespeare’s works describesa single painting shown in Figure 2. Fortunately we havea dataset of modern English poems which describe images[7] and line-by-line modern paraphrases of Shakespeare’splays [4]. Our solution is therefore to combine two sepa-rately trained models to synthesize Shakespearean prose fora given painting.

Figure 1. Sample result: Input painting and output synthesizedShakespeare prose.

1.1. Related work

A general end-to-end approach to sequence learning [11]makes minimal assumptions on the sequence structure. Thismodel is widely used in tasks such as machine translation,text summarization, conversational modeling, and imagecaptioning. A generative model using a deep recurrent ar-chitecture [12] has also beeen used for generating phrasesdescribing an image. The task of synthesizing multiple linesof poetry for a given image [7] is accomplished by extract-ing poetic clues from images. Given the context image, thenetwork associates image attributes with poetic descriptionsusing a convolutional neural net. The poem is generatedusing a recurrent neural net which is trained using multi-adversarial training via policy gradient.

Transforming text from modern English to Shake-spearean English using text ”style transfer” is challeng-ing. An end to end approach using a sequence-to-sequencemodel over a parallel text corpus [4] has been proposedbased on machine translation. In the absence of a paralleltext corpus, generative adversarial networks (GANs) havebeen used, which simultaneously train two models: a gen-erative model which captures the data distribution, and adiscriminative model which evaluates the performance of

arX

iv:1

910.

0363

4v1

[cs

.CV

] 8

Oct

201

9

Page 2: New arXiv:1910.03634v1 [cs.CV] 8 Oct 2019 · 2019. 10. 10. · Samrat Phatale Columbia University shp2139@columbia.edu Iddo Drori Columbia University idrori@cs.columbia.edu Abstract

Figure 2. Shakespeare’s ground truth prose for the painting Venusand Adonis by Titian.

the generator. Using a target domain language model as adiscriminator has also been employed [13], providing richerand more stable token-level feedback during the learningprocess. A key challenge in both image and text style trans-fer is separating content from style [2, 3, 10]. Cross-alignedauto-encoder models have focused on style transfer usingnon-parallel text [10]. Recently, a fine grained model fortext style transfer has been proposed [6] which controlsseveral factors of variation in textual data by using back-translation. This allows control over multiple attributes,such as gender and sentiment, and fine-grained control overthe trade-off between content and style.

2. MethodsWe use a total three datasets: two datasets for generating

an English poem from an image, and Shakespeare plays andtheir English translations for text style transfer.

We train a model for generating poems from imagesbased on two datasets [7]. The first dataset consists of im-age and poem pairs, namely a multi-modal poem dataset(MultiM-Poem), and the second dataset is a large poem cor-pus, namely a uni-modal poem dataset (UniM-Poem). Theimage and poem pairs are extended by adding the nearestthree neighbor poems from the poem corpus without redun-dancy, and an extended image and poem pair dataset is con-structed and denoted as MultiM-Poem(Ex)[7].

We use a collection of line-by-line modern paraphrasesfor 16 of Shakespeares plays [4], for training a style trans-fer network from English poems to Shakespearean prose.We use 18,395 sentences from the training data split. Wekeep 1,218 sentences in the validation data set and 1,462sentences in our test set.

2.1. Image To Poem Actor-Critic Model

For generating a poem from images we use an existingactor-critic architecture [7]. This involves 3 parallel CNNs:an object CNN, sentiment CNN, and scene CNN, for featureextraction. These features are combined with a skip-thoughtmodel which provides poetic clues, which are then fed intoa sequence-to-sequence model trained by policy gradient

with 2 discriminator networks for rewards. This as a wholeforms a pipeline that takes in an image and outputs a poemas shown on the top left of Figure 3. A CNN-RNN gener-ative model acts as an agent. The parameters of this agentdefine a policy whose execution determines which word isselected as an action. When the agent selects all words ina poem, it receives a reward. Two discriminative networks,shown on the top right of Figure 3, are defined to serve asrewards concerning whether the generated poem properlydescribes the input image and whether the generated poemis poetic. The goal of the poem generation model is to gen-erate a sequence of words as a poem for an image to maxi-mize the expected return.

2.2. Shakespearizing Poetic Captions

For Shakespearizing modern English texts, we experi-mented with various types of sequence to sequence mod-els. Since the size of the parallel translation data avail-able is small, we leverage a dictionary providing a mappingbetween Shakespearean words and modern English wordsto retrofit pre-trained word embeddings. Incorporating thisextra information improves the translation task. The largenumber of shared word types between the source and targetsentences indicates that sharing the representation betweenthem is beneficial.

2.2.1 Seq2Seq with Attention

We use a sequence-to-sequence model which consists of asingle layer unidrectional LSTM encoder and a single layerLSTM decoder and pre-trained retrofitted word embeddingsshared between source and target sentences. We experi-mented with two different types of attention: global atten-tion [8], in which the model makes use of the output fromthe encoder and decoder for the current time step only, andBahdanau attention [1], where computing attention requiresthe output of the decoder from the prior time step. We foundthat global attention performs better in practice for our taskof text style transfer.

2.2.2 Seq2Seq with a Pointer Network

Since a pair of corresponding Shakespeare and modern En-glish sentences have significant vocabulary overlap we ex-tend the sequence-to-sequence model mentioned above us-ing pointer networks [9] that provide location based atten-tion and have been used to enable copying of tokens directlyfrom the input. Moreover, there are lot of proper nouns andrare words which might not be predicted by a vanilla se-quence to sequence model.

Page 3: New arXiv:1910.03634v1 [cs.CV] 8 Oct 2019 · 2019. 10. 10. · Samrat Phatale Columbia University shp2139@columbia.edu Iddo Drori Columbia University idrori@cs.columbia.edu Abstract

Figure 3. Model architecture: Input is a painting (top left) for which we first generate an English poem using 3 CNNs for feature extraction,and an RNN generator as an agent with 2 discriminators (center right) which provide feedback to the agent for model improvement. Thestyle transfer model takes as input the generator output and performs text style transfer using a seq2seq model with global attention tosynthesis the output prose (bottom left).

Figure 4. Sample results: Painting (left), synthesized Englishpoem (center) and Shakespearean Prose (right) for ”Girl with thepearl earing”, a painting of a man on a lake, and ”Portrait ofMadame Recaimer”.

2.2.3 Prediction

For both seq2seq models, we use the attention matrices re-turned at each decoder time step during inference, to com-pute the next word in the translated sequence if the decoderoutput at the current time step is the UNK token. We re-place the UNKs in the target output with the highest aligned,maximum attention, source word. The seq2seq model withglobal attention gives the best results with an average tar-get BLEU score of 29.65 on the style transfer dataset, com-pared with an average target BLEU score of 26.97 using theseq2seq model with pointer networks.

3. Results

We perform a qualitative analysis of the Shakespeareanprose generated for the input paintings. We conducted asurvey, in which we presented famous paintings includ-ing those shown in Figures 1 and 4 and the correspondingShakespearean prose generated by the model, and asked 32students to rate them on the basis of content, creativity andsimilarity to Shakespearean style on a Likert scale of 1-5.Figure 6 shows the result of our human evaluation.

The average content score across the paintings is 3.7which demonstrates that the prose generated is relevant tothe painting. The average creativity score is 3.9 whichdemonstrates that the model captures more than basic ob-jects in the painting successfully using poetic clues in thescene. The average style score is 3.9 which demonstratesthat the prose generated is perceived to be in the style ofShakespeare.

We also perform a quantitative analysis of style transferby generating BLEU scores for the model output using thestyle transfer dataset. The variation of the BLEU scoreswith the source sentence lengths is shown in Figure 5. Asexpected, the BLEU scores decrease with increase in sourcesentence lengths.

3.1. Implementation

All models were trained on Google Colab with a singleGPU using Python 3.6 and Tensorflow 2.0. The number ofhidden units for the encoder and decoder is 1,576 and 256for seq2seq with global attention and seq2seq with pointernetworks respectively. Adam optimizer was used with thedefault learning rate of 0.001. The model was trained for 25epochs. We use pre-trained retrofitted word embeddings ofdimension 192.

Page 4: New arXiv:1910.03634v1 [cs.CV] 8 Oct 2019 · 2019. 10. 10. · Samrat Phatale Columbia University shp2139@columbia.edu Iddo Drori Columbia University idrori@cs.columbia.edu Abstract

Figure 5. BLEU score vs. source sentence length.

Figure 6. Survey results: Average rating of content, creativity, andstyle on a Likert scale.

3.2. Limitations

Since we do not have an end-to-end dataset, the gener-ated English poem may not work well with Shakespearestyle transfer as shown in Figure 6 for ”Starry Night” witha low average content score. This happens when the styletransfer dataset does not have similar words in the trainingset of sentences. A solution would be to expand the styletransfer dataset, for a better representation of the poem data.

3.3. Conclusions and Future Work

In conclusion, combining two pipelines with an interme-diate representation works well in practice. We observe thata CNN-RNN based image-to-poem net combined with aseq2seq model with parallel text corpus for text style trans-fer synthesizes Shakespeare-style prose for a given paint-ing. For the seq2seq model used, we observe that it per-forms better in practice using global attention as comparedwith local attention. We make our models and code publiclyavailable [5]. In future work we would like to experiment

with GANs in the absence of non-parallel datasets, so thatwe can use varied styles for text style transfer. We wouldalso like to experiment with cross aligned auto-encoders,which form a latent content representation, to efficientlyseparate style and content.

References[1] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio.

Neural machine translation by jointly learning to align andtranslate. International Conference on Learning Representa-tions, 2015. 2

[2] Iddo Drori, Daniel Cohen-Or, and Hezy Yeshurun. Example-based style synthesis. In 2003 IEEE Computer Society Con-ference on Computer Vision and Pattern Recognition, 2003.Proceedings., 2003. 2

[3] Leon A Gatys, Alexander S Ecker, and Matthias Bethge. Im-age style transfer using convolutional neural networks. InProceedings of the IEEE conference on computer vision andpattern recognition, pages 2414–2423, 2016. 2

[4] Harsh Jhamtani, Varun Gangal, Eduard Hovy, and Eric Ny-berg. Shakespearizing modern language using copy-enrichedsequence-to-sequence models. ACL Workshop on StylisticVariation, pages 10–19, 2017. 1, 2

[5] Prerna Kashyap, Samrat Phatale, and IddoDrori. Prose for painting: source code. Inhttps://github.com/prerna135/prose-for-a-painting, 2019. 4

[6] Guillaume Lample, Sandeep Subramanian, Eric Smith, Lu-dovic Denoyer, Y-Lan Boureau, et al. Multiple-attribute textrewriting. International Conference on Learning Represen-tations, 2019. 2

[7] Bei Liu, Jianlong Fu, Makoto P Kato, and MasatoshiYoshikawa. Beyond narrative description: generating poetryfrom images by multi-adversarial training. In ACM Interna-tional Conference on Multimedia, pages 783–791, 2018. 1,2

[8] Minh-Thang Luong, Hieu Pham, and Christopher D Man-ning. Effective approaches to attention-based neural machinetranslation. arXiv preprint arXiv:1508.04025, 2015. 2

[9] Stephen Merity, Caiming Xiong, James Bradbury, andRichard Socher. Pointer sentinel mixture models. Interna-tional Conference on Learning Representations, 2017. 2

[10] Tianxiao Shen, Tao Lei, Regina Barzilay, and TommiJaakkola. Style transfer from non-parallel text by cross-alignment. In Advances in neural information processingsystems, pages 6830–6841, 2017. 2

[11] Ilya Sutskever, Oriol Vinyals, and Quoc V Le. Sequenceto sequence learning with neural networks. In Advances inNeural Information Processing Systems, pages 3104–3112,2014. 1

[12] Oriol Vinyals, Alexander Toshev, Samy Bengio, and Du-mitru Erhan. Show and tell: A neural image caption gener-ator. In Conference on Computer Vision and Pattern Recog-nition, pages 3156–3164, 2015. 1

[13] Zichao Yang, Zhiting Hu, Chris Dyer, Eric P Xing, and Tay-lor Berg-Kirkpatrick. Unsupervised text style transfer usinglanguage models as discriminators. In Advances in NeuralInformation Processing Systems, pages 7287–7298, 2018. 2