Being able to automatically generate a description from an image is a fundamental problem in artificial intelligence, connecting computer vision and natural language processing. The problem is particularly challenging because it requires to correctly recognize different objects in images and how they interact. Another challenge is that an image description generator needs to express these interactions in a natural language (e.g. English). Therefore, a language model is implicitly required in addition to visual understanding.
Recently, this problem has been studied by many different authors. Most of the attempts are based on recurrent neural networks to generate sentences. These models leverage the power of neural networks to transform image and sentence representations into a common space(Mao et al., 2014; Karpathy & Fei-Fei, 2014; Vinyals et al., 2014; Donahue et al., 2014).
In this paper, we propose a different approach to the problem that does not rely on complex recurrent neural networks. An exploratory analysis of two large datasets of image descriptions reveals that their syntax is quite simple. The ground-truth descriptions can be represented as a collection of noun, verb and prepositional phrases. The different objects in a given image are described by the noun phrases, while the interactions between these objects are encoded by both the verb and the prepositional phrases. We thus train a model that predicts the set of phrases present in the sentences used to describe the images. By leveraging previous works on word vector representations, each phrase can be represented by the mean of the representations of the words that compose the phrase. Vector representations for images can also be easily obtained from some pre-trained convolutional neural networks. The model then learns a common embedding between phrase and image representations (see Figure3).
Given a test image, a bilinear model is trained to predict a set of top-ranked phrases that best describe it. Several noun phrases, verb phrases and prepositional phrases are in this set. The objective is therefore to generate syntactically correct sentences from (possibly different) subsets of these phrases. We introduce a trigram constrained language model based on our knowledge about how the sentence descriptions are structured in the training set. With a very constrained decoding scheme, sentences are inferred with a beam search. Because these sentences are not conditioned to the given image (apart with the initial phrases selection), a re-ranking is used to pick the sentence that is closest to the sample image (according to the learned metric). The quality of our sentence generation is evaluated on two very popular datasets for the task: Flickr30k (Hodosh et al., 2013) and the recently published COCO (Lin et al., 2014). Using the popular BLEU score (Papineni et al., 2002), our results are competitive with other recent works. Our generated sentences also achieve a similar performance as humans on the BLEU metric.
The paper is organized as follows. Section 2 presents related works. Section 3 presents the analysis we conducted to better understand the syntax of image descriptions. Section 4 describes the proposed phrase-based model. Section 5 introduces the sentence generation from the predicted phrases. Section 6 describes our experimental setup and the results on the two datasets. Section 7 concludes.
2 Related Works
The classical approach to sentence generation is to pose the problem as a retrieval problem: a given test image will be described with the highest ranked annotation in the training set (Hodosh et al., 2013; Socher et al., 2014; Srivastava & Salakhutdinov, 2014). These matching methods may not generate proper descriptions for a new combination of objects. Due to this limitation, several generative approaches have been proposed. Many of them use syntactic and semantic constraints in the generation process (Yao et al., 2010; Mitchell et al., 2012; Kulkarni et al., 2011; Kuznetsova et al., 2012). These approaches benefit from visual recognition systems to infer words or phrases, but in contrast to our work they do not leverage a multimodal metric between images and phrases.
More recently, automatic image sentence description approaches based on deep neural networks have emerged with the release of new large datasets. As starting point, these solutions use the rich representation of images generated by Convolutional Neural Networks (LeCun et al., 1998) (CNN) that were previously trained for object recognition tasks. These CNN are generally followed by recurrent neural networks (RNN) in order to generate full sentence descriptions (Vinyals et al., 2014; Karpathy & Fei-Fei, 2014; Donahue et al., 2014; Chen & Zitnick, 2014; Mao et al., 2014; Venugopalan et al., 2014; Kiros et al., 2014)
. Among these recent works, long short-term memory (LSTM) is often chosen as RNN. In such approaches, the key point is to learn a common space between images and words or between images and sentences, i.e. a multimodal embedding.
Vinyals et al. (2014) consider the problem in a similar way as a machine translation problem. The authors propose an encoder/decoder (CNN/LSTM networks) system that is trained to maximize the likelihood of the target description sentence given a training image. Karpathy & Fei-Fei (2014) propose an approach that is a combination of CNN, bidirectional RNN over sentences and a structured objective responsible for a multimodal embedding. They then propose a second RNN architecture to generate new sentences. Similarly, Mao et al. (2014) and Donahue et al. (2014) propose a system that uses a CNN to extract image features and a RNN for sentences. The two networks interact with each other in a multimodal common layer.
Our model shares some similarities with these recent proposed approaches. We also use a pre-trained CNN to extract image features. However, thanks to the phrase-based approach, our model does not rely on complex recurrent networks for sentence generation, and we do not fine-tune the image features.
As our approach, Fang et al. (2014) proposes to not use recurrent networks for generating the sentences. Their solution can be divided into three steps: (i) a visual detector for words that commonly occur are trained using multiple instance learning, (ii) a set of sentences are generated using a Maximum-Entropy language model and (iii) the set of sentences is re-ranked using sentence-level features and a proposed deep multimodal similarity model. Our work differs from this approach in two different important ways: our model infers phrases present in the sentences instead of words and we use a considerably simpler language model.
3 Syntax Analysis of Image Descriptions
The art of writing sentences can vary a lot according to the domain. When reporting news or reviewing an item, not only the choice of the words might vary, but also the general structure of the sentence. In this section, we wish to analyze the syntax of image descriptions to identify whether images have their own structures. We therefore proceed to an exploratory analysis of two recent datasets containing a large amount of images with descriptions: Flickr30k (Hodosh et al., 2013) and COCO (Lin et al., 2014).
The Flickr30k dataset contains 31,014 images where 1,014 images are for validation, 1,000 for testing and the rest for training (i.e. 29,000 images). The COCO dataset contains 123,287 images, 82,783 training images and 40,504 validation images. The testing images has not yet been released. We thus use two sets of 5,000 images from the validation images for validation and test, as in Karpathy & Fei-Fei (2014)222Available at http://cs.stanford.edu/people/karpathy/deepimagesent/. In both datasets, images are given with five (or six) sentence descriptions annotated using Amazon Mechanical Turk. This results in 559,113 sentences when combining both training datasets.
3.2 Chunking-based Approach
A quick overview over these sentence descriptions reveals that they all share a common structure, usually describing the different objects present in the image and how they interact between each other. This interaction among objects is described as actions or relative position between different objects. The sentence can be short or long, but it generally respects this process. To confirm this claim and better understand the description structures, we used a chunking (also called shallow parsing) approach which identifies the constituents of a sentence. These constituents are usually noun phrases (NP), verb phrases (VP) and prepositional phrases (PP). We extract them from the training sentences with the SENNA software333Available at http://ml.nec-labs.com/senna/. Pre-verbal and post-verbal adverb phrases are merged with verb phrases to limit the number of phrase types.
Statistics reported in Figure 1 and Figure 2 confirm that image descriptions possess a simple and distinct structure. These sentences do not have much variability. All the key elements in a given image are usually described with a noun phrase (NP). Interactions between these elements can then be explained using prepositional phrases (PP) or verb phrases (VP). A large majority of sentences contain from two to four noun phrases. Two noun phrases then interact using a verb or prepositional phrase. Describing an image is therefore just a matter of identifying these constituents. We thus propose to train a model which can predict the phrases which are likely to be in a given image.
4 Phrase-based Model for Image Descriptions
By leveraging previous works on word and image representations, we propose a simple model which can predict the phrases that best describe a given image. For this purpose, a metric between images and phrases is trained, as illustrated in Figure 3. The proposed architecture is then just a low-rank bilinear model .
4.1 Image Representations
For the representation of images, we choose to use a Convolutional Neural Network. CNN have been widely used in different vision domains and are currently the state-of-the-art in many object recognition tasks. We consider a CNN that has been pre-trained for the task of object classification (Chatfield et al., 2014)
. We use a CNN solely to the purpose of feature extraction, that is, no learning is done in the CNN layers.
4.2 Learning a Common Space for Image and Phrase Representations
Let be the set of training images, the set of all phrases used to describe , and the trainable parameters of the model. By representing each image with a vector thanks to the pre-trained CNN, we define a metric between the image and a phrase as a bilinear operation:
with and being the trainable parameters . Note that could be a full matrix, but a low-rank setting eases the capacity control.
4.3 Phrase Representations Initialization
Noun phrases or verb phrases are often a combination of several words. Good word vector representations can be obtained very efficiently with many different recent approaches (Mikolov et al., 2013b; Mnih & Kavukcuoglu, 2013; Pennington et al., 2014; Lebret & Collobert, 2014). Mikolov et al. (2013a) also showed that simple vector addition can often produce meaningful results, such as king - man + woman queen. By leveraging the ability of these word vector representations to compose by simple summation, representations for phrases are easily computed with an element-wise addition.
Each phrase composed of words is therefore represented by a vector thanks to a word representation model pre-trained on large unlabeled text corpora. A vector representation for a phrase is then calculated by averaging its word vector representations:
Vector representations for all phrases can thus be obtained to initialized the matrix . is initialized randomly and trained to encode images in the same vector space than the phrases used for their descriptions.
4.4 Training with Negative Sampling
Each image is described by a multitude of possible phrases . We consider classifiers attributing a score for each phrase. We train our model to discriminate a target phrase from a set of negative phrases , with . With
, we minimize the following logistic loss function with respect to:
The model is trained using stochastic gradient descent. A new set of negative phrasesis randomly picked from the training set at each iteration.
5 From Phrases to Sentence
After identifying the most likely constituents in the image , we propose to generate sentences out of them. From this set, phrases are used to compose a syntactically correct description.
5.1 Sentence Generation
Using a statistical language framework, the likelihood of a certain sentence is given by:
Keeping this system as simple as possible and using the second order Markov property, we approximate Equation 4 with a trigram language model:
The best candidate corresponds to the sentence which maximizes the likelihood of Equation 5 over all the possible sizes of sentence. Because we want to constrain the decoding algorithm to include prior knowledge on chunking tags , we rewrite Equation 5 as:
Both conditions and
5.2 Sentence Decoding
At decoding time, we prune the graph of all possible sentences made out of the top
phrases with a beam search, according to three heuristics: (i) we consider only the transitions which are likely to happen (we discard any sentence which would have a trigram transition probability inferior to 0.01). This thresholding helps to discard sentences that are semantically incorrect; (ii) each predicted phrasesmay appear only once444This is easy to implement with a beam search, but intractable with a full search.; (iii) we add syntactic constraints which are illustrated in Figure 4. The last heuristic is based on the analysis of syntax in Section 3. In Figure 2, we see that a noun phrase is, in general, always followed by a verb phrase or a prepositional phrase, and both are then followed by another noun phrase. A large majority of the sentences contain three noun phrases interleaved with verb phrases or prepositional phrases. According the statistics reported in Figure 1, sentences with two or four noun phrases are also common, but sentences with more than four noun phrases are marginal. We thus repeat this process times until reaching the end of a sentence (characterized by a period).
5.3 Sentence Re-ranking
For each test image , the proposed model will generate a set of sentences. Sentence generation is not conditioned on the image, apart from phrases which are selected beforehand. Some phrase sequences might be syntactically good, but have low match with the image. Consider, for instance, an image with a cat and a dog. Both sentences “a cat sitting on a mat and a dog eating a bone” and “a cat sitting on a mat” are correct, but the second is missing an important part of the image. A ranking of the generated sentences is therefore necessary to choose the one that has the best match with the image.
Because a generated sentence is composed from phrases predicted by our system, we simply average the phrase scores given by Equation 1. For a generated sentence composed of phrases , a score between and is calculated as:
The best candidate is the sentence which has the highest score out of the generated sentences. This ranking helps the system to chose the sentence which is closer to the sample image.
6.1 Experimental Setup
6.1.1 Feature Selection
|Noun Phrase (NP)||4818||8982|
|Verb Phrase (VP)||2109||3083|
|Prepositional Phrase (PP)||128||189|
For each training set, only phrases occurring at least ten times are considered. This threshold is chosen to fulfil two objectives: (i) limit the number of phrases and therefore the size of the matrix
and (ii) exclude rare phrases to better generalize the descriptions. Statistics on the number of phrases are reported in Table1. For Flickr30k, this threshold covers about 81% of NP, 83% of VP and 99% of PP. For COCO, it covers about 73% of NP, 75% of VP and 99% of PP. Phrase representations are then computed by averaging vector representations of their words. We obtained word representations from the Hellinger PCA of a word co-occurrence matrix, following the method described in Lebret & Collobert (2014). The word co-occurrence matrix is built over the entire English Wikipedia555Available at http://download.wikimedia.org. We took the January 2014 version., with a symmetric context window of ten words coming from the 10,000 most frequent words. Words, and therefore also phrases, are represented in 400-dimensional vectors.
6.1.2 Learning the Multimodal Metric
The parameters are (initialized randomly) and (initialized with the phrase representations) which are tuned on the validation datasets. They are trained with randomly chosen negative samples and a learning rate set to 0.00025.
6.1.3 Generating Sentences from the Predicted Phrases
Transition probabilities for our constrained language model (see Figure 4) are calculated independently for each training set. No smoothing has been used in the experiments. Concerning the set of top-ranked phrases for a given test image, we select only the top five predicted verb phrases and the top five predicted prepositional phrases. Since the average number of noun phrases is higher than for the two other types of phrases (see Figure 1), more noun phrases are needed. The top twenty predicted noun phrases are thus selected.
6.2 Experimental Results
As a first evaluation, we consider the task of retrieving the ground-truth phrases from test image descriptions. Results reported in Table 2 show that our system achieves a recall of around 50% on this task on the test set of both datasets, assuming the threshold considered for each type of phrase (see 6.1.3). Note that this task is extremely difficult, as semantically similar phrases (the women / women / the little girls) are classified separately. Despite the possible number of noun phrases being higher, results in Table 2 reveal that noun phrases are better retrieved than verb phrases. This shows that our system is able to detect different objects in the image. However, finding the right verb phrase seems to be more difficult. A possible explanation could be that there exists a wide choice of verb phrases to describe interactions between the noun phrases. For instance, we see in Figure 3 that two annotators have used the same noun phrases (a man, a skateboard and a (wooden) ramp) to describe the scene, but they have then chosen a different verb phrase to link them (riding versus is grinding). Therefore, we suspect that a low recall for verb phrases does not necessarily mean that the predictions are wrong. Finding the right prepositional phrase seems, on the contrary, much easier. The high recall for prepositional phrase can be explained by much lower variability of this type of phrase compared to the two others (see Table 1).
|Noun Phrase (NP)||38.14||45.44|
|Verb Phrase (VP)||20.61||27.83|
|Prepostional Phrase (PP)||81.70||84.49|
|Mao et al. (2014)||-||-||-||-||-|
|Karpathy & Fei-Fei (2014)||-||-|
|Vinyals et al. (2014)||-||-||-||-||-||-|
|Donahue et al. (2014)|
|Fang et al. (2014)||-||-||-||-||-||-||-|
As a second evaluation, we consider the task of generating full descriptions. We measure the quality of the generated sentences using the popular, yet controversial, BLEU score (Papineni et al., 2002). Table 3 shows our sentence generation results on the two datasets considered. BLEU scores are reported up to 4-gram. Human agreement scores are computed by comparing the first ground-truth description against the four others666For all models, BLEU scores are computed against five reference sentences which give a slight advantage compared to human scores.. For comparison, we include results from recently proposed models. Our model, despite being simpler, achieves similar results to state of the art results. It is interesting to note that our results are very close to the human agreement scores.
We show examples of full automatic generated sentences in Figure 5. The simple language model used is able to generate sentences that are in general syntactically correct. Our model produces sensible descriptions with variable complexity for different test samples. Due to the generative aspect of the model, it can occur that the sentence generated is very different from the ground-truth and still provides a descent description. The last row of Figure 5 illustrates failure samples. We can see in these failure samples that our system has however outputted relevant phrases. There is still room for improvement for generating the final description. We deliberately choose a simple language model to show that competitive results can be achieved with a simple approach. A more complex language model could probably avoid these failure samples by considering a larger context. The probability for a dog to stand on top of a wave is obviously very low, but this kind of mistake cannot be detected with a simple trigram language model.
6.3 Diversity of Image Descriptions
In contrast to RNN-based models, our model is not trained to match a given image with its ground-truth descriptions , i.e., to give . Because our model outputs instead a set of phrases, this is not really surprising that only 1% of our generated descriptions are in the training set for Flickr30k, and 9.7% for COCO. While a RNN-based model is generative, it might easily overfit a small training data. Vinyals et al. (2014) report, for instance, that the generated sentence is present in the training set 80% of the time. Our model therefore offers a good alternative with the possibility of producing unseen descriptions with a combination of phrases from the training set.
6.4 Phrase Representation Fine-Tuning
|a grey cat||1||a grey dog||a gray cat|
|2||a grey and black cat||a grey and black cat|
|3||a gray cat||a brown cat|
|4||a grey elephant||a grey and white cat|
|10||a yellow cat||grey and white cat|
|home plate||1||a home plate||a home plate|
|4||a plate||home base|
|6||another plate||the pitch|
|9||a red plate||the batter|
|10||a dinner plate||a baseball pitch|
|a half pipe||1||a pipe||a pipe|
|2||a half||the ramp|
|5||a small clock||a hand rail|
|9||a large clock||a skate board ramp|
|10||a small plate||an empty pool|
Before training the model, the matrix is initialized with phrase representations obtained from the whole English Wikipedia. This corpus of unlabeled text is well structured and large enough to provide good word vector representations, which can then produce good phrase representations. However, the content of Wikipedia is clearly different from the content of the image descriptions. Some words used for describing images might be used in different contexts in Wikipedia, which can lead to out-of-domain representations for certain phrases. This becomes thus crucial to adapt these phrase representations by fine-tuning the matrix during the training777Experiments with a fixed phrase representations matrix significantly hurt the general performance. We observe about a 50% decrease in both datasets with the BLEU metric. Since the number of trainable parameters is reduced, the capacity of should be increased to guarantee a fair comparison.. Some examples of noun phrases are reported in Table 4 with their nearest neighbors before and after the training. These confirm the importance of fine-tuning to incorporate visual features. In Wikipedia, cat seems to occur in the same context than dog or other animals. When looking at the nearest neighbors of a phrase such as a grey cat, other grey animals arise. After training on images, the word cat becomes the important feature of that phrase. And we see that the nearest neighbors are now cats with different colours. In some cases, averaging word vectors to represent phrases is not enough to capture the semantic meaning. Fine-tuning is thus also important to better learn specific phrases. Images related to baseball games, for example, have enabled the phrase home plate to be better defined. This is also true for the phrase a half pipe with images about skateboarding. This leads to interesting phrase representations, grounded in the visual world, which could be possibly used in natural language applications in future work.
In this paper, we propose a simple model that is able to infer different phrases from image samples. From the phrases predicted, our model is able to automatically generate sentences using a statistical language model. We show that the problem of sentence generation can be effectively achieved without the use of complex recurrent networks. Our algorithm, despite being simpler than state-of-the-art models, achieves similar results on this task. Also, our model generate new sentences which are not generally present in training set. Future research directions will go towards leveraging unsupervised data and more complex language models to improve sentence generation. Another interest is assessing the impact of visually grounded phrase representations into existing natural language processing systems.
This work was supported by the HASLER foundation through the grant “Information and Communication Technology for a Better World 2020” (SmartWorld).
- Chatfield et al. (2014) Chatfield, K., Simonyan, K., Vedaldi, A., and Zisserman, A. Return of the Devil in the Details: Delving Deep into Convolutional Nets. In British Machine Vision Conference, 2014.
- Chen & Zitnick (2014) Chen, X. and Zitnick, C. L. Learning a Recurrent Visual Representation for Image Caption Generation. CoRR, abs/1411.5654, 2014.
- Donahue et al. (2014) Donahue, J., Hendricks, L. A., Guadarrama, S., Rohrbach, M., Venugopalan, S., Saenko, K., and Darrell, T. Long-term Recurrent Convolutional Networks for Visual Recognition and Description. CoRR, abs/1411.4389, 2014.
- Fang et al. (2014) Fang, H., Gupta, S., Iandola, F. N., Srivastava, R., Deng, L., Dollár, P., Gao, J., He, X., Mitchell, M., Platt, J. C., Zitnick, C. L., and Zweig, G. From Captions to Visual Concepts and Back. CoRR, abs/1411.4952, 2014.
Hodosh et al. (2013)
Hodosh, M., Young, P., and Hockenmaier, J.
Framing image description as a ranking task: data, models and evaluation metrics.Journal of Artificial Intelligence Research, 2013.
- Karpathy & Fei-Fei (2014) Karpathy, A. and Fei-Fei, L. Deep Visual-Semantic Alignments for Generating Image Descriptions. CoRR, abs/1412.2306, 2014.
- Kiros et al. (2014) Kiros, R., Salakhutdinov, R., and Zemel, R. S. Unifying Visual-Semantic Embeddings with Multimodal Neural Language Models. volume abs/1411.2539, 2014.
- Kulkarni et al. (2011) Kulkarni, G., Premraj, V., Dhar, S., Li, Siming, Choi, Yejin, Berg, A. C., and Berg, T. L. Baby Talk: Understanding and Generating Simple Image Descriptions. In CVPR, 2011.
- Kuznetsova et al. (2012) Kuznetsova, P., Ordonez, V., Berg, A. C., Berg, T. L., and Choi, Y. Collective generation of natural image descriptions. In ACL, 2012.
- Lebret & Collobert (2014) Lebret, R. and Collobert, R. Rehabilitation of Count-based Models for Word Vector Representations. CoRR, abs/1412.4930, 2014.
- LeCun et al. (1998) LeCun, Y., Bottou, L., Bengio, Y., and Haffner, P. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 1998.
- Lin et al. (2014) Lin, T.-Y., Maire, M., Belongie, S., Hays, J., Perona, P., Ramanan, D., Dollár, P., and Zitnick, C. L. Microsoft COCO: Common Objects in Context. In ECCV, 2014.
- Mao et al. (2014) Mao, J., Xu, W., Yang, Y., Wang, J., and Yuille, A. L. Explain Images with Multimodal Recurrent Neural Networks. CoRR, abs/1410.1090, 2014.
- Mikolov et al. (2013a) Mikolov, T., Chen, K., Corrado, G., and Dean, J. Efficient Estimation of Word Representations in Vector Space. ICLR Workshp, 2013a.
- Mikolov et al. (2013b) Mikolov, T., Sutskever, I., Chen, K., Corrado, G., and Dean, J. Distributed Representations of Words and Phrases and their Compositionality. In NIPS. 2013b.
- Mitchell et al. (2012) Mitchell, M., Han, X., Dodge, J., Mensch, A., Goyal, A., Berg, A., Yamaguchi, K., Berg, T., Stratos, K., and Daumé, III, H. Midge: Generating Image Descriptions from Computer Vision Detections. In EACL, 2012.
Mnih & Kavukcuoglu (2013)
Mnih, A. and Kavukcuoglu, Koray.
Learning word embeddings efficiently with noise-contrastive estimation.In NIPS. 2013.
- Papineni et al. (2002) Papineni, K., Roukos, S., Ward, T., and Zhu, W.-J. BLEU: A Method for Automatic Evaluation of Machine Translation. In ACL, 2002.
- Pennington et al. (2014) Pennington, J., Socher, R., and Manning, C. D. GloVe: Global Vectors for Word Representation. In EMNLP, 2014.
- Socher et al. (2014) Socher, R., Karpathy, A., Le, Q. V., Manning, C. D., and Ng, A. Y. Grounded Compositional Semantics for Finding and Describing Images with Sentences. TACL, 2014.
Srivastava & Salakhutdinov (2014)
Srivastava, N. and Salakhutdinov, R.
Multimodal Learning with Deep Boltzmann Machines.
Journal of Machine Learning Research, 2014.
- Venugopalan et al. (2014) Venugopalan, S., Xu, H., Donahue, J., Rohrbach, M., Mooney, R. J., and Saenko, K. Translating Videos to Natural Language Using Deep Recurrent Neural Networks. CoRR, abs/1412.4729, 2014.
- Vinyals et al. (2014) Vinyals, O., Toshev, A., Bengio, S., and Erhan, D. Show and Tell: A Neural Image Caption Generator. CoRR, abs/1411.4555, 2014.
- Yao et al. (2010) Yao, B. Z., Yang, X., Lin, L., Lee, M. W., and Zhu, S. C. I2T: Image Parsing to Text Description. Proceedings of the IEEE, 2010.