Pixel-BERT: Aligning Image Pixels with Text by Deep Multi-Modal Transformers

04/02/2020 ∙ by Zhicheng Huang, et al. ∙ English 设为首页 Microsoft SUN YAT-SEN UNIVERSITY 0

We propose Pixel-BERT to align image pixels with text by deep multi-modal transformers that jointly learn visual and language embedding in a unified end-to-end framework. We aim to build a more accurate and thorough connection between image pixels and language semantics directly from image and sentence pairs instead of using region-based image features as the most recent vision and language tasks. Our Pixel-BERT which aligns semantic connection in pixel and text level solves the limitation of task-specific visual representation for vision and language tasks. It also relieves the cost of bounding box annotations and overcomes the unbalance between semantic labels in visual task and language semantic. To provide a better representation for down-stream tasks, we pre-train a universal end-to-end model with image and sentence pairs from Visual Genome dataset and MS-COCO dataset. We propose to use a random pixel sampling mechanism to enhance the robustness of visual representation and to apply the Masked Language Model and Image-Text Matching as pre-training tasks. Extensive experiments on downstream tasks with our pre-trained model show that our approach makes the most state-of-the-arts in downstream tasks, including Visual Question Answering (VQA), image-text retrieval, Natural Language for Visual Reasoning for Real (NLVR). Particularly, we boost the performance of a single model in VQA task by 2.17 points compared with SOTA under fair comparison.



There are no comments yet.


page 14

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

With the success of self-supervised learning applied for representation learning in natural language process field

[34, 9], we have witnessed many recent researches addressing the task of cross-modality learning, especially in vision and language [6, 18, 19, 21, 22, 29, 33, 41], with similar self-supervised learning way. Pre-training is widely used in those works to provide a strong representation for both vision and language in cross-modality domain. Most of them utilize BERT-based language feature and region-based visual feature as the input for joint embedding learning in pre-trained models.

The semantic gap between different modalities has always been treated as one of the most important challenges in cross-modality researches. Early works in vision and language, such as Visual Question Answering (VQA) [3]

and image captioning

[35], utilize CNN features directly extracted from a pre-trained model on image classification task. Later on, with the introduction of Visual Genome Dataset [16]

and the proposal of Bottom-Up and Top-Down Attention model


, most recent vision and language researches, including the pre-trained models mentioned above, utilize region-based visual features extracted from object detection model (e.g., Faster R-CNN) for better performance. However, region-based visual feature extractors are designed for specific visual tasks (e.g. object detection), and this will cause an information gap with language understanding. Specifically, the shape rectangle of bounding boxes restricts will bring noisy information in the background. Some important factors of visual information are lost, such as shapes of objects, spatial relations between objects of overlapped bounding boxes, etc. Moreover, the feature representation capability is limited to the given categories of such task-specific model while visual information about broader semantics such as scene and sentiment are also lost in the object detection model. We show some examples that region-based visual features cannot well handle in Fig.

1. In Example (A), it is difficult for object detection model to obtain the status of the plane. For Example (B), even though we can detect the “girl” and “ground”, since there is overlap between their regions, it will be even hard for further fusion embedding models to judge the actual spatial relation given their bounding boxes. Similarly in Example (C), with only visual features of “giraffe”, it is difficult to infer the status of the animals.

Figure 1: Examples of images, questions (Q) and answers (A) in VQA2.0 dataset. In these cases, region-based visual features cannot well handle the questions.

Existing researches that use region-based visual features and language embedding as input of Transformer for cross-modality joint learning are limited to the visual semantics represented by the visual features. Thus, we step out of the bounding box to make the full power of visual information in images for vision and language learning. We propose Pixel-BERT

that learns to align image pixels with text to build a more thorough semantic embedding between visual and textual information. Pixel-BERT consists of three parts: a fully convolutional neural network (CNN) that takes image pixels as input for visual embedding learning, a word-level token embedding based on BERT, and multi-modal Transformers for jointly learning of visual and language embedding.

To learn a universal representation for most vision and language tasks, we first pre-train our model with image-sentence pair dataset similar to other cross-modality pre-training researches [6, 18, 19, 21, 22, 29, 33, 41]. Two pre-training tasks and one pre-training mechanism are used in our pre-training procedure. For language, we follow other pre-training works [6, 29, 33] to use Masked Language Modeling (MLM) for the prediction of masked tokens with surrounding text and image. For vision and language interaction, we follow [6]

to apply Image-Text Matching (ITM) to classify whether an image and sentence pair is matched or not. For vision, we propose a random pixel sampling mechanism to make up for the difficulty of predicting pixel-level features. The random pixel sampling mechanism improves the robustness of visual feature learning and overcome the problem of overfitting.

The contributions of this paper are summarized as follows:

  • We propose Pixel-BERT that consists of a CNN-based visual encoder and deep multi-modal Transformers to jointly learn visual and language embedding. We are the first to consider aligning vision and language semantics in pixel and text level using self-supervised learning.

  • We use our model in pre-training manner and propose a random pixel sampling mechanism to improve the robustness of visual representation learning.

  • Extensive experiments demonstrate the effectiveness of our approach by achieving the most state-of-the-art performances in various tasks, including VQA, Image-Text Retrieval and NLVR. In particular, our approach accelerates the performance of VQA by 2.17 points compared with SOTA [6] in fair comparison and even higher than its larger model.

2 Related Works

2.1 Pre-training Mechanism

For vision and language tasks, a better understanding of the semantic is important to get better joint representation. For visual-content understanding, several backbone models [13, 32, 38] has proposed for pure visual understanding, which have shown their effectiveness on large datasets [8]. Pioneering work [24] also shows its generalizability of the pre-trained backbone models by fine-tuning them on different downstream tasks. In terms of language understanding, we have witnessed a rapid process towards building a universal backbone model with large-scale contextualized pre-training  [7, 9, 23] in recent years. They improved the performances on various tasks to significant levels. For cross-modality researches, many methods [6, 18, 19, 21, 22, 29, 31, 33, 41] have been proposed in very recent period. They focus on leaning the visual and sentence dense connection between different modalities. Existing methods can be clustered into two groups based on their network structure. Some researches [21, 33] utilize two-stream neural networks based on the Transformer [34]. The two-stream neural networks process visual and language information respectively and fuse them afterward by another Transformer layer. On the other hand, there are some methods [1, 6, 18, 22, 29] apply single-stream neural network. They use BERT [9]

to learn a bi-directional joint distribution over the detection bounding box feature and sentence embedding feature. The differences among them are the training method, loss function, and datasets. Pixel-BERT is categorized into second group while our way of visual embedding is different from all those methods.

2.2 Visual Feature Embedding in Vision and Language Tasks

Cross-modality tasks, such as VQA [11], image captioning [39], require understanding of both sentence and visual semantics. Early method [5] directly adopts CNN features extracted from pre-trained classification model as visual representation. Later on, with the introduction of Visual Genome Dataset [16] and the proposal of Bottom-Up and Top-Down Attention model [2], most recent researches related to vision and language utilize region-based visual features extracted from object detection models (e.g., Faster R-CNN [24]) for better performance [6, 15, 22, 33]. With those methods, the visual semantic is limited by Visual Genome detection categories. While the language domain contains much more semantic. One key difference between our model and the other methods is the visual semantic embedding methods. Instead of using detection bounding box features as the visual semantic representation for visual and language embedding learning, we combine the visual encoder representation learning network into one framework and input the source image as the visual input. We use this model for cross-modality pre-training for learning richer visual semantics.

Figure 2: Pixel-BERT: The model contains a visual feature embedding module, a sentence feature embedding module, and a cross-modality alignment module. Pixel-BERT takes image-sentence pairs as input, and outputs the attention features of each input element. Images are passed into a pixel feature embedding module pixel by pixel and sentences are fed into a sentence feature embedding module token by token. The model can be pre-trained by MLM and ITM tasks, and can be flexibly applied to downstream tasks (e.g. VQA, retrieval, etc).

3 Approach

The overall architecture of our proposed end-to-end framework with CNN-based visual encoder and cross-modal Transformers for visual and language embedding learning is illustrated in Fig. 2. Image-sentence pairs are taken as input to produce joint embedding features. The whole network can be end-to-end pre-trained by MLM and ITM tasks, and is suitable to be applied to downstream tasks.

In this section, we will first revisit the Transformer model in Sec.3.1, explain our model architecture of Pixel-BERT in detail in Sec.3.2 and pre-training procedure in Sec.3.3.

3.1 Revisit Transformer

Pixel-BERT adopts the BERT [9] as cross-modality alignment module. BERT is a multi-layer bidirectional Transformer encoder, which is able to model the dependency of all input elements. Before introducing our Pixel-BERT, we first revisit the architecture of Transformer.

The two key operations in the basic Transformer module are self-attention and feed-forward. Given the input , where is the element number and indicates the feature dimension, we first compute query , key and value by


where , and are corresponding weight matrices. We compute the attention output by


where indicates the self-attention weights of each input element. We then compute the output by


where FFN

consists of a group of fully-connected layers with ReLU activation function as in

[34]. Above operations builds dense connections among all input elements, including the each element itself.

In cross-modality tasks, the input elements come from visual and language domains. We propose to build dense connections among both intra-domain (i.e. image-image, sentence-sentence) and inter-domain (i.e. image-sentence) by Transformer, which will be detailed explained in Sec. 3.2.3.

3.2 Model Architecture

The inputs of vision and language tasks come from different modalities. Natural language is usually in the form of a sentence which can be split into a sequence of words. We follow [6, 18, 21, 22, 29, 33, 41]

to first tokenize each word, and embed each token into a vector. The input coming from the visual domain is usually an image. Most recent methods embed the visual input by extracting region-based features with object detection model like Faster R-CNN

[2]. However, such region-based visual feature extractors are designed for specific visual tasks (e.g. object detection), which have an information gap with language understanding. Specifically, a bounding box is in the shape of a rectangle, which may include noisy background and miss the shape and spatial relation information. Besides, the feature representation ability is limited by the training categories of such task-specific model. Moreover, visual information about broader semantics such as scene and sentiment are also lost in the object detection model. To utilize visual information, we propose a pixel-based end-to-end framework for vision and language embedding learning, called Pixel-BERT.

3.2.1 Sentence Feature Embedding

We follow [9] to encode the language information. Given a sentence as input, we first split it into a sequence of words, and use WordPiece to tokenize each word into token. We then adopt an embedding matrix to embed each token into a vector. Here we use to represent the embedded sequence, where indicates the sequence length, and is the embedding dimension. We follow other BERT-based language researches and add the positional embedding to encode the position information. The final representation of sentence can be calculated by


where indicates the embedding vector at position , is a semantic embedding vector and is a normalization function described in [4]. Since the summation of position and semantic embedding is mathematic equivalence to one embedding, we will omit the term in our implementation.

3.2.2 Image Feature Embedding

Most recent vision and language researches follow Bottom-Up and Top-Down Attention[2] to extract visual features by Faster R-CNN [24] trained on Visual Genome dataset. The detectors extract region features by first detecting region under pre-defined categories, and extract their features before the final classifier. The representation ability of such extracted features will be limited by the detection categories.

We use pixels to represent regions rather than use bounding boxes so that we can break the limit of shapes and borders. The pixel features are learned by a CNN visual backbone such as ResNet[13]. Given an input image , we first use CNN backbone such as ResNet-50, to extract its feature, then flat the feature along the spatial dimension. We denote the flatten feature as , where indicates the number of feature pixels. The visual embedding feature can be computed by


where is a semantic embedding vector for distinguishing the difference with language embedding. Since all pixels share the same , this embedding vector can be considered as a bias term and be combined with the CNN backbone.

3.2.3 Cross-Modality Module

We adopt Transformer to learn cross-modality attention between image pixels and language tokens. After obtaining sentence embedding vectors and pixel features, we combine all vectors to construct the input sequence. We also adding two special tokens [CLS] and [SEP] to learning joint classification features and specify token length, respectively. The final input sequence to Transformer is formulated as


The CNN backbone and the Transformer is combined into a single model, which is end-to-end trainable. When we apply learning supervision on the output of Transformer, the gradient can backward to the CNN backbone, and thus the features learned by the CNN backbone would be more suitable to the target learning task. This can break the domain gap between.

3.3 Pre-Training

In order to learn a universal visual and sentence embedding representation for vision and language-related tasks, we apply the self-supervised method to pre-train a model on a large aggregated dataset. We follow [6, 18, 21, 22, 29, 33, 41] to conduct two pre-training tasks, including Masked Language Modeling (MLM) and Image-Text Matching (ITM). Compared with existing methods that rely on the detection model to extract region-based visual features, our model uses the source image as input to do pre-training tasks.

3.3.1 Masked Language Modeling

To pre-train the model and build the mapping between language tokens and visual contents, we take the Masked Language Model (MLM) task in the cross-modality domain. Specifically, we randomly mask language tokens with a probability of

, and require the model to predict the masked tokens based on other non-masked tokens and visual tokens. The learning target can be formulated as


where indicates the masked token, is the model parameters, and indicates the like-hood generated function.

Different from the single-modality task in BERT where the masked tokens are only predicted from the surrounding non-masked tokens in the language domain, our model can handle the cross-modality scenario where ambiguity may occur using only language modality. MLM task can encourage the model to infer the masked tokens from both language and visual tokens, which can help build the mapping from language modality to the visual modality.

3.3.2 Image-Text Matching

Some downstream tasks, such as image-text retrieval, require the model to distinguish whether a sentence can well describe an image, or in other words, whether they are matched or not. To enhance the cross-modalities matching, we adopt image-text matching (ITM) task for pre-training as previous work [6]. During training, we sample all image-sentence pairs provided by datasets, and consider them as positive samples. We also randomly shuffle the datasets consider the unmatched image-sentence pairs as negative samples. To prevent learning bias, we adopt the same number of positive samples and negative samples.

We apply a binary classifier on the joint embedding feature of [CLS] token to classify whether the input image and sentence are matched or not. ITM task is driven by following loss function:


where indicates whether the image and sentence is matched, and indicates the classification score generated function.

3.3.3 Pixel Random Sampling

To improve the robustness of feature learning and avoid overfitting, inspired by dropout[28], we propose to randomly sample feature pixels during pre-training. At each iteration, after extracting pixel features, we will randomly sample a part from them and feed it into Transformer. Such pixel random sampling can benefit the model training in two ways. First, it can encourage the model to learn semantic knowledge from incomplete visual input, and thus enhance the robustness. Second, it reduce the number of input elements, so that it can reduce the computation cost and accelerate the training progress. We will randomly sample a fixed number of pixels from the feature map for each input image in our experiments.

4 Experiments

4.1 Pre-training

Task Dataset #Imgs #Text Training Testing Metric
Pretrain VG 101K 5.06M train+val - -
COCO 106K 533K train+restval - -
VQA VQA2.0 204K 1.1M train+val test-dev/test-std VQA-score
NLVR NLVR 214K 107K train dev/test Accuracy
IR & TR COCO 92K 460K train+restval test Recall@1,5,10
Flickr30K 32K 160K train+restval test
Table 1:

Statistics of different datasets, data splits and evaluation metrics used for pre-training and downstream tasks.

4.1.1 Datasets

We pre-train our Pixel-BERT on two large-scale image-sentence datasets: MS-COCO [20], Visual Genome [16]. We utilize the image-level caption annotations in MS-COCO and region-level caption annotations in Visual Genome as training data for pre-training. For Visual Genome dataset, we adopt data in both train and val for training. For MS-COCO, we follow [14] to split the whole dataset into train, restval, val and test. Since one of our downstream tasks, image-text retrieval, is conducted on MS-COCO dataset, to avoid data leak, we use train and restval splits for training. The statistic of training samples can be found in the first two rows of Table 1.

4.1.2 Implementation Details

During pre-training, our Pixel-BERT receives a batch of image-sentence pairs as input in each iteration. We first use the WordPiece tokenizer [37] as used in BERT to split each sentence into language tokens. We use ResNet-50 as visual backbone for ablation analysis, and follow [27, 29]

to adopt more powerful ResNeXt-152 to obtain better performance. We use public accessible pre-trained model on ImageNet

[8] to initialize the parameters of the visual backbone. We resize the shorter edge of input images to , and limit the longer edge lower than when using ResNet-50 as visual backbone. When using ResNeXt-152, considering the GPU memory usage, we adjust the size of the shorter edge and longer edge limits to and , respectively. As claimed in [40], the CNN visual backbone and Transformer may favor different kinds of the optimizer, we adopt different optimizer settings for visual backbone and Transformer. Specifically, we use SGD with learning rate and weight decay to optimize the CNN backbone, and adopt AdamW with learning rate and weight decay

as Transformer optimizer. We pre-train Pixel-BERT on 64 NVIDIA Tesla V100 GPUs with the batch size 4096 samples for 40 epochs. We decay the learning rate by 10 at

and epoch.

4.2 Downstream Tasks

We evaluate our model on several downstream vision and language tasks, including Visual Question Answering (VQA) and Natural Language for Visual Reasoning for Real (NLVR on VQA 2.0 [12], NLVR [30]

datasets, respectively. We also conduct experiments on image-to-text and text-to-image retrieval tasks on Flickr30K

[38] and MS-COCO [20] dataset. The detailed statistics including dataset splits, numbers of training/validation/testing data and evaluation metrics in all used datasets can be found in Table 1. We report the performance of Pixel-BERT under two different visual backbone setting in later tables, where r50 indicates ResNet-50 and x152 indicates ResNeXt-152. Since our model adopts 12-Layer Transformer as a language module, we mainly compare our experiments with other approaches under the same Transformer setting.

Model test-dev test-std
MUTAN[5] 60.17 -
BUTD[2] 65.32 65.67
ViLBERT[21] 70.55 70.92
VisualBERT[19] 70.80 71.00
VLBERT[29] 71.79 72.22
LXMERT[33] 72.42 72.54
UNITER[6] 72.27 72.46
Pixel-BERT (r50) 71.35 71.42
Pixel-BERT (x152) 74.45 74.55
Table 2: Evaluation of Pixel-BERT with other methods on VQA.
Model dev test-P
Image Only[30] 51.6 51.9
CNN+RNN[30] 53.5 52.4
MaxEnt[30] 54.1 54.8
VisualBERT[19] 67.4 67.0
LXMERT[33] 74.9 74.5
UNITER[6] 75.4 76.0
UNITER[6] 77.1 77.9
Pixel-BERT (r50) 71.7 72.4
Pixel-BERT (x152) 76.5 77.2
Table 3: Evaluation on NLVR task. indicates use paired method. indicates use pair-biatt method.

4.2.1 Visual Question Answering

In Visual Question and Answering (VQA) task, Pixel-BERT takes an image and a question as input and predicts an answer as output. We model it as a classification problem by learning multi-layer perception from the [CLS] token via binary cross-entropy loss. We follow the same optimizer setting as pre-training. We fine-tune the model for 18 epochs on 16 NVIDIA Tesla V100 GPUs with batch size 256. The initial learning rates are the same as pre-training, and we decay the learning rate by 10 at and epoch.

We report our experiment results on VQA task in Table 3. We compare our approach with recent state-of-the-art approaches. From Table 3, we can find that our approach with ResNet-50 as visual backbone achieves 71.35 score on test-dev split, which already outperforms ViLBERT [21] and VisualBERT [19] which using more powerful visual backbone like ResNet-101 or ResNeXt-152. When equipped with ResNeXt-152 backbone, our model Pixel-BERT achieves 74.45 on test-dev split and 74.55 on test-std split, which significantly outperforms all existing works. It worth noting that this result is even higher than the performance of UNITER (Large), which using 24-Layer Transformer as a language module and get score on VQA test-std split. This obvious improvement demonstrates that learning visual and language attention in image’s pixel-level can benefit the visual encoder representation and enhance the visual and language embedding learning afterward.

4.2.2 Natural Language for Visual Reasoning for Real

Natural Language for Visual Reasoning for Real (NLVR) task requires a model to predict whether a language description is related to a given pair of images. In our model, we feed two image-language pairs into Pixel-BERT to get two embedding vectors from the [CLS] tokens, and use their concatenation to learn a classifier over “true” or “false” by cross-entropy loss. The optimizer, epoch number and learning rate settings are all the same as VQA settings explained above. And the batch size is the half of the VQA.

We evaluate NLVR on both dev and test-P split. Different from pre-training tasks and other downstream tasks, NLVR receives a pair of images at once. From the results shown in Table 3, we can find that Pixel-BERT obtains 76.5 accuracy on dev split and 77.2 accuracy on test-P split. Our setting of composing two image-language pairs is the same as LXMERT and the “Pair” setting in UNITER, and from the comparison in Table 3 we can find that Pixel-BERT outperforms them. These results show that Pixel-BERT can be also adapted to other similar input formats.

Model TR IR
R@1 R@5 R@10 R@1 R@5 R@10
VSE++[10] 52.9 80.5 87.2 39.6 70.1 79.5
SCAN[17] 67.4 90.3 95.8 48.6 77.7 85.2
SCG[26] 71.8 90.8 94.8 49.3 76.4 85.6
PFAN[36] 70.0 91.8 95.0 50.4 78.7 86.1
ViLBERT[21] - - - 58.2 84.9 91.5
Unicoder-VL[18] 86.2 96.3 99.0 71.5 90.9 94.9
UNITER[6] 84.7 97.1 99.0 71.5 91.2 95.2
ours (R50) 75.7 94.7 97.1 59.8 85.5 91.6
ours (X152) 87.0 98.9 99.5 71.5 92.1 95.8
Table 4: Evaluation of Pixel-BERT with other methods for image-to-text retrieval (TR) and text-to-image retrieval (IR) on Flickr30K dataset.
Model TR IR
R@1 R@5 R@10 R@1 R@5 R@10
1K Test set
VSE++[10] 64.6 90.0 95.7 52.0 84.3 92.0
SCAN[17] 72.7 94.8 98.4 58.8 88.4 94.8
SCG[26] 76.6 96.3 99.2 61.4 88.9 95.1
PFAN[36] 76.5 96.3 99.0 61.6 89.6 95.2
Unicoder-VL[18] 84.3 97.3 99.3 69.7 93.5 97.2
ours (R50) 77.8 95.4 98.2 64.1 91.0 96.2
ours (X152) 84.9 97.7 99.3 71.6 93.7 97.4
5K Test set
VSE++[10] 41.3 71.1 81.2 30.3 59.4 72.4
SCAN[17] 50.4 82.2 90.0 38.6 69.3 80.4
SCG[26] 56.6 84.5 92.0 39.2 68.0 81.3
Unicoder-VL[18] 62.3 87.1 92.8 46.7 76.0 85.3
UNITER[6] 63.3 87.0 93.1 48.4 76.7 85.9
Pixel-BERT (r50) 53.4 80.4 88.5 41.1 69.7 80.5
Pixel-BERT (x152) 63.6 87.5 93.6 50.1 77.6 86.2
Table 5: Evaluation of Pixel-BERT with other methods for image-to-text retrieval (TR) and text-to-image retrieval (IR) on MS-COCO Dataset.

4.2.3 Image-Text Retrieval

We consider the retrieval task as a ranking problem similar to other works [6, 18, 29]. During training, for each image in an image-sentence pair, we use the ground-truth caption in the pair as the positive sample and randomly sample 20 unrelated captions from other pairs to make negative samples. We predict the score of whether a pair is related by a fully-connected layer on the representation of all [CLS] tokens, and apply softmax cross-entropy loss to encourage that the positive image-caption pair to obtain the highest score. We only backward the gradient on 5 negative samples with the highest loss for each image sample. Since the retrieval task is closely related to ITM task in pre-training, we only fine-tune the parameters in Transformer. We adopt AdamW with learning rate and weight decay as optimizer. We fine-tune the model on 8 NVIDIA Tesla GPUs with a batch size of 64 samples per GPU. For Flickr30K, we train 10 epochs and decay the learning rate at epoch. For MS-COCO we train 4 epochs and decay the learning rate at epoch.

We report recall@1, 5, 10 on both text-to-image retrieval (IR) and image-to-text retrieval (TR) sub-tasks to evaluate our approach. Table 4 shows the 1K testing results on Flickr30K, and Tabel 5 shows the 5-fold 1K testing results and 5K testing results on MS-COCO. We mainly compare Pixel-BERT with Unicoder-VL and UNITER which both adopt 12-layers Transformer as a language module. For image-to-text retrieval subtask, we obtain at least 0.6 performance gain on MS-COCO 1K test set, and 0.3 on MS-COCO 5K test set for recall@1. And for the text-to-image retrieval subtask, we achieve more significant results with improvements of at lease 1.9 on MS-COCO 1K testing set and 1.7 on MS-COCO 5K testing set compared with Unicoder-VL and UNITER. This is due to that the text-to-image retrieval task focuses more on the global description of an image, and our architecture can encourage the model to learn attention across language and image pixels.

# Visual Pre-traning Sampling VQA TR IR NLVR
Backbone Tasks Method test-dev val val dev
1 ResNet-50 - Random 63.50 52.4 39.6 52.0
2 ResNet-50 ITM Random 65.24 69.0 55.5 51.9
3 ResNet-50 MLM Random 71.13 67.1 52.7 70.9
4 ResNet-50 MLM+ITM ALL 70.84 72.0 57.7 71.3
5 ResNet-50 MLM+ITM Random 71.35 75.7 59.8 71.7
6 ResNext-152 MLM+ITM Random 74.45 87.0 71.5 76.5
Table 6: Ablation study results on VQA, retrieval and NLVR downstream tasks. We evaluate the effectiveness of pre-training tasks and our proposed sampling method. The first row indicates training downstream tasks without pre-training. We report VQA score for VQA task, Recall@1 for TR and IR, and accuracy for NLVR.

4.3 Ablation Study

We conduct ablation experiments to evaluate the effectiveness of each component of our Pixel-BERT. Since the performance of the pre-training model can not be well measured by a single metric, we use the evaluated results on downstream tasks for evaluation. The ablation study results can be found in Table 6. We first evaluate the effectiveness of each pre-training tasks. From the comparison of model (1) and model (2) (3), we can find that both MLM and ITM can significantly improve the performance on almost all downstream tasks. Specifically, for VQA, MLM and ITM can bring about and improvement. For the retrieval task, ITM contributes more and brings at least improvement on both TR and IR sub-tasks. NLVR relies heavily on MLM task, without which the training even can not converge. The effectiveness of pre-training is consistent with the conclusions drawn in other works [6, 29]. And their combination in model (5) can further improve the performance of each task than single task. From the comparison of model (4) and model (5), we can find that our proposed randomly pixel sampling method can contribute score on VQA, about score on retrieval tasks and score on NLVR. This demonstrates the effectiveness of our pixel random sampling mechanism. In model (6), we follow [27, 29] to replace the visual backbone with ResNext-152, and the results show that our model with a powerful visual backbone will further accelerate the performance by a large margin.

Figure 3: Visualization of attention regions extracted from the first Transformer layer of Pixel-BERT. The attention regions are extracted by using the specific token as query and pixel features as keys. Highlight areas indicate regions with high attention score.

4.4 Visualization

To further check whether our approach Pixel-BERT can well learn the visual representation by cross-modality attention across language and pixels, we visualize some intermediate results of attention maps on examples from MS-COCO val set. The visualization results can be found in Fig. 3. From the result of Case (A), we can see that the response areas of token “dog”, “grass” and “frisbee” are actually distributed on the correct region. For Case (B), we can find that although “cutting” is a verb, it can attend to the most related region in which the action of “cutting” is performed with a knife. From Case (C), we find that the token “room” can attend to the correct region in the image, which is difficult to be represented by a bounding box. Although we did not apply any spatial supervision (e.g., bounding box annotations) to guide the attention learning, the results from Fig. 3 show that with well-defined tasks, our Pixel-BERT can well learn the visual representation in region level with cross-modality learning. This result also brings a lot of possibilities for further researches to study whether cross-modality learning can help the semantic understanding of visual information conversely.

5 Conclusion and Discussion

Pre-training mechanism has shown its effectiveness in vision and language domain. In this paper, we discuss the visual embedding method that is commonly used in existing works and aim to solve the limitation of region-based visual representation. We propose CNN-based Visual Encoder and combine it with multi-modal Transformers to construct Pixel-BERT in an end-to-end manner and build more accurate and more thorough embedding between visual and linguistic contents in pixel and text level. We use pixels of an image as input and apply a random pixel sampling mechanism for the robustness of visual embedding learning. We build a pre-training model based on Pixel-BERT to learn a universal visual and language embedding on Visual Genome dataset and MS-COCO dataset. Masked language model and image-text matching are two tasks designed for pre-training. We conduct downstream vision and language tasks with our pre-trained model and achieve the best performances in most tasks, including VQA, NLVR, image-to-text retrieval and text-to-image retrieval.

Without the restriction of annotated bounding boxes, our pre-trained model with Pixel-BERT can provide much stronger representation for both images and sentences with a larger image-sentence pair dataset. We will consider to pre-train our model on Conceptual Caption Dataset [25] to further optimize the visual and language embedding. Masked visual prediction is proposed in some works. For example, [6] proposed three types of masked region modeling for the prediction of the masked region. In this paper, we use a random pixel sampling mechanism to replace this part due to the difficulty of pixel reconstruction compared with regions. In the future, we will research on how to design and combine self-supervised tasks for visual contents in our current approach.


  • [1] Alberti, C., Ling, J., Collins, M., Reitter, D.: Fusion of detected objects in text for visual question answering. In: EMNLP. pp. 2131–2140 (2019)
  • [2] Anderson, P., He, X., Buehler, C., Teney, D., Johnson, M., Gould, S., Zhang, L.: Bottom-up and top-down attention for image captioning and visual question answering. In: CVPR (June 2018)
  • [3] Antol, S., Agrawal, A., Lu, J., Mitchell, M., Batra, D., Lawrence Zitnick, C., Parikh, D.: Vqa: Visual question answering. In: ICCV (December 2015)
  • [4] Ba, J.L., Kiros, J.R., Hinton, G.E.: Layer normalization. arXiv (2016)
  • [5] Ben-Younes, H., Cadene, R., Cord, M., Thome, N.: Mutan: Multimodal tucker fusion for visual question answering. In: ICCV. pp. 2612–2620 (2017)
  • [6] Chen, Y.C., Li, L., Yu, L., Kholy, A.E., Ahmed, F., Gan, Z., Cheng, Y., Liu, J.: Uniter: Learning universal image-text representations. arXiv0 (2019)
  • [7] Conneau, A., Lample, G.: Cross-lingual language model pretraining. In: NIPS. pp. 7057–7067 (2019)
  • [8] Deng, J., Dong, W., Socher, R., Li, L.J., Li, K., Fei-Fei, L.: Imagenet: A large-scale hierarchical image database. In: CVPR. pp. 248–255. Ieee (2009)
  • [9] Devlin, J., Chang, M.W., Lee, K., Toutanova, K.: Bert: Pre-training of deep bidirectional transformers for language understanding. In: ACL. pp. 4171–4186 (2019)
  • [10] Faghri, F., Fleet, D.J., Kiros, J.R., Fidler, S.: Vse++: Improving visual-semantic embeddings with hard negatives. In: BMVC (2017)
  • [11] Goyal, Y., Khot, T., Summers-Stay, D., Batra, D., Parikh, D.: Making the V in VQA matter: Elevating the role of image understanding in Visual Question Answering. In: CVPR (2017)
  • [12] Goyal, Y., Khot, T., Summers-Stay, D., Batra, D., Parikh, D.: Making the v in vqa matter: Elevating the role of image understanding in visual question answering. In: CVPR. pp. 6904–6913 (2017)
  • [13] He, K., Zhang, X., Ren, S., Sun, J.: Deep residual learning for image recognition. In: CVPR. pp. 770–778 (2016)
  • [14] Karpathy, A., Fei-Fei, L.: Deep visual-semantic alignments for generating image descriptions. In: CVPR. pp. 3128–3137 (2015)
  • [15] Kim, J.H., Jun, J., Zhang, B.T.: Bilinear attention networks. In: NIPS. pp. 1564–1574 (2018)
  • [16] Krishna, R., Zhu, Y., Groth, O., Johnson, J., Hata, K., Kravitz, J., Chen, S., Kalantidis, Y., Li, L.J., Shamma, D.A., et al.: Visual genome: Connecting language and vision using crowdsourced dense image annotations. IJCV 123(1), 32–73 (2017)
  • [17] Lee, K.H., Chen, X., Hua, G., Hu, H., He, X.: Stacked cross attention for image-text matching. In: ECCV. pp. 201–216 (2018)
  • [18] Li, G., Duan, N., Fang, Y., Jiang, D., Zhou, M.: Unicoder-vl: A universal encoder for vision and language by cross-modal pre-training. In: AAAI (2019)
  • [19] Li, L.H., Yatskar, M., Yin, D., Hsieh, C.J., Chang, K.W.: Visualbert: A simple and performant baseline for vision and language. arXiv (2019)
  • [20] Lin, T.Y., Maire, M., Belongie, S., Hays, J., Perona, P., Ramanan, D., Dollár, P., Zitnick, C.L.: Microsoft coco: Common objects in context. In: ECCV. pp. 740–755. Springer (2014)
  • [21] Lu, J., Batra, D., Parikh, D., Lee, S.: Vilbert: Pretraining task-agnostic visiolinguistic representations for vision-and-language tasks. In: NIPS. pp. 13–23 (2019)
  • [22] Qi, D., Su, L., Song, J., Cui, E., Bharti, T., Sacheti, A.: Imagebert: Cross-modal pre-training with large-scale weak-supervised image-text data. arXiv (2020)
  • [23] Radford, A., Narasimhan, K., Salimans, T., Sutskever, I.: Improving language understanding by generative pre-training. URL https://s3-us-west-2. amazonaws. com/openai-assets/researchcovers/languageunsupervised/language understanding paper. pdf (2018)
  • [24] Ren, S., He, K., Girshick, R., Sun, J.: Faster r-cnn: Towards real-time object detection with region proposal networks. In: NIPS. pp. 91–99 (2015)
  • [25] Sharma, P., Ding, N., Goodman, S., Soricut, R.: Conceptual captions: A cleaned, hypernymed, image alt-text dataset for automatic image captioning. In: ACL. pp. 2556–2565 (2018)
  • [26] Shi, B., Ji, L., Lu, P., Niu, Z., Duan, N.: Knowledge aware semantic concept expansion for image-text matching. In: IJCAI. pp. 5182–5189 (2019)
  • [27] Singh, A., Goswami, V., Natarajan, V., Jiang, Y., Chen, X., Shah, M., Rohrbach, M., Batra, D., Parikh, D.: Pythia-a platform for vision & language research. In: SysML Workshop, NeurIPS. vol. 2018 (2018)
  • [28] Srivastava, N., Hinton, G., Krizhevsky, A., Sutskever, I., Salakhutdinov, R.: Dropout: a simple way to prevent neural networks from overfitting. JMLR 15(1), 1929–1958 (2014)
  • [29] Su, W., Zhu, X., Cao, Y., Li, B., Lu, L., Wei, F., Dai, J.: Vl-bert: Pre-training of generic visual-linguistic representations (2019)
  • [30] Suhr, A., Zhou, S., Zhang, A., Zhang, I., Bai, H., Artzi, Y.: A corpus for reasoning about natural language grounded in photographs. In: ACL. pp. 6418–6428 (2019)
  • [31] Sun, C., Myers, A., Vondrick, C., Murphy, K., Schmid, C.: Videobert: A joint model for video and language representation learning. In: ICCV. pp. 7464–7473 (2019)
  • [32] Szegedy, C., Liu, W., Jia, Y., Sermanet, P., Reed, S., Anguelov, D., Erhan, D., Vanhoucke, V., Rabinovich, A.: Going deeper with convolutions. In: CVPR. pp. 1–9 (2015)
  • [33] Tan, H., Bansal, M.: Lxmert: Learning cross-modality encoder representations from transformers. In: ACL (2019)
  • [34] Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A.N., Kaiser, Ł., Polosukhin, I.: Attention is all you need. In: NIPS. pp. 5998–6008 (2017)
  • [35] Vinyals, O., Toshev, A., Bengio, S., Erhan, D.: Show and tell: A neural image caption generator. In: CVPR (June 2015)
  • [36] Wang, Y., Yang, H., Qian, X., Ma, L., Lu, J., Li, B., Fan, X.: Position focused attention network for image-text matching. In: IJCAI (2019)
  • [37]

    Wu, Y., Schuster, M., Chen, Z., Le, Q.V., Norouzi, M., Macherey, W., Krikun, M., Cao, Y., Gao, Q., Macherey, K., et al.: Google’s neural machine translation system: Bridging the gap between human and machine translation. arXiv (2016)

  • [38] Xie, S., Girshick, R., Dollár, P., Tu, Z., He, K.: Aggregated residual transformations for deep neural networks. In: CVPR. pp. 1492–1500 (2017)
  • [39] Xu, K., Ba, J., Kiros, R., Cho, K., Courville, A., Salakhudinov, R., Zemel, R., Bengio, Y.: Show, attend and tell: Neural image caption generation with visual attention. In: ICML. pp. 2048–2057 (2015)
  • [40] Zhang, J., Karimireddy, S.P., Veit, A., Kim, S., Reddi, S.J., Kumar, S., Sra, S.: Why adam beats sgd for attention models. arXiv (2019)
  • [41] Zhou, L., Palangi, H., Zhang, L., Hu, H., Corso, J.J., Gao, J.: Unified vision-language pre-training for image captioning and vqa. In: ICLR (2018)