---
title: "TransVG: End-to-End Visual Grounding with Transformers (2021)"
description: "TransVG uses transformers to match a referring expression to an image and predict its bounding box directly, without selecting a candidate box."
canonical: "https://research.elamur.ai/free/en/papers/deng-2021-transvg-end-end-visual-grounding/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Constitution](https://md.constitution.elamur.ai/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/deng-2021-transvg-end-end-visual-grounding/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2021](https://md.research.elamur.ai/free/en/papers/2021/) / TransVG: End-to-End Visual Grounding with Transformers

# TransVG: End-to-End Visual Grounding with Transformers

Paper · 2021 · Jiajun Deng, Zhengyuan Yang, Tianlang Chen et al.

**Authors:** Jiajun Deng, [Zhengyuan Yang](https://md.research.elamur.ai/free/en/authors/zhengyuan-yang/), Tianlang Chen, [Wengang Zhou](https://md.research.elamur.ai/free/en/authors/wengang-zhou/) and [Houqiang Li](https://md.research.elamur.ai/free/en/authors/houqiang-li/) · **Year:** 2021 · **Venue:** IEEE/CVF International Conference on Computer Vision (ICCV) · **Licence:** [CC BY 4.0 (arXiv)](https://creativecommons.org/licenses/by/4.0/)

[**372** citations OpenAlex, 2026-10-14](https://openalex.org/works?filter=cites:W3156978626) · [IEEE/CVF International Conference on Computer Vision (ICCV)](https://openalex.org/S4363607764) · [licence](https://creativecommons.org/licenses/by/4.0/)

- [PDF](https://arxiv.org/pdf/2104.08541)
- [DOI 10.1109/iccv48922.2021.00179](https://doi.org/10.1109/iccv48922.2021.00179)
- [arXiv 2104.08541](https://arxiv.org/abs/2104.08541)
- [OpenAlex](https://openalex.org/W3156978626)

Citations: OpenAlex, 2026-10-14.

## Summary

A description can identify an object through its surroundings. To find an orange between other fruit, a system has to locate the possible oranges and use the arrangement of nearby objects to decide which one the description means. This is the problem of visual grounding. The inputs are an image and a referring expression, and the answer is a rectangle around the region the expression identifies. TransVG studies how to make that decision using a common mechanism for processing the image, the words, and their relationships, an approach to [vision and language](https://md.research.elamur.ai/free/en/topics/multimodal/).

Earlier systems typically chose a region from proposals supplied by a detector or made a prediction relative to pre-defined boxes distributed across the image. Some also assigned distinct components of a description, such as a subject or a location, to separate parts of the architecture. TransVG gives the image and the expression their own processing branches, then combines their outputs in a single sequence. The elements of that sequence exchange information through attention, which lets each element draw on other elements with weights that depend on the input. A learned token joins the sequence and provides the representation from which the system predicts the box coordinates. The same kind of encoder carries out the exchanges within and across the two inputs, using the [transformer](https://md.research.elamur.ai/free/en/concepts/transformer/).

With a ResNet-101 image backbone, TransVG reaches 70.73% top-1 accuracy on the ReferItGame test set, 79.10% on the Flickr30K Entities test set, and 78.35% on RefCOCO testB in the original comparison. A prediction counts as correct when its overlap with the annotated box, measured relative to their union, is above 0.5. The results are less uniform on RefCOCO+. The paper also reports scores obtained with the released code on the RefCOCO benchmarks, and some differ from the original figures.

The controlled comparisons help locate the sources of the improvement. The dedicated learned token works better on RefCOCO validation than substituting a pooled image representation, a pooled language representation, or the language branch’s existing summary token. On ReferItGame, accuracy is highest when both branches can add context to their own inputs before the joint encoder combines them. The broader comparison establishes that a shared attention mechanism and direct box prediction can work well together across several grounding benchmarks. The experiments leave open how much of the gain comes from direct regression on its own.

## Deep dive: TransVG: End-to-End Visual Grounding with Transformers

TransVG uses transformers to match a referring expression to an image and predict its bounding box directly, without selecting a candidate box. · about 35 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### A region depends on the words and the scene

Visual grounding begins with a particular image and language that identifies something in it. The system has to recover the location the speaker meant. A category word may provide much of the answer in one scene. In another, several objects fit the category, and a word describing position or a relation becomes decisive. The same category word can therefore point to different places even within a single image. The output has to reflect the description as a whole and the scene in which it is used.

The orange example makes the distinction concrete. An image recognizer could recognize the fruit and still give equal support to several places. A useful grounding system has to represent the candidate fruit along with the other objects that help identify the target. It ultimately has to return the extent of the orange itself. The neighboring objects provide evidence for that decision, while the expected bounding box describes the referred orange. This division between the evidence and the region to be returned is one reason the task calls for more than finding a visual counterpart for each noun.

The paper treats referring expression comprehension and phrase localization as forms of this task. The expressions can come from different annotation settings. Some identify objects through distinct descriptions supplied for a scene. Others are short phrases with an annotated correspondence to a region. A shared architecture has to accommodate both kinds of input even when they make different demands on how language and visual context are combined. The earlier studies cited by the authors include work on the generation and comprehension of unambiguous object descriptions and on [modeling context in referring expressions](https://md.research.elamur.ai/free/en/papers/yu-2016-modeling-context-referring-expressions/).

#### How earlier systems narrowed down the location

In the two-stage approach described by the paper, the first stage proposes regions using the image. An unsupervised proposal procedure or a pretrained detector can supply those regions. The second stage compares representations of them to the language expression and chooses the best match. For training that comparison, some earlier work used binary classification to distinguish matching pairs from other pairs. Other work used a ranking objective that tried to give the correct pairing a sufficiently higher score than alternatives.

This arrangement makes localization partly a question about the quality of the regions available for comparison. If a useful region has already been proposed, the matching stage can devote itself to deciding whether the description fits it. If the proposed regions poorly cover the referent, even a good understanding of the phrase may leave the matching stage with poor options. Refinement can adjust a selected box, but the starting region still matters. The authors identify proposal generation and the rules used to associate annotations with candidates as sources of dependence on decisions made before the final grounding prediction.

Similarity Net illustrates a relatively simple matching stage. It compares a region representation with an expression representation through a small neural network. Subsequent two-stage methods developed more elaborate ways to use the clues in the description. MAttNet separated evidence about the subject, location, and relationships. Other approaches used graphs to represent relations between objects or assembled parts of the computation into a tree. The paper also describes work that learned stronger correspondences or exploited the fact that phrases can occur together. Each line of work gave the second stage more information with which to distinguish plausible regions.

The one-stage approach moves language into the detector’s computation. Image features retain their arrangement over a spatial grid, and the expression can influence predictions throughout that grid. In the typical pipeline described by the authors, pre-defined boxes called anchors serve as reference shapes at different locations. The system scores the resulting predictions and returns the box associated with the strongest score. This avoids preparing a separate set of regions and extracting features from each of them before comparing them to the text. It still builds the final decision around regions associated with preset reference boxes.

FAOA is the paper’s example of a straightforward way to incorporate language into this pipeline. It represents the expression as a vector and joins that vector to visual features in YOLOv3. ReSC addresses the problem of long or complicated descriptions by constructing subqueries recursively and using them to condition the visual features over successive steps. RCCF takes a different route through correlation filtering. It finds a peak in a map of image–language correspondence and treats that peak as the target’s center. These examples show that the one-stage category covers several ways of turning image and text into a location.

#### Why change both fusion and prediction?

The authors identify two choices that recur in this history. The first is how the architecture determines which visual and linguistic cues can interact. A module dedicated to a location phrase may be effective when the expected kind of phrase is present. A graph may help when the relationships it represents capture the relevant distinction. For the authors, the cost of committing to a particular structure is that the system can become adapted to the descriptions and scenes for which that structure works best. A differently phrased relationship or a different amount of detail can change which exchanges would be useful.

The second choice concerns what the predictor is trained to produce. A candidate-based system frequently has intermediate goals such as identifying the positive candidate, scoring alternatives, or refining a promising box. Those are reasonable ways to reach the final location. They also require choices about the candidate geometry and how to assign training targets to it. The authors ask whether grounding can be trained more directly from the annotated rectangle, with the geometry predicted from a joint representation of the image and expression.

These questions are related but distinct. A system could combine the modalities through attention and still choose among proposals. It could also use some other mechanism to combine them and then predict coordinates. TransVG changes both parts of the pipeline. Its experiments evaluate the resulting system as a whole and examine several of its components separately. Keeping the two design choices in view matters when interpreting what the comparisons establish.

#### The precedents for using attention

TransVG draws its basic operation from a transformer originally introduced for machine translation. Attention lets the representation of an item depend on other items in the sequence. Each item contributes according to a weight computed from the current input. For language, this makes it possible to connect words that are separated in a sentence. For a sequence made from an image feature map, it allows information to travel between positions that are far apart on the map. In either case the operation can process the sequence in parallel. The underlying design comes from [Attention Is All You Need](https://md.research.elamur.ai/free/en/papers/vaswani-2017-attention-all-need/).

The paper also places its work alongside applications of transformers in vision. It describes ViT as evidence that a transformer can work well for image classification. It gives particular attention to DETR, which uses learned object queries to predict a set of detections and uses attention to incorporate scene context and relationships among objects. That provides a precedent for asking a learned representation to drive spatial predictions. TransVG’s task supplies a description of a particular referent, so its prediction is conditioned on that description. Its image branch also takes its starting weights from [DETR](https://md.research.elamur.ai/free/en/papers/carion-2020-end-end-object-detection-transformers/).

A second neighboring line of work used transformers to pretrain joint vision–language representations. The paper describes systems such as UNITER and ViLBERT as learning from inputs that include object proposals and text. Their training can ask whether an image and text match, align words with regions, or recover masked parts of the inputs. The objective is to acquire representations that transfer to downstream tasks. TransVG uses pretrained weights in its individual branches while training the joint grounding architecture on examples with annotated locations. Its immediate objective is the rectangle corresponding to a particular expression. The distinction is between the task addressed by the joint training and the use of earlier training to supply a starting point for the branches. [UNITER](https://md.research.elamur.ai/free/en/papers/chen-2019-uniter-universal-image-text-representation/) · [ViLBERT](https://md.research.elamur.ai/free/en/papers/lu-2019-vilbert-pretraining-task-agnostic-visiolinguistic/)

### The method, step by step

#### From the two inputs to a rectangle

TransVG first constructs a sequence from the visual input and another from the language input. The image branch turns a grid of visual features into a sequence whose elements correspond to positions in that grid. The language branch looks up vectors for the expression’s tokens and enriches those vectors using the surrounding tokens. Each branch has its own encoder before the inputs meet. This gives the visual elements a chance to gather information about the rest of the scene and the language elements a chance to represent how words work together in the expression.

The two branches produce vectors of different widths. Separate learned projections give them a common width so that the fusion encoder can process them together. TransVG adds a learned regression token, [REG], to the combined sequence. At the start of fusion, it is the same learned vector for every example. Its representation changes as the encoder processes the image and text. At the end, a small prediction network reads that representation and outputs the box.

Consider again the orange described through its relationship to other fruit. Before fusion, the image features can carry information about objects across the scene, and the language features can represent the target noun together with its modifiers. During fusion, an image position can draw on the relevant language tokens, other image positions, or both. The regression token can gather information from these updated representations. The box is read from its final state. This describes the routes that information can take. The architecture leaves the choice of which routes to use to the learned attention weights.

How TransVG turns an image and expression into a box The steps in order.

#### What the encoder does to a sequence

The attention operation uses queries, keys, and values. A query represents the position seeking information. A key provides a way to judge how much another position can contribute. A value is the information to be combined once the weights have been determined. In the paper’s compact notation, the calculation for an attention head is as follows.

```
Attn(fᑫ, fᵏ, fᵛ) = softmax((fᑫ fᵏ) / √dₖ) · fᵛ
```

`Attn` denotes the attention output. The superscripts `q`, `k`, and `v` on `f` identify the query, key, and value embeddings in this formula. The product `fᑫ fᵏ` stands for the dot products between queries and keys, arranged to compare a query with the available key positions. `dₖ` is the channel dimension of a key, and division by its square root scales the dot products. The `softmax` operation turns the scaled scores into weights over the keys for each query. The dot preceding `fᵛ` applies those weights to the corresponding values, giving a weighted combination.

The term self-attention describes where these inputs originate. The queries, keys, and values all come from the same sequence of representations. In the visual encoder that sequence consists of image tokens. In the linguistic encoder it consists of language tokens. In the fusion encoder it contains both, together with [REG]. A head in the fusion encoder can therefore use a word to update a visual position or use one visual position to update another. Multi-head attention carries out the operation through several sets of learned projections, giving the layer several ways to distribute its attention.

A transformer encoder layer uses this exchange first, then processes the result with a feed-forward network. The residual connection around attention adds its update to the state that entered the layer. The sum goes through layer normalization, which adjusts the scale and offset of the features. The paper writes the first part of the layer in the following form. [Layer normalization](https://md.research.elamur.ai/free/en/papers/ba-2016-layer-normalization/)

```
x′ₙ = LN(xₙ + Fₘₛₐ(xₙ))
```

`xₙ` is the sequence entering the encoder layer indexed by `n`, and `x′ₙ` is the intermediate sequence after the attention sublayer. `Fₘₛₐ` denotes multi-head self-attention. The plus sign adds its output to the incoming sequence. `LN` denotes layer normalization applied to that sum. The prime marks the intermediate state within the layer.

```
xₙ₊₁ = LN(x′ₙ + Fꜰꜰɴ(x′ₙ))
```

`xₙ₊₁` is the output passed on from layer `n` to the following layer. `x′ₙ` is the intermediate sequence just defined, and `Fꜰꜰɴ` is the feed-forward network. It uses fully connected operations and ReLU activations to transform the features. A ReLU keeps positive inputs and clips negative inputs to zero. The plus sign again marks the residual addition, and `LN` again normalizes the result.

The two sublayers consequently do different jobs. Attention gathers information across positions. The feed-forward sublayer transforms each resulting representation. Repeating the layer means that later exchanges can work with representations already changed by earlier exchanges. For grounding, this permits a visual position to carry information acquired from the text into a later interaction with the regression token. It also permits the regression token to draw on both streams directly. The formulas give the information paths available in an encoder layer. Which paths prove important for a particular expression is an empirical question.

#### Constructing the visual sequence

The visual branch starts with a color image. A convolutional backbone produces a grid of feature vectors, with nearby positions corresponding to nearby parts of the image. The paper uses ResNet and compares ResNet-50 with ResNet-101. The convolutional stage matters for interpreting the architecture. The visual transformer receives a spatial map of already computed features. Those features give it an input organized by image position and enriched by the preceding convolutional processing. [ResNet](https://md.research.elamur.ai/free/en/papers/he-2015-deep-residual-learning-image-recognition/)

```
z₀ ∈ ℝ³×ᴴ⁰×ᵂ⁰
```

`z₀` denotes the input image. `ℝ` denotes real-valued entries, and the superscript describes the shape. `3` is the number of color channels. `H₀` and `W₀`, represented in the superscript as `ᴴ⁰` and `ᵂ⁰`, are the height and width of the image entering the backbone. The multiplication signs separate axes of the array.

```
z ∈ ℝ^(C × H × W)
```

`z` is the backbone’s output map. `C` is its channel count, while `H` and `W` are its spatial height and width. The paper gives 2048 as the typical value of `C`. The parentheses after `ℝ^` specify the axes of a real-valued tensor.

```
H = H₀ / 32
```

`H` is the feature map’s height, `H₀` is the input image height, and `32` is the backbone’s reduction factor along that axis. The division describes the spatial scale of the feature grid relative to the input.

```
W = W₀ / 32
```

`W` is the feature map’s width, `W₀` is the input image width, and `32` again gives the reduction factor. The paper uses the same factor along both spatial axes.

A convolution with a 1 × 1 kernel then changes the channel count to 256. At each position it transforms the vector of channels while preserving the map’s spatial dimensions. The resulting grid is flattened so each position contributes one vector to the transformer. Flattening changes the layout of the array. The visual branch supplies position information separately so attention can still distinguish where the vectors came from.

```
Nᵥ = H × W
```

`Nᵥ` is the number of visual tokens. `H` and `W` count the positions on the grid along the two axes. Their product counts the grid positions represented in the sequence.

```
zᵥ ∈ ℝ^(Cᵥ × Nᵥ)
```

`zᵥ` denotes the flattened sequence. `Cᵥ` is the projected channel dimension, which is 256, and `Nᵥ` counts the tokens. The subscript `v` distinguishes quantities for the visual branch. The layout writes tokens as columns in a real-valued array.

The visual encoder has 6 layers and uses 8 attention heads per layer. Its feed-forward network has 2 fully connected layers, with output widths of 2048 and 256. The intermediate expansion operates on the features at each sequence position, and the return to width 256 makes the result compatible with the residual update. The encoder adds sine-based spatial encodings to the queries and keys at each layer. These encodings carry information about each token’s original place in the grid, so position can influence the attention weights.

The visual encoder returns contextual tokens, denoted by `fᵥ` in the paper. They have the same shape as the flattened input `zᵥ`. Each output token still corresponds to a grid position, but information from distant positions can now contribute to it. This is a useful distinction for relational descriptions. A token at an object’s location can carry some evidence about its surroundings before the text is introduced. Image features with a known place and broader scene context are what pass to the fusion stage.

#### Constructing the language sequence

The language branch follows the basic BERT architecture. The expression is represented using vocabulary identifiers, and an embedding lookup turns each identifier into a feature vector. The paper describes the identifier at lookup as a one-hot vector, meaning that its active entry selects the corresponding learned embedding. A special token called [CLS] occupies the beginning of the sequence, and [SEP] marks its end. These tokens are part of the linguistic input. The separate [REG] token used to produce the grounding output enters later. [BERT](https://md.research.elamur.ai/free/en/papers/devlin-2019-bert-pre-training-deep-bidirectional/)

The linguistic transformer uses 12 encoder layers. Its output channels have width 768. Attention allows the representation at each token to take account of the rest of the expression. For a relational phrase, the target term and the words locating or distinguishing it can therefore influence each other before fusion. The design passes the contextual sequence to the next stage. This preserves individual token positions and lets joint attention use whichever parts of the expression help with a particular visual decision.

```
fₗ ∈ ℝ^(Cₗ × Nₗ)
```

`fₗ` denotes the output embeddings of the linguistic branch. `Cₗ` is their width, 768, and `Nₗ` is the number of positions in the linguistic sequence. The subscript `l` identifies language quantities. The real-valued array contains one embedding column for each position, with padding handled by a mask in attention.

Keeping the sequence intact is an architectural choice with implications for fusion. The joint encoder can attend differently to different language positions, using the target term in one interaction and a modifying term in another. The representations arriving at those positions already carry the effects of linguistic context. Fusion can work on those contextual representations while retaining the ability to assign different weights to them.

#### Combining both sequences and learning where to read out

A linear projection for each modality maps the branch’s output into a common space. The paper calls the resulting sequences `pᵥ` and `pₗ`, with the shared channel width denoted by `Cₚ` and set to 256. The visual features already have width 256. Their learned projection can still change the representation that the joint encoder receives. The language projection maps its wider vectors into the common width. The two projections give the fusion encoder a compatible vector shape for all its inputs.

```
x₀ = [pᵣ, pᵥ¹, …, pᵥᴺᵥ, pₗ¹, …, pₗᴺₗ]
```

`x₀` is the sequence entering the joint encoder. `pᵣ` is the trainable vector for [REG]. The entries `pᵥ¹` through `pᵥᴺᵥ` are the projected visual tokens indexed from the first position to the `Nᵥ`th position. The entries `pₗ¹` through `pₗᴺₗ` are the projected linguistic tokens through the `Nₗ`th position. The superscripts label sequence positions. The brackets and commas indicate that the vectors are joined in sequence, and each ellipsis stands for the intervening positions. Every listed entry has the common width `Cₚ`.

```
x₀ ∈ ℝ^(Cₚ × (Nᵥ + Nₗ + 1))
```

`x₀` again denotes the joint sequence, and `Cₚ` is its channel width. `Nᵥ` and `Nₗ` give the lengths contributed by the visual and linguistic branches. The `1` accounts for the dedicated regression token. The additions give the total number of positions in the real-valued array.

The joint transformer has 6 encoder layers. It uses learned positional encodings at each layer to keep information about the positions and modalities of its inputs available. Attention operates on the combined sequence. A language position can use evidence from another language position, revisit its interpretation using visual evidence, or participate in both kinds of interaction. An image position can similarly use information from the phrase or from the scene. The paper calls this a homogeneous way to perform reasoning because the same encoder operation supports all these exchanges.

The starting vector for [REG] is randomly initialized and learned during training. At fusion time, its input value is shared across examples. Its output depends on the tokens supplied alongside it and on how they interact in the encoder. This separates the stable role of [REG] as the readout position from the specific information it comes to hold for each image and description. In effect, the loss trains the system to put the information needed for a spatial decision into that final state.

A feed-forward prediction head reads only that final state. It has two hidden layers of width 256 with ReLU activations and a linear output layer. The output consists of 4 coordinates, which describe the box by its center and dimensions. The head therefore makes a continuous geometric prediction from the information gathered by [REG]. A grid cell in the image branch provides a feature at a particular location. It does not serve as a box that the output must select.

#### What the training loss asks the system to predict

The supervision is the bounding box associated with the expression. Directly comparing the output with that box gives a training signal for the head, the regression token, the fusion layers, and both input branches. The procedure avoids a separate step for assigning a positive anchor or proposal to each example. It still needs a loss that measures box error in a way that reflects both coordinate accuracy and the relationship between the two rectangles.

```
b = (x, y, w, h)
```

`b` is the predicted box. Its center is at horizontal coordinate `x` and vertical coordinate `y`. Its width is `w`, and its height is `h`. The parentheses group these quantities as an ordered vector, with each position carrying a different part of the rectangle’s geometry.

```
b̂ = (x̂, ŷ, ŵ, ĥ)
```

`b̂` is the annotated box after its coordinates are normalized by the image scale. The hats distinguish the target values from their predicted counterparts. `x̂` and `ŷ` give the target center, and `ŵ` and `ĥ` give its width and height in the normalized coordinate system.

```
L = Lₛₘₒₒₜₕ₋ₗ₁(b, b̂) + λ · Lɢɪᴏᴜ(b, b̂)
```

`L` is the total training loss. `Lₛₘₒₒₜₕ₋ₗ₁` is the smooth L1 loss applied to the predicted coordinates `b` and target coordinates `b̂`. `Lɢɪᴏᴜ` is the generalized intersection-over-union loss evaluated on the same pair of boxes. `λ` controls the weight of the geometric loss, and the centered dot denotes multiplication. The plus sign combines the coordinate and geometric terms. The authors set `λ` to 1.

The authors motivate the geometric term by comparing errors on large and small rectangles. A coordinate loss can assign different penalties to errors that are proportionally similar when the underlying objects differ in size. Normalizing the target coordinates by the image scale gives the system a common coordinate convention. Generalized intersection over union supplies a complementary signal based on how the rectangles relate geometrically. Together, the two terms reward coordinate agreement and a box that covers the right region. [Generalized intersection over union](https://md.research.elamur.ai/free/en/papers/rezatofighi-2019-generalized-intersection-over-union-metric/)

#### Preparing examples and optimizing the architecture

The image input is prepared at 640 × 640. The longer side is resized to 640, maintaining the aspect ratio, and the shorter side is padded to 640 with the mean values of the RGB channels. This makes examples fit a common input shape without stretching their contents to fill the square. A mask records which parts are padding so the transformer can exclude them from attention.

The language input has a maximum length of 40 positions. The expression is cut off if its length exceeds 38, leaving places for [CLS] and [SEP]. Shorter inputs are padded after [SEP] until the sequence reaches 40. A mask marks those padded positions. For both inputs, the fixed size makes it possible to form a common batch, and the masks tell the attention layers which entries represent actual input. Truncation has a different effect from padding because it removes language that would otherwise be available for the grounding decision.

The complete architecture is optimized with AdamW. The joint vision–language encoder and prediction head start at a learning rate of 10⁻⁴. The visual and linguistic branches start at 10⁻⁵, and the weight decay is 10⁻⁴. The visual branch starts with the backbone and encoder weights of DETR. The language branch starts with basic BERT weights. The remaining learned components are initialized using Xavier initialization. This arrangement gives the new fusion and prediction components a larger initial learning rate while adapting the pretrained branches through joint [fine-tuning](https://md.research.elamur.ai/free/en/concepts/fine-tuning/).

The batch size is 64. The paper applies dropout after the attention and feed-forward sublayers, using a default ratio of 0.1, and follows earlier grounding work in using data augmentation during training. For every dataset except Flickr30K Entities, the authors train for 90 epochs and reduce the learning rate to one-tenth of its previous value after epoch 60. For Flickr30K Entities, training runs for 60 epochs with a learning-rate drop after 40 epochs.

At inference, the result comes directly from the prediction head. The paper describes no additional operation to sort, match, or refine candidate boxes. That property follows from the form of the prediction. The input pair already specifies which referent is being sought, and the architecture is trained to produce the coordinates for that pair. The authors release their implementation and include reproduced scores from it in the paper, which gives readers a separate set of comparison figures for the RefCOCO benchmarks.

### Experiments and results

#### What the benchmarks ask the system to locate

ReferItGame has 20,000 images drawn from SAIAPR-12. Its regions are paired with referring expressions. In the split used here, 54,127 expressions belong to training, 5,842 to validation, and 60,103 to testing. The expression counts matter because a prediction is made for an image and an expression together. Several grounding examples can therefore come from the same image. The authors use the validation set for experimental analysis and the test set for comparison with published methods. [ReferItGame](https://md.research.elamur.ai/free/en/papers/kazemzadeh-2014-referitgame-referring-objects-photographs-natural/)

Flickr30K Entities associates short phrases with annotated regions in Flickr30K images. The paper describes a collection of 31,783 images and 427K referred entities. Measured in images, the split assigns 29,783 to training and 1,000 each to validation and testing. It gives the architecture a setting in which the units of language are phrases associated with entities. Good performance there complements the evidence from datasets that the paper discusses in connection with longer referring expressions.

RefCOCO contains 19,994 images, 50,000 referred objects, and 142,210 expressions. The paper uses the official split with 120,624 training expressions and 10,834 validation expressions. The test partitions are testA with 5,657 expressions and testB with 5,095 expressions. The authors report the partitions separately, so a score on testB describes that particular evaluation set. This distinction matters for the widely cited 78.35% figure, which is a testB result.

RefCOCO+ contains 19,992 images, 49,856 referred objects, and 141,564 expressions. Its official split gives 120,191 expressions for training, 10,758 for validation, 5,726 for testA, and 4,889 for testB. RefCOCOg contains 25,799 images, and the paper reports 49,856 referred objects and expressions. RefCOCOg has two split protocols in the comparison. The Google protocol contributes the validation result labeled val-g. The UMD protocol supplies the validation and test results referred to as val-u and test-u. Keeping those labels is important when comparing TransVG to earlier work because the reported scores refer to different partitions.

#### How a prediction earns credit

The paper measures top-1 accuracy. The architecture returns a single rectangle for the expression, and the evaluation computes the Jaccard overlap between that rectangle and the annotated box. This quantity is also known as intersection over union. The numerator is the area shared by the two rectangles. The denominator is all the area covered by either of them. A predicted box can therefore lose overlap by missing part of the target or by extending too far beyond it. The prediction is counted as correct if the overlap is above 0.5.

The resulting accuracy is the proportion of evaluated expressions for which the predicted rectangle meets the threshold. It puts direct regression, proposal selection, and anchor-based predictions on a common scale. Each method supplies a final rectangle, and the criterion depends on its overlap with the annotation. The metric can tell whether a prediction met that convention. A score by itself gives less information about the geometry of the errors, since successful matches of differing precision receive equal credit.

The comparison tables organize earlier approaches by pipeline and identify their visual backbones. That distinction helps the reader interpret differences in scores. Comparing two backbones within TransVG shows what happens to the measured accuracy when the visual variant changes. Comparing whole systems with one backbone name in common removes one obvious difference, while leaving choices such as initialization, language processing, fusion, and training objective in play. The rankings are best read as comparisons of complete systems under the reported [evaluation benchmarks](https://md.research.elamur.ai/free/en/topics/evaluation-benchmarks/).

#### ReferItGame and Flickr30K Entities

On ReferItGame, the comparison includes DDPN among the two-stage approaches and ReSC-Large among the one-stage approaches. The former reaches 63.00% test accuracy, and the latter reaches 64.60%. TransVG reaches 69.76% with ResNet-50 and 70.73% with ResNet-101. The paper reports the stronger TransVG variant’s advantage as 6.13% in absolute accuracy over ReSC-Large and 7.73% over DDPN. These are differences on the ReferItGame test set.

System comparison on ReferItGame test top-1 accuracy Both TransVG variants score above the strongest earlier entries shown.

**The numbers**

| System or setting | top-1 accuracy % |
| --- | --- |
| ZSGNet with ResNet-50 | 58.63 |
| DDPN with ResNet-101 | 63.00 |
| RCCF with DLA-34 | 63.79 |
| ReSC-Large with DarkNet-53 | 64.60 |
| TransVG with ResNet-50 | 69.76 |
| TransVG with ResNet-101 (this paper) | 70.73 |

ZSGNet and the smaller TransVG variant both list ResNet-50. ZSGNet reaches 58.63% top-1 accuracy on the ReferItGame test set, and the paper reports an absolute advantage of 11.13% for TransVG in that comparison. This result is informative because the gain is visible without moving to ResNet-101. It still compares two complete pipelines. The backbone held in common gives a closer point of comparison and leaves the remaining architectural and training differences combined.

The authors also compare TransVG conceptually with ReSC. Both carry out repeated operations to improve the representation used for grounding. In ReSC, recurrence constructs subqueries, which are then used to modulate visual features. In TransVG, the repeated operation jointly updates the visual and linguistic sequence, along with [REG]. The accuracy comparison is consistent with the authors’ case for repeated joint updates. It measures the performance of the two systems instead of the isolated effect of where those updates occur.

The top TransVG result on the Flickr30K Entities test set is 79.10% with ResNet-101. DDPN, the strongest earlier entry listed for this dataset, reaches 73.30%. The paper gives 5.80% as the absolute improvement over the previous record in that comparison. With ResNet-50, TransVG reaches 78.47%, so the advantage also appears with the smaller of the two backbones tested. The result extends the evidence for the design to short region-linked phrases, which differ from the longer descriptions discussed in the RefCOCOg experiments.

System comparison on Flickr30K Entities test top-1 accuracy Both TransVG variants lead the reported comparison on region-linked phrases.

**The numbers**

| System or setting | top-1 accuracy % |
| --- | --- |
| Similarity Net with ResNet-101 | 60.89 |
| FAOA with DarkNet-53 | 68.71 |
| ReSC-Large with DarkNet-53 | 69.28 |
| PIRC with ResNet-101 | 72.83 |
| DDPN with ResNet-101 | 73.30 |
| TransVG with ResNet-50 | 78.47 |
| TransVG with ResNet-101 (this paper) | 79.10 |

The order of the earlier systems differs between these benchmarks. ReSC-Large is the closest listed competitor on ReferItGame, whereas DDPN is the closest on Flickr30K Entities. This is one reason to read the results separately by dataset. TransVG leads both comparisons under the same overlap criterion, even though the next strongest pipeline and the kinds of expressions differ.

#### RefCOCO, RefCOCO+, and RefCOCOg

On RefCOCO, the original ResNet-101 row reports 81.02% for validation, 82.72% for testA, and 78.35% for testB. The corresponding original ResNet-50 figures are 80.32%, 82.67%, and 78.12%. The paper highlights testB, where ReSC-Large reaches 72.30%, the strongest prior result in the comparison. The authors state an absolute improvement of 6.05% for the original ResNet-101 result over that benchmark entry.

The released-code comparison changes the picture of which TransVG run is strongest on an individual split. For RefCOCO with ResNet-101, the reproduced scores are 80.83% on validation, 83.38% on testA, and 76.94% on testB. The original row is higher on testB, while the released row is higher on testA. The smaller backbone shows the same direction of change for those two test partitions. With ResNet-50, the released scores are 83.28% on testA and 75.24% on testB. The authors direct subsequent comparisons towards the released-code figures. The original 78.35% on testB remains the result from the original run.

RefCOCO+ is the clearest qualification to a story of uniform improvements. The original ResNet-101 result of 64.82% on validation is below MAttNet’s 65.33% and NMTree’s 66.46%. On testA, original TransVG reaches 70.70%, with NMTree at 72.02%. On testB, the original numbers are 56.94% for TransVG and 57.52% for NMTree. The comparison thus supports the paper’s description of performance close to leading systems in its original runs. Those rows give no basis for treating every benchmark as a win over the strongest earlier entry.

The released ResNet-101 row is stronger on RefCOCO+ than the original ResNet-101 row. The released results are 68.00% on validation, 72.46% on testA, and 59.24% on testB. These values belong to the reproduced run. Reporting the two rows separately helps account for why the narrative describes RefCOCO+ as competitive while the released figures in the table are more favorable to TransVG.

RefCOCOg provides the paper’s main benchmark evidence concerning longer expressions. The original ResNet-101 row gives 67.02% on val-g, 68.67% on val-u, and 67.73% on test-u. Among the earlier comparisons, NMTree records 64.62% on val-g and 65.87% on val-u, while MAttNet records 67.27% on test-u. The released TransVG row with ResNet-101 gives 68.03%, 68.71%, and 67.98% on the same splits, respectively. Within the table, both sets of TransVG figures support the claim that joint attention works in a benchmark characterized by longer descriptions. This is a comparison over the partitions as a whole. It gives no direct breakdown by expression length or type of relation.

The contrast with MAttNet is especially visible across datasets. MAttNet is close to TransVG on some RefCOCO-family splits but scores 29.04% on ReferItGame test. The authors interpret this variation as consistent with the idea that an explicit decomposition into subject, location, and relation can fit some kinds of data better than others. Because the systems differ in several respects, this comparison supports the practical case for evaluating across benchmarks. A causal explanation for the variation would require holding more of the pipeline fixed.

### What the ablations show

#### A readout trained for grounding works best among the tested choices

The ablation experiments use ResNet-50 and train the variants for 90 epochs. The first experiment changes how the readout representation is supplied to the fusion encoder. The question is whether [REG] needs to be a dedicated learned vector or whether a summary taken from one of the input branches gives the joint encoder an equally good starting point.

For the pooling variants, the image or language sequence supplies a single vector. Average pooling combines the features across positions by averaging each channel. Max pooling retains the highest response for each channel. In either case, the resulting vector enters fusion in the readout role. It starts with information from the current expression or image, depending on which stream produced it. The dedicated [REG] has a shared starting value and acquires example-specific information through joint attention.

Using [CLS] is a different intervention. That token already has a place in the linguistic sequence and an output in the joint encoder. In the sharing variant, the head reads its final state to make the prediction. This tests whether the existing language token can serve the task’s readout function as well as a token introduced specifically for grounding.

Readout choice on RefCOCO validation top-1 accuracy A dedicated learned token gives the highest accuracy among the tested readouts.

**The numbers**

| System or setting | top-1 accuracy % |
| --- | --- |
| Average-pooled visual tokens | 79.12 |
| Max-pooled visual tokens | 78.37 |
| Average-pooled linguistic tokens | 78.51 |
| Max-pooled linguistic tokens | 78.74 |
| Shared CLS token | 77.90 |
| Dedicated learned REG token (this paper) | 80.32 |

On RefCOCO validation, the learned embedding gives 80.32% top-1 accuracy. Average pooling of visual tokens is the strongest alternative at 79.12%, and sharing [CLS] gives 77.90%. Among the language pools, max pooling gives 78.74% and average pooling gives 78.51%. The ordering of average and max therefore depends on which input supplies the starting representation. The broader finding is that the dedicated learned embedding does better than starting from any of the tested summaries.

The authors suggest that pooled tokens can bring a bias towards the modality from which they are derived. A learned [REG] gives the encoder more freedom to assemble the information it needs. In this experiment, that explanation is consistent with the dedicated token’s lead over both image-derived and language-derived alternatives. The experiment measures different ways of constructing the readout, however. It does not separately measure modality bias or identify a particular attention pattern that causes the accuracy gain. The [CLS] comparison also changes which position the head reads, so it addresses whether the existing token is a good substitute for the dedicated one.

#### Context within each branch helps before fusion

A second ablation asks what the separate visual and linguistic transformers contribute. The baseline keeps the image and language inputs and the joint grounding machinery, with the branch transformers removed. It therefore still has a fusion stage capable of attention over both inputs. Its accuracy on the ReferItGame test set is 64.24%.

With the visual transformer alone restored, ReferItGame test accuracy is 68.48%. With the linguistic transformer alone restored, it is 66.78%. The complete architecture reaches 69.76%. Both single-branch variants improve on the common baseline, and the highest score comes when both branch encoders are present. The larger numerical change in this setting accompanies the visual transformer. That ordering refers to this ablation on ReferItGame with the paper’s ResNet-50 setup.

The visual branch has a plausible job to do even before the expression is introduced. An image feature can incorporate context from other positions that may eventually help distinguish the referent. The language branch similarly gives a word access to the rest of the description. The fusion encoder then receives features that already represent some of these within-input dependencies. The results show that giving the branches this opportunity improves the tested architecture over asking the joint encoder to handle the same task from less contextualized inputs.

The experiment removes whole transformers. In the full design, those stages bring pretrained weights as well as additional layers and a route for information to travel within an input. Their removal consequently changes several properties at once. The result establishes the practical value of retaining the tested components. It does not quantify the separate contributions of transformer depth, transferred weights, and the order in which within-input and joint processing occur.

#### Attention maps suggest a progression across layers

The paper shows qualitative examples from the RefCOCOg test set by placing maps of [REG] attention alongside predicted and annotated rectangles. For the example involving an orange and nearby fruit, the output corresponds to a referent identified through its arrangement in the scene. This illustrates that the framework can use a phrase whose useful evidence extends beyond the target object. The display also lets the reader compare the area receiving visual attention with the area covered by the predicted box.

A further visualization follows [REG] through layers 2, 4, and 6 of the joint encoder. The authors describe relatively broad attention at layer 2, spreading across multiple image regions. At layer 4, the displayed maps emphasize regions that can help discriminate the referent. In one scene, a bus behind a man draws attention as context connected with the road. At layer 6, the map is more concentrated on the referred object, and its visible emphasis more closely follows the target’s shape and location.

This progression fits the architecture’s division of labor. Earlier layers can maintain access to a broad set of clues, while the final state has to support a particular rectangle. The maps supply examples of where the regression token places weight as it moves through that computation. Since the final state also depends on the values that are combined, the residual updates, and earlier exchanges among other tokens, the displayed weights are one view of the process. The paper offers them as qualitative evidence about the behavior of the joint encoder and its [interpretability](https://md.research.elamur.ai/free/en/topics/interpretability/).

The visualizations and the ablations answer different questions. The readout experiment compares alternatives for transferring joint information to the head. The branch experiment compares alternative sources of context entering the joint encoder. The maps show what the trained system attends to in selected cases. Together, they clarify why the overall architecture is plausible and which tested components help, while leaving the contribution of the direct box objective to be assessed separately.

### Limitations

#### Limits and qualifications the authors identify

The authors discuss a failure case on RefCOCO+ where a referring expression consists of the numeral 32. Such an expression offers little internal linguistic context from which the branch can infer a relation or distinguish among uses of a word. The paper uses the example to explain why an expressive linguistic encoder may contribute less to some inputs than to richly worded descriptions. It documents a particular sort of difficult input. The discussion gives no prevalence estimate for these cases and does not attribute the entire RefCOCO+ result to them.

The authors also identify a training issue with coordinate error. A loss defined in terms of coordinate deviations can treat comparable proportional errors differently across box sizes. Their design responds with image-scale normalization and a generalized overlap term. The rationale and the remedy are part of the method. The reported ablations address the readout and branch encoders, so the results do not give a controlled estimate of how the loss components affect grounding at different object sizes.

The input specification places a clear bound on how much language can enter the system. The expression is truncated beyond 38 positions before adding its boundary tokens. Strong performance on RefCOCOg is evidence for processing the longer expressions encountered under this setup. If identifying information lies beyond the retained part of an expression, it is unavailable to the encoder. The paper supplies no separate accuracy figure for truncated examples.

The reproduced comparisons are another qualification visible in the paper itself. The released runs can yield higher or lower accuracy depending on the split, including the drop on RefCOCO testB relative to the original result. Both sets of figures show strong results against the comparison methods, but the exact values depend on which reported run is being discussed. The authors’ instruction to favor the released figures for later comparisons makes that distinction consequential.

#### What follows from the experimental design

The evidence for replacing elaborate fusion modules comes primarily from comparisons between complete systems. TransVG changes the way features are prepared, how they interact, and how the output is predicted. Both input branches also start from pretrained weights. The branch and readout ablations measure particular changes within TransVG. There is no controlled comparison that uses the same inputs, weights, and joint encoder while switching the final task between candidate selection and direct coordinate regression. The benchmarks therefore show that the combined design works well, with the credit due to each change still open.

Similarly, the paper motivates flexible attention as a way to avoid depending on a fixed analysis of expressions or scenes. The favorable comparison on several datasets supports the practical value of the design. The experiments train and evaluate using the benchmark protocols described for each dataset. They do not directly measure how an architecture trained on one benchmark handles the language or scene distribution of another. The comparison with MAttNet across benchmarks cannot by itself establish that its hand-designed decomposition causes the variation in its scores.

Top-1 accuracy above the documented overlap threshold is a clear test of whether the output hits the intended region. It leaves questions about tighter localization unresolved. Two successful predictions can fit the target to noticeably different degrees and still contribute equally to accuracy. A missed threshold can likewise arise from a slightly misplaced box or from a region belonging to the wrong object. The headline comparisons measure success under the standard criterion, and the visual examples supply a few cases in which the geometry can be inspected more closely.

The attention figures have a related limitation. They can show that the readout assigns weight to areas a reader recognizes as relevant. They cannot establish that an attended area is necessary for the decision. In the road scene, for example, the bus receives emphasis at an intermediate layer, consistent with the authors’ interpretation of it as context. The same figure cannot show how the prediction would change if that cue were absent. The observed progression is a description of those examples, and the benchmark accuracy does not measure how often that progression occurs.

Finally, direct prediction simplifies the output procedure, a useful architectural fact. Its computational cost still includes convolutional feature extraction and transformer processing in the branches and in the joint encoder. The paper’s main tables document accuracy. They give no comparative latency or resource measurements from which to conclude that the complete system is faster or cheaper than the earlier pipelines. The data also present the task as localization of the region associated with an expression, with a single rectangle as the answer. Behavior for expressions with several acceptable referents, or with no matching referent, remains outside those reported results.

### What came after

The two later works that cite TransVG attend to different parts of the grounding problem. One places grounding in the service of open-set object detection. The other stays with referring expression comprehension and emphasizes the use of knowledge. The citations establish a connection in subject matter and chronology. The stated scope of each work supports a comparison of the problems they address. The citation alone leaves the transfer of particular TransVG components unspecified.

#### Grounding as a basis for open-set detection

Grounding DINO connects DINO with grounded pretraining for open-set object detection. In TransVG, the expression supplies the clues needed to locate a particular referent in the image. The later work places grounded training in the context of a detector whose task is framed around an open set. The shared idea at this level is that associations between linguistic information and visual regions can help make spatial predictions. The shift is in how those associations are used. TransVG evaluates a rectangle for a supplied referring expression. Grounding DINO’s stated project is to bring grounded pretraining into an open-set detection system. [Grounding DINO](https://md.research.elamur.ai/free/en/papers/liu-2023-grounding-dino-marrying-dino-grounded/)

#### Knowledge in referring expression comprehension

The Segment-Level and Category-Oriented Network takes up knowledge-based referring expression comprehension. Its stated design is organized around segments and categories, bringing those concerns into the same general task that TransVG approaches through joint attention. TransVG explicitly allows the image and expression tokens to exchange information without assigning the description to prescribed reasoning modules. The later work’s focus identifies a different question within referring expression comprehension, concerning how knowledge can inform a design oriented around segments and categories. Its relation to TransVG can be stated at the level of that shared grounding problem. The available account leaves the details of architectural reuse open. [Segment-Level and Category-Oriented Network](https://md.research.elamur.ai/free/en/papers/bu-2023-segment-level-category-oriented-network/)

## Cite

Cite as Jiajun Deng, Zhengyuan Yang, Tianlang Chen, Wengang Zhou and Houqiang Li. 2021. TransVG: End-to-End Visual Grounding with Transformers. IEEE/CVF International Conference on Computer Vision (ICCV).

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.1109/iccv48922.2021.00179](https://doi.org/10.1109/iccv48922.2021.00179) · [arXiv 2104.08541](https://arxiv.org/abs/2104.08541)

```bibtex
@inproceedings{deng2021transvg,
  title = {{TransVG: End-to-End Visual Grounding with Transformers}},
  author = {Jiajun Deng, Zhengyuan Yang, Tianlang Chen, Wengang Zhou and Houqiang Li},
  booktitle = {IEEE/CVF International Conference on Computer Vision (ICCV)},
  year = {2021},
  doi = {10.1109/iccv48922.2021.00179},
  eprint = {2104.08541},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.1109/iccv48922.2021.00179}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
