<figure><img src="image_1.png" /></figure>

HAL
open science

# Image Semantic Description Based on Deep Learning with Multi-attention Mechanisms

Jian Yang, Zuqiang Meng

<figure><img src="image_2.png" /></figure>

## To cite this version:

Jian Yang, Zuqiang Meng. Image Semantic Description Based on Deep Learning with Multi-attention Mechanisms. 10th International Conference on Intelligent Information Processing (IIP), Oct 2018, Nanning, China. pp.356-362, 10.1007/978-3-030-00828-4_36. hal-02197765

HAL Id: hal-02197765

https://inria.hal.science/hal-02197765

Submitted on 30 Jul 2019

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_3.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
Image semantic description based on deep learning with
multi-attention mechanisms

Jian Yang, ZuQiang Meng

College of Computer, Electronics and Information, Guangxi University Nanning 530004, China

yangjian1015@foxmail.com

**ABSTRACT.** In the era of big data, cross-media and multi-modal data are expanding, and data processing methods fail to meet corresponding functional requirements. Aiming at the characteristic of large expression gap of multi-model data, This paper proposes a multimodal data fusion method based on deep learning, which combines the advantages of deep learning in the field of image detection, text sequence prediction, and the multi-attention mechanism. The BLEU algorithm is used to calculate the similarity of four levels of description statements of model output and image. Training and testing were conducted in the Flickr8K data set. Comparing with the traditional single mode state image description method, the experiments show that under the BLEU index, the multi-AM model can achieve better results.

**KEYWORDS:** Multimodal data, Deep learning, Attention mechanism, Image semantic expression

# 1 Introduction

With the emergence of various high-tech electronic products, the carrier of important information is no longer a traditional single text, video or audio, but a variety of media. Cross-media and multi-modal data mainly showed the underlying data's characteristics of heterogeneous and high-level semantic expression similar to the "semantic gap" problem, in recent years, more and more scholars and researchers have been involved in the study of multi-modal data[1,2].

Image scene description is an important research direction in the field of image understanding, its object of study is by the color, texture, shape representation of image information, such as the target task is to get an accurate description of image content text sequences, across the two modal images and text information expression. Traditional image description task mainly has two key issues - image content representation and classification judgment, namely to find the most representative image scene, and then to learning and training of scene, scene category classification model. Image content description often requires human visual feature extracting, design visual dictionary, such as complex work, and need additional researchers' prior knowledge, this
part of the work has a great influence for the classification effect. The main sources of problems or image and text data in the underlying data expression differences, how to eliminate the differences, and for a variety of modal data fusion is the core content of this paper.

Hinton since 2006, put forward the concept of deep learning, a large number of papers published about deep learning, in-depth study has been successfully applied to computer vision, speech recognition, natural language processing, and other fields. In multiple modal data fusion, image and text, for example, the depth of the neural network can use different models of two kinds of modal data feature extraction, and image and text are similar characteristics of space vector modeling method, therefore, for the fusion of images and text on the feature space, image semantic expression based on deep learning can be realized.

## 2 Related Work

The study of semantic description of traditional image scenes is mainly based on single-modality images. To reduce the “semantic gap”, an image analysis layer such as a visual dictionary is constructed between the low-level visual features and high-level semantic information. Image semantic information description must establish the mapping relationship between low-level visual features and high-level semantics. In recent years, more and more scholars have begun to pay attention to the research field of multimodal data fusion. Sawant Neela, et al (2011) thinks it needs to capture events, locations, and personalities in addition to the visual features of the human beings in the traditional object monitoring and scene interpretation [3]. The abstract concept of a reference, Ma, Hao, et al (2011) carried out related research on image and text fusion methods, and proposed a data fusion framework based on image content and tags-a new random walk model that uses fusion parameters to balance content and labels between the impact [4]. Hollink L, et al. (2005) describes a semi-automatic image annotation algorithm in specific fields, the goal is to identify domain features to increase semantic understanding [5].

In recent years, the intensified research on deep neural networks has remained high and breakthroughs have also been made. This has benefited from convolutional neural networks and recurrent neural networks [6], and most researchers are based on these two types of deep neural network models and have done a lot of optimization work. Karpathy, Andrej, and F. F. Li (2015) and Xu, Kelvin, et al (2015) did a lot of work in the field of image understanding [7,8]. F. F. Li et al. propose an image semantic alignment model, extract the key information in the image and align it with the keywords in the sentence description. However, they all use the RNN structure in the language model, and there is a lack of semantic relevance.
## 3 Deep neural network model based on multi-attention mechanism

In this paper, we propose a deep neural network based on Convolution Neural Network(CNN) and Long Short Term Memory Network Network(LSTM) to describe the image in sentences, and introduce multi-attention mechanism on this basis. When we describe an image, we need to pay attention to the content of the image as well as the language foundation. When we get the word "cat," we focus on the cat part of the image and ignore the rest. The prediction of a word requires not only the introduction of attention mechanism in the language model, but also in the image.

### 3.1 CNN for Feature Extraction

Russakovsky, Olga, et al (2015) summarized the competition results of each team in the ImageNet competition and the brief description of the algorithm in the last five years[9]. Among them VGG network performance is particularly outstanding. Simo-nyan, Karen, and A. Zisserman(2014) believed that the filter of 7x7 could be decomposed into a number of 3x3 filters, the smaller filter means more flexible channel[10]. Fig.1 shows the convolution structure of vgg-16 network, We used his convolutional layer to extract image features as input to the image part.

### 3.2 LSTM for Sequences' Predict

DNN may be able to extract excellent characteristic expression, but LSTM is better than DNN in word prediction. LSTM is an improved recurrent neural network[11], general RNN cannot save too much information, there is only one state in the hidden layer, it is very sensitive to short-term input, if we add another state C to save long-term information, the problem will be solved. LSTM uses gate to control long-term status C. The gate can be expressed as:

$$g(x) = \sigma(Wx + b) \qquad (1)$$

W is the weight vector of the gate and b is the bias term. σ is the sigmoid function and the range is (0,1), so the state of the gate is half open and half closed. The structure of a single node in the LSTM network is shown in Fig.1. The final output of the LSTM is jointly controlled by the output gate and cell state:

$$h_t = o_t \circ tanh(c_t) \qquad (2)$$
<figure><img src="image_4.png" /><figcaption>Fig. 1. Calculation of a single LSTM node</figcaption></figure>

Because of the control of oblivion gate, it can save the information of a long time ago, and because of the control of the input door, it can avoid the current inconsequential content from entering the memory.

3.3 Multi-attention mechanism

The AM model is one of the most important developments in the NLP field in the past
few years, which appear in most of the current papers are attached to the Encoder-
Decoder framework. But the AM model can be used as a general idea, When a gen-
eral RNN model generates a language sequence, the predicted next word is only relat-
ed to its first n words, and n is generally less than 5.

$$
\mathbf{y}_i = f(\mathbf{y}_{i-1}, \mathbf{y}_{i-2}, \mathbf{y}_{i-3}, \dots, \mathbf{C}) \qquad (3)
$$

The above formula C represents the semantic encoding, Obviously the semantic se-
mantics of each word is C is unreasonable, and a word will not only be related to the
most recent words, So we give each word a probability distribution that expresses its
relevance to other words, and Replace C with Cᵢ.

$$
c_i = \sum_{j=1}^{T_x} \alpha_{ij} h_j \qquad (4)
$$

$T_x$ indicates the number of other words associated with $C_i$, $\alpha_{ij}$ represents the probability of interest between two words. $h_j$ is the information of the word itself. The
question now is how to calculate the probability distribution. It is usually to calculate
the similarity between the current input information **H**<sub>*i*</sub> and the previous information
**h**<sub>*j*</sub>. In the word2vec model, it is the distance between two vectors.

After going through a multi-layer convolutional structure, the image information is
compressed into a vector I. When predicting each word, you need to associate some
information in the vector. The attention parameter W for the image is what we need to
train to get.

$$
A_i = I \circ W_i \tag{5}
$$

Finally, the functional relationship of each predicted word is as follows and The model is shown in Fig. 2.

$$
y_i = f(A_i, C_i, y_{i-1}, y_{i-2}, y_{i-3}, \dots) \quad (6)
$$

<figure><img src="image_5.png" /><figcaption>Fig. 2. Deep neural network of multi-attention mechanism</figcaption></figure>

4 Experiments

In order to compare with the prior art, we conducted a large number of experiments using the BLEU metrics to evaluate the effectiveness of our model. Experiments used the Flickr 8K data set, contrast traditional image scene expression method.

4.1 Experimental environment and parameter deployment

Experiments using the current popular TensorFlow framework, and VGG-16 model to
extract image features, In the whole model, set the batch-size to 8 to relieve the pres-
sure of GPU memory. Fully connected layer functions as a "classifier" throughout the
convolutional neural network, while the convolutional layer, the pooled layer, and the
activation function layer can be viewed as mapping the image to the feature space.
Deeper layers will inevitably bring better results.

The experiment uses the Flickr8k dataset, which includes Flickr8k_Dataset and Flickr8k_text. We compressed the image to a size of 300x300 pixels so that we could train more samples; In Flickr8k_text, each image corresponds to 4 different types of descriptions. We use Word2vec to vectorize the words. In terms of semantically similar words, the Euclidean distances of their vectors are often very close. Then we only select the first 200 words of frequency, and the rest are replaced by [UNK], which makes the load of the model smaller.

## 4.2 evaluating indicator

The popular automatic evaluation method is the BLEU algorithm proposed by IBM[12]. The BLEU method first calculates the number of matching n-grams in the reference sentence and the generated sentence, and then calculates the ratio of the number of n-grams in the generated sentence as an evaluation index. It focuses on the accuracy of generating the word or phrase in the sentence. The accuracy of each order N-gram can be calculated by the following formula:

$$P_n = \frac{\sum_{i} \sum_{k} \min(h_k(c_i), \max_{j \in m} h_k(s_{ij}))}{\sum_{i} \sum_{k} \min(h_k(c_i))} \quad (7)$$

The upper limit of N is 4, which means that only the accuracy of 4-gram can be calculated.

## 4.3 Results and discussion

There are two comparisons in the experiment. One is to compare the traditional basic model, and the other is to compare the current mainstream model. As can be seen from Table 1, the accuracy of the Multi-AM model in the keyword is better than the traditional model.

<table><caption>**Table 1.** Comparison with other methods on the flicker8K dataset</caption><thead><tr><th>model</th><th>BLEU-1</th><th>BLEU-2</th><th>BLEU-3</th><th>BLEU-4</th></tr></thead><tbody><tr><td>Object-based</td><td>54</td><td>28.0</td><td>14.5</td><td>13.1</td></tr><tr><td>Scene-based</td><td>57.9</td><td>38.3</td><td>17.4</td><td>16.0</td></tr><tr><td>Multi-AM</td><td><b>68.2</b></td><td><b>42.3</b></td><td><b>23.5</b></td><td><b>18.3</b></td></tr></tbody></table>

From the results of Table 2, the accuracy of one and two keywords is better than other mainstream algorithms, but the effect of obtaining more keywords is not good. But the effect of obtaining more keywords is not good.
<table><caption>**Table 2.** Comparison with other mainstream model on the flicker8K dataset</caption><thead><tr><th>model</th><th>BLEU-1</th><th>BLEU-2</th><th>BLEU-3</th><th>BLEU-4</th></tr></thead><tbody><tr><td>LogBilinear</td><td>54</td><td>28.0</td><td>14.5</td><td>13.1</td></tr><tr><td>Multi-RNN</td><td>57.9</td><td>38.3</td><td><b>24.5</b></td><td>16.0</td></tr><tr><td>R-CNN</td><td>63.0</td><td>35.5</td><td>21.8</td><td><b>20.2</b></td></tr><tr><td>Multi-AM</td><td><b>68.2</b></td><td><b>42.3</b></td><td>23.5</td><td>18.3</td></tr></tbody></table>

## 5 Conclusions

Semantic description of images is a complex task, and the framework based on deep learning has become the current mainstream method. This paper proposes a multi-attention mechanism based on deep neural network, we need to understand the grammar of the sentence generation, as well as the content in the image. Words have different levels of attention to image content and different levels of attention from context. Experimental results show that the multi-attention mechanism can achieve higher scores under the BLEU evaluation criteria, which shows that the method can extract more keywords.

Future research should attempt to lack the sentence description data set and improve the semantic matching of sentences. We need to accurately position the predicted word in the image, which is very difficult.

## 6 References

1. Vedantam, Ramakrishna, C. L. Zitnick, and D. Parikh. "CIDEr: Consensus-based image description evaluation." Computer Vision and Pattern Recognition IEEE, 2015:4566-4575.

2. Vinyals, Oriol, et al. "Show and tell: A neural image caption generator." Computer Vision and Pattern Recognition IEEE, 2015:3156-3164.

3. Sawant, Neela, J. Li, and J. Z. Wang. "Automatic image semantic interpretation using social action and tagging data." Multimedia Tools & Applications 51.1(2011):213-246.

4. Ma, Hao, et al. "Bridging the Semantic Gap Between Image Contents and Tags." IEEE Transactions on Multimedia 12.5(2010):462-473.

5. Zeiler, Matthew D., and R. Fergus. "Visualizing and Understanding Convolutional Networks." 8689(2013):818-833.

6. Hollink, L., S. Little, and J. Hunter. "Evaluating the application of semantic inferencing rules to image annotation." International Conference on Knowledge Capture ACM, 2005:91-98.
7. Karpathy, Andrej, and F. F. Li. "Deep visual-semantic alignments for generating image descriptions." IEEE Show and tell: A neural Transactions on Pattern Analysis & Machine Intelligence 39.4(2017):664-676.

8. Xu, Kelvin, et al. "Show, Attend and Tell: Neural Image Caption Generation with Visual Attention." Computer Science (2015):2048-2057.

9. Russakovsky, Olga, et al. "ImageNet Large Scale Visual Recognition Challenge." International Journal of Computer Vision 115.3(2015):211-252.

10. Simonyan, Karen, and A. Zisserman. "Very Deep Convolutional Networks for Large-Scale Image Recognition." Computer Science (2014).

11. Jia, Xu, et al. "Guiding the Long-Short Term Memory Model for Image Caption Generation." IEEE International Conference on Computer Vision IEEE, 2016:2407-2415.

12. Papineni, K. "A Method for Automatic Evaluation of Machine Translation." Proc Acl (2002).