Obj2Seq: Formatting Objects as Sequences with Class Prompt for Visual Tasks
Abstract
Visual tasks vary a lot in their output formats and concerned contents, therefore it is hard to process them with an identical structure.
One main obstacle lies in the high-dimensional outputs in object-level visual tasks.
In this paper, we propose an object-centric vision framework, Obj2Seq.
Obj2Seq takes objects as basic units, and regards most object-level visual tasks as sequence generation problems of objects.
Therefore, these visual tasks can be decoupled into two steps.
First recognize objects of given categories, and then generate a sequence for each of these objects.
The definition of the output sequences varies for different tasks, and the model is supervised by matching these sequences with ground-truth targets.
Obj2Seq is able to flexibly determine input categories to satisfy customized requirements, and be easily extended to different visual tasks.
When experimenting on MS COCO, Obj2Seq achieves 45.7% AP on object detection, 89.0% AP on multi-label classification and 65.0% AP on human pose estimation.
These results demonstrate its potential to be generally applied to different visual tasks.
Code has been made available at: https://github.com/CASIA-IVA-Lab/Obj2Seq .
[Equation]
Class: Baseball Bat; Task: Object Detection 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 =0.9, 𝑥𝑥 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 =22, 𝑦𝑦 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 =57,… 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 =0.8, 𝑥𝑥 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 =62, 𝑦𝑦 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 =91,…
Class: Person; Task:
Pose Estimation 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 =0.6, 𝑥𝑥 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 =19, 𝑦𝑦 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 =45,…
Class: Trunk; Task: Classification
No Trunks!
Obj2Seq
Person
Trunk Baseball Bat
Introduction
Deep learning has made great progress in the field of computer vision [24, 44, 23, 31], and recently researchers are seeking for a unified framework for various visual tasks.
This idea has been widely discussed in Natural Language Processing (NLP), which results in the emergence of general language models.
In NLP, all tasks are formatted as sequence-to-sequence problems in order to be processed by a single transformer [54].
Meanwhile, prompt learning [20] is utilized so that the general model is compelled to perform a specific task.
With the help of large-scale text data, numerous pre-trained language models are developed [16, 1, 60], and they achieve excellent performance on a wide range of language tasks.
With these encouraging achievements in NLP, it is natural to ask whether we can implement a similar framework in computer vision as well.
One of the two obstacles to realize this is that visual tasks are defined in various formats.
They can hardly be unified like sequence-to-sequence problems in
NLP, especially those object-level tasks with high-dimensional outputs.
The other is that the model may encounter diverse categories even for an identical task.
If the model is not aware of what it will process in advance, we cannot expect it to satisfy customized requirements flexibly.
There are some works taking a step forward to solve these problems.
M-DETR [27] takes sentences as inputs in addition to the images, so that it is able to flexibly detect specific targets that mentioned and realize target-aware inference.
However, M-DETR is designed for object detection only, and hard to extend for general usage.
Pix2Seq [9] is a forward looking work to unify the formats of different tasks.
It turns object detection into a sequence generation task, and directly applies next token generation to yield bounding boxes and categories.
Even so, Pix2Seq is not aware of the desired targets before inference, and the output sequence might become extremely long under sophisticated scenes.
In this paper, we propose a unified visual framework, Obj2Seq, in order to adapt the sequence generation framework for object-level visual tasks.
Obj2Seq formats these tasks into a two-step process.
First, with images and class prompts as inputs, Obj2Seq determines whether each given category exists or not in an image, and detects objects of these categories.
Then a sequence is generated as the output for each object in response to the desired task.
Many visual tasks can be filled in this template by changing class prompts and the definition of output sequences.
For each specific task, class prompts provide additional instructions to impel the framework to attend to objects of specified categories, and the output sequences are defined accordingly to include information required by the task.
This gives the credit to two new modules, Prompted Visual Indicator that receives class prompts from the inputs, and General Sequence Predictor that outputs sequences in a unified format for each object.
Obj2Seq has two main advantages.
On one hand, the behavior of Obj2Seq can be controlled and manipulated.
By taking different class prompts as inputs, Obj2Seq is able to focus on different objects and flexibly satisfy specific requirements under practical scenes.
On the other hand, the sequences generated by Obj2Seq are of a unified format to describe objects, which makes it ready to be extended for a wide range of object-level visual tasks.
In order to validate the versatility of our framework, we conduct experiments on MS COCO [34] for some common visual tasks.
Obj2Seq achieves 45.7% AP on object detection and 89.0% AP on multi-label classification when trained for object detection, while it also achieves 65.0% AP on human pose estimation with keypoint annotations.
These results indicate that our framework is effective for different visual tasks, and has potential for general usage.
Related Works 2.1 General Frameworks for Visual Tasks
The idea of pretraining a general model is firstly proposed in NLP [16, 1].
Currently, a similar trend appears in computer vision as well.
Researchers first borrow transformer as the base model [17, 53, 37, 56, 12], and then design novel self-supervised algorithms to pretrain them with the help of huge amounts of unlabeled data and modern hardware [10, 5, 30, 22, 8, 32].
The pretrained models are capable of extracting robust feature for downstream tasks.
However, since only the pretrained backbone is provided, downstream tasks still have to design their specific head structures and need further training to get desired results.
Recently, the academic raises a higher requirement to train a general framework that can be directly applied in different tasks.
It should be trained in an end-to-end way, and does not need finetuning for a specific task.
Multi Task Learning (MTL) is one related field [6, 48, 21].
It constructs a shared backbone and multiple heads to process a fixed combination of tasks.
However, since MTL needs individually designed heads and sufficient labels for every sample, it is expansive and unable to be extended to other tasks.
Recently, works like ML-Decoder [47] and X-DETR [2] attempt to construct a general framework for a set of some similar tasks.
However, they can hardly be generalized for tasks with totally different definitions.
Pix2Seq [9] provides a straight-forward solution to convert an image into a sequence of words.
However, it lacks interface to flexibly adopt for different scenes.
In addition, the whole image is sometimes too complex to be represented in a single sequence.
Different from previous work, we take objects as the basic unit in visual tasks, and unify them as sequence generation for each single object.
Additional class prompts are used to specify the objects in need.
2.2 Prompt Learning
Prompt learning [20] is firstly develop in NLP in order to directly apply pre-trained language models in different tasks.
It does not need finetuning model parameters, but rather modifies the inputs and uses a template to indicate the proposed task.
Therefore, the model handles all tasks in a unified manner.
In order to train vision models with easily available image-text pair data, the concept of prompt is firstly introduced to construct training targets with label text in computer vision [43, 59].
These algorithms help supervision with large-scale data only for a certain task.
The prompts are used as labels, and they cannot control the inference.
VPT [26] and FP-DETR [55] add prompt parameters in their framework.
These parameters are trained in the finetune stage for each task.
However, they do not make use of language embeddings, and the effect of these modules is hard to explain.
ML-Decoder [47] and MDETR [27] use text to impel the model to focus on specific categories or objects.
It allows us to interfere the model behavior, however, these frameworks are limited to a group of similar tasks.
In this paper, class prompts are used to give instructions about what categories to detect, and Obj2Seq is able to perform a wide range of vision tasks.
2.3 Sequence Prediction
Sequence prediction is a basic formulation for various NLP tasks, since the words in sentences are sequential naturally.
It has the characteristic that the forward process at time t depends on features or outputs from previous time steps.
Currently transformer [54] is widely utilized to solve these problems.
In order to generate a sequence, the output token at time t is taken as the input token of the next step.
Some up-to-date pre-train algorithm use the input sentence as the target output, in order to perform next-token prediction for unsupervised training [1, 60].
As to computer vision, there is no preset order in the input image.
Sequence prediction is only available in image generation since they can generate an output image pixel by pixel [41].
When transformer becomes popular, it is firstly applied to process a group of image patches [17] or an unordered set of objects [4].
Recently, the idea of next-token prediction is borrowed in order to develop novel self-supervised training algorithms [7, 25].
However, these algorithms are still closely related to image generation, as they predict the image patches in sequence.
Pix2Seq [9] is the first attempt to apply sequential prediction as a general method in a traditional visual task, and achieves a decent performance.
It regards the whole detection results as a single sequence, which abandons semantic structures in the original image.
On the contrary, our framework considers a more basic unit, objects, in the field of computer vision.
This makes Obj2Seq more suitable for visual tasks, and achieves better results.
Methods 3.1 Overview
Obj2Seq is a unified visual framework for object-level tasks.
It takes an image I ∈ R 3 × H 0 × W 0 and a group of K class prompts C =
[ c (1) ...
c ( K ) ]
∈ R K × d as inputs, and outputs a set of objects, each with a sequence to describe it.
It contains four main parts listed as below:
[Figure]
Fig 2 v
[Figure]
bipartite
[Figure]
Classifier
[Figure]
𝑥𝑥 𝑦𝑦 𝑎𝑎𝑛𝑛𝑎𝑎𝑎𝑎𝑛𝑛 𝑥𝑥 𝑦𝑦 𝑤𝑤 ℎ 𝑦𝑦 𝑤𝑤 ℎ 𝑥𝑥 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑦𝑦 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑥𝑥 𝑛𝑛𝑒𝑒𝑛𝑛 𝑥𝑥 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑦𝑦 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑥𝑥 𝑎𝑎𝑛𝑛𝑎𝑎𝑎𝑎𝑛𝑛
[Figure]
Pos Embs
Forward
Forward and Stop Gradient
Detection Results
KeypointResults
[Figure]
Self Attn
[Figure]
Cross Attn
[Figure]
Query 𝑥𝑥 𝑦𝑦 𝑎𝑎𝑛𝑛𝑎𝑎𝑎𝑎𝑛𝑛 𝑥𝑥 𝑦𝑦 𝑤𝑤 ℎ 𝑦𝑦 𝑤𝑤 ℎ 𝑥𝑥 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑦𝑦 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑥𝑥 𝑛𝑛𝑒𝑒𝑛𝑛 𝑥𝑥 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑦𝑦 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑥𝑥 𝑎𝑎𝑛𝑛𝑎𝑎𝑎𝑎𝑛𝑛2 Task Pos Embs
Forward
Forward and Stop Gradient
Detection Results
[Figure]
• Image Feature Encoder E to extract
• Prompted Visual Indicator I to receive class prompts from
initialize object queries
• Object Transformer Decoder D to encode object-related features into object queries.
• General Sequence Predictor P to generate a sequence of desired attributes for each object.
When the inputs I and C are provided, Obj2Seq first extracts image features F I with Image Feature
Encoder E .
Then, Prompted Visual Indicator I receives class prompts.
It judges the existence of each category for classification, and initializes class-aware object queries ˆ F O .
Each object query ˆ f o ∈ R 1 × d is responsible for detecting and describing one object of a specific class.
Afterwards, these object queries are sent into Object Transformer Decoder D .
The decoder extracts object-related features from F I according to ˆ F O , and transforms ˆ F O into well-encoded object queries F O .
These new queries contain sufficient information to describe their corresponding objects as the task requires.
Finally, General Sequence Predictor P generates a sequence for each object query, which contains the desired attributes and constitutes the final result.
The whole pipeline is shown in Figure 2a.
In the following sections, we mainly elaborate on Prompted Visual Indicator I and General Sequence
Predictor P , and then supply additional details in other parts of our implemention.
3.2 Prompted Visual Indicator
Different from processing with a complete category set, human beings usually know what categories to focus on in advance of each task.
This prior information makes their behavior more compact and accurate.
Also, the categories can be flexibly changed according to specific requirements.
Therefore, is it possible that we provide not only the images but also additional instructions as inputs, so that the model is forced to focus on objects of specified categories?
Prompted Visual Indicator borrows the idea of prompt learning from NLP [20].
It receives additional class prompts as inputs, therefore it can classify the input image with specific categories, and generate input-dependent object queries to focus on desired objects.
As shown in Figure 2b, each class prompt is a vector representing a certain category c ( k ) ∈ R d .
These input vectors are sent into prompt blocks with cross-attention modules that can extract class-related features from F I .
After processing by these blocks, the output vectors f ( k ) c represent features about specified categories in the input image.
These vectors can be classified by a class-related binary classifier as in Eq.
The classifier compares them with original class vectors, and outputs a score s ( k ) C to indicate the existence of each category.
Moreover, these features are utilized to generate class-aware object queries for further inference.
We retain K ′ categories that are more likely to exist with a certain retention policy, and perform Cartesian product with a set of N position embeddings to generate N object queries for each retained class.
Each object query ˆ f o is the sum of a class vector f ( k ) c and a position embedding.
These object queries are sent into Object Transformer Decoder for further process.
The retention policy is detailed in Section 3.4.
[Equation]
With the help of Prompted Visual Indicator, Obj2Seq can take not only images but also desired categories as inputs.
The model can flexibly classify and detect desired objects with given categories, and therefore is able to achieve better performance.
Moreover, each category is processed in an isolated way.
Obj2Seq is able to take any category subsets as the input, without any influence in results.
This makes our framework flexible and easy to implement in different scenes.
3.3 General Sequence Predictor
In the field of NLP, a task-agnostic language model usually converts all language tasks into a sequenceto-sequence format.
This is intuitive, because we always answer questions by speaking a sentence out.
As to visual tasks, we can also describe the input image with a sentence.
Since the image contains more sophisticated information, the sentence should be better organized with a more basic visual unit, objects.
In order to satisfy different requirements, we may need the bounding box, keypoint offsets or some other attributes in this sentence to describe an object.
Therefore, we construct General
Sequence Predictor, that generates a sequence of attributes to describe an object.
This paradigm can be generalized among a wide range of visual tasks.
General Sequence Predictor P takes object queries processed by Object Transformer Decoder as inputs, and outputs a sequence of attributes for each object.
We illustrate how it works in Figure 2c, taking object detection and human pose estimation as examples.
For simplicity, we only elaborate on the prediction process for one object query, and omit the superscript ( i ) .
The predictor P first takes the object query f
o as the input z in, 0 of the first time step.
The input is then sent into self- and cross-attention layers to get the output feature z out, 0 .
For any other time step t , P takes the previous output feature z out,t − 1 as the input z in,t , and the self-attention layers always take all previous inputs z in, 0: t to calculate keys and values.
After the output feature z out,t is obtained, a linear layer is utilized to convert it into a logit z t .
Finally, logits from all time steps are further interpreted into specific attributes in a non-parametric way, according to different tasks.
We formulate this process as in Eq.
[Equation]
General Sequence Predictor provides a unified way to generate output attributes for each object.
It can handle different object-level visual tasks with an identical structure, which makes Obj2Seq ready to be implemented for general usage.
3.4 Other Details
Image Feature Encoder Image Feature Encoder E consists of a resnet backbone and 6 multi-scale deformable encoder layers, which is exactly the same as [64].
The backbone extracts multi-scale feature maps { F ( l ) B } 4 l =1 from C 3 to C 5 and an additional downsampled scale C 6 .
These feature maps are transformed to have d = 256 channels, and then processed by deformable encoder layers to obtain
F I .
Object Transformer Decoder Object Transformer Decoder D consists of 4 multi-scale deformable decoder layers.
A decoder layer contains self-attention and multi-scale deformable attention modules, which is elaborated in [64].
Here we only implement 4 decoder layers for fair comparison in computation with other methods.
Retention policy Here we discuss about how Prompted Visual Indicator retains categories and generates class-aware object queries.
During training, categories with ground truth objects are first guaranteed to be retained.
Then we select categories with the highest scores to fullfill a fixed number of K ′ classes.
While in inference, we can retain either top- K ′ categories or all categories over a fixed threshold.
The influence of these policies is discussed in Section 4.4.3.
Objectness branch Besides describing an object with a sequence, we implement a separate objectness branch to recognize if the object exists.
This branch provides a score s ( i ) for each object as in Eq.
We first compute the probability of each object with given image and categories, and then multiply it with its corresponding class existence s ( k ) C .
In Section 4.4.2, we will elaborate on the efficacy of this objectness branch .
[Equation]
Training Criterion
The outputs of Obj2Seq is a set of objects with specified categories.
These objects are equivalent, and do not appear in a certain order.
Therefore, we use bipartite matching loss for supervision [4].
It matches object queries with ground truth so that the loss of matched pairs is minimized, and then optimizes this optimal match.
This loss makes sure that each object is only predicted with one object query, eliminating the need of non-maximum suppression.
The definition of the detailed loss function varies for tasks, which will be elaborated in Appendix.
As to the classifier in Prompted Visual Indicator, we regard it as an auxiliary multi-label classification problem, and supervise it with asymmetric loss [46].
Experiments
In this section, we first conduct experiments on three different visual tasks separately, including object detection, multi-label classification and human pose estimation.
These results demonstrate how
Obj2Seq solves visual tasks in a unified way.
After that, some ablation studies are provided to better comprehend the detailed options in Obj2Seq.
Here we only provide overall results.
Implementation details please refer to Appendix.
4.1 Experiments on Object Detection
In Table 1, we compare Obj2Seq with a group of popular detection frameworks on MS COCO [34].
We mainly compare it with different variations of DETR [4] here, because they are also end-to-end object detection frameworks without NMS, and Obj2Seq shares some similarity with Deformable
DETR [64].
All variations use multi-scale features or dilated convolution in stage 5 (DC5) for similar computation cost.
Meanwhile, we also present some representative convolution-based frameworks [44, 51] too, and they are trained with longer schedulers as reported in former papers.
Obj2Seq achieves 45.7% mAP with R50 as the backbone, without bells and whistles.
It is +1.2% higher than Deformable DETR using the same multi-scale deformable attention, and outperforms other detection frameworks as well, no matter DETR-like or convolution-based frameworks with a longer scheduler.
With R101 as the backbone, Obj2Seq also achieves 46.1%.
We notice that
[Table]
[Table]
[Table]
Obj2Seq
[Table]
DAB-DETR achieves significantly higher AP L than Obj2Seq.
This possibly attributes to its enhanced position embeddings, since reference points with learnable wh may better fit objects with extreme scales.
In general, these results indicates that Obj2Seq is an effective framework for object detection.
It achieves excellent performance.
4.2 Experiments on Multi-Label Classfication
Prompted Visual Indicator does not only generate object queries for Object Transformer Decoder, but also classify if the input categories exist in the image, and output scores for them.
Therefore, we are able to perform multi-label classification as well with the outputs from Prompted Visual Indicator.
We evaluate the model trained in Section 4.1 on MS COCO multi-label benchmark.
The classifier in
Prompted Visual Indicator achieves 89.0 mAP, which is comparable to most multi-label classification solutions.
We will elaborate on its detailed behavior in Appendix.
4.3 Experiments on Human Pose Estimation
Current human pose estimation algorithms are generally divided into three categories, bottom-up methods, top-down methods with image crop, and top-down methods in an end-to-end way.
All of them involves sophisticate structures, such as image crop [58, 61, 11] or RoI Align [29, 23] for top-down methods and group post-processing for bottom-up methods [42, 3].
There are few works directly obtaining keypoints from the input image [49].
In Obj2Seq, General Sequence Predictor can directly read the coordinates out from object queries without any task-specific model structures.
We also provide a baseline for better comparision.
The only difference between the baseline and
Obj2Seq is that the baseline model use a simple MLP instead of General Sequence Predictor.
The details in hyperparameters and training configurations are elaborated in Appendix.
Our experiments are conducted on the COCO keypoint challange [34], and we mainly list other end-to-end top-down methods in Table 2 for comparison.
Obj2Seq achieves 60.1% mAP with a 50-epoch training scheduler.
It reaches a reasonable performance as an end-to-end framework with no delicate structures.
The result with General Sequence Predictor is +2.9% higher than the MLP-head baseline, which indicates that it is a more effective predictor.
This improvement may attribute to the interdependence between different keypoints.
Knowing the exact position of some keypoints benefits the prediction of others.
We also attempt to train Obj2Seq with a longer training schedule.
Training
[Table] [Table]
for 150 epochs can further improves mAP to 65.0%.
Obj2Seq currently falls behind of start-of-theart methods (listed in Appendix), but has potential for further improvements.
Nevertheless, these experiments validate that Obj2Seq can be implemented in human pose estimation, and we believe it is also available for other visual tasks.
4.4 Ablation Studies
In this section, we examine different parts and ablate on some important options in Obj2Seq.
We conduct these experiments on object detection for demonstration.
4.4.1 Overall Structure
We mainly elaborate the existence of two modules in Obj2Seq, Prompted Visual Indicator and General
Sequence Predictor.
Removing them leading to a framework similar to Deformable DETR.
Therefore, we directly takes Deformable DETR as the baseline.
Table 3 shows that both modules provide steady improvements for Obj2Seq.
With the help of Prompted Visual Indicator, Obj2Seq is able to process objects of different categories separately, and distinguish important class-aware features with given prompts.
This makes Obj2Seq work more efficiently, leading to an improvement of +0.6%.
General
Sequence Predictor is initially designed for better generality.
However, the precision is also increased by +0.6%, which actually surprises us.
We suppose that attributes of most object-level tasks are not independent.
Some known attributes may help with the prediction of the others.
For example, it would be more accuracy to estimate the scale of a box if its center is determined.
4.4.2 Objectness Branch
In Section 3.4, we have introduced the additional objectness branch.
It is constructed in order to recognize if the object exists, rather than to describe it.
Meanwhile, it is also a valid way if we merge objectness into the output sequence of General Sequence Predictor, which means inserting an additional word representing the objectness score before the original sequence.
We validate the necessity of the objectness branch in Table 3.
Predictor without a separate objectness branch achieves the same performance as the original MLP.
However, a separate objectness branch further improves mAP by +0.6%.
Both options are extensible for different tasks.
We explain this phenomenon in two aspects.
On one hand, a single linear layer is not that good at judging the existence of objects of different categories.
It needs help from the class vectors.
On the other hand, checking the existence of an object is different from describing it.
Their functions may conflict in the same head.
Therefore, it is better to build a separate objectness branch.
Clip Initialization Fixed [Table] Vectors mAP
[Table]
✓
[Table]
✓ ✓
[Table]
     
  1XPEHURIFDWRJRULHVUHWDLQHG       P $    
  
  * ) O R S V P$3ZVFRUHRIFDWHJRULHVP$3ZRVFRUHRIFDWHJRULHV&RPSXWDWLRQ&RVW (a)     7KUHVKROGWRUHWDLQFDWHJRULHV   
   P $    
  
  * ) O R S V P$3ZVFRUHRIFDWHJRULHVP$3ZRVFRUHRIFDWHJRULHV&RPSXWDWLRQ&RVW (b)
4.4.3 Ablation of Prompted Visual Indicator
Input prompt vector Obj2Seq receives class prompts as inputs to detect objects of certain categories, while how to generate class prompts remains a question.
The simplest way is learning a prompt vector for each class from scratch, just like how object queries are learned in DETR [4].
As shown in Table 4, this straight-forward solution achieves 45.4%.
CLIP [43] is a robust feature extractor pretrained with a huge amount of image-text data pairs.
It can provide better representations for label text of each category.
Initializing prompt vectors with CLIP features achieves +0.3% improvement.
However, fixing these prompt vectors leads to a slight decrease in precision.
Vectors generated by
CLIP may not be well aligned with image features.
It needs to be tuned in the training process.
Retention Policies As mentioned in Section 3.2, Prompted Visual Indicator is not only used for classification, but also to initialize object queries for retained categories.
If one category is filtered out, it means that Obj2Seq will not detect any objects of this category.
It may be doubtful whether
Obj2Seq is sensitive to the retention policy.
Here we demonstrate how mAP changes when we use different policies in evaluation.
As shown in Figure 3, we mainly test with two policies, retaining the top- K ′ categories or any categories over a threshold.
Obj2Seq achieves steady results with both policies (see the blue curves).
The evaluation metric fluctuates within a range of 0.2% when the number of remaining classes changes from 10 to 80, and mAP is also stable when the threshold is lower than 0.3.
These results indicate that Obj2Seq is insensitive to the retention policy.
In Eq.
(3), the scores for class existence s ( k ) C is further multiplied in the objectness branch to obtain final scores for objects.
It does not improves the accuracy much if we use the same retention policy in training and evaluation, but makes Obj2Seq a more robust framework with different policies in inference.
Figure 3 provides both curves with and without the participance of class existence s ( k ) C .
Without s ( k ) C , the precision drops more significantly when we modify the retention policy in evaluation.
This phenomenon emerges because Object Transformer Decoder and General Sequence
Predictor receives inputs in different distributions when the policy changes.
Inputs of some categories are filtered out by Prompted Visual Indicator during training, therefore Obj2Seq cannot make accurate predictions if they are seen in inference.
By multiplying with the class existence s ( k ) C , we are able to make it up to some extent.
Conclusion
In this paper, we propose a controllable and versatile framework for object-level visual tasks, Obj2Seq.
This framework takes class prompts to determine the objects it should attend to, and generates a sequence of attributes to describe each object in the image.
Obj2Seq can be applied in different visual tasks, such as object detection, human pose estimation and image classification, and achieves comparable results with other task-specific methods.
There are a few problems unsolved in Obj2Seq, which need further discussions.
Firstly, Obj2Seq mainly focuses on a unified definition of different visual tasks, but barely pays attention to the detailed structure of the feature extractor.
Designing a new feature extractor for general usage may achieve better performance.
Secondly, Obj2Seq can be implemented in a wide range of other tasks.
Finally,
Obj2Seq only takes class prompts to guide the model.
In order to satisfy finer requirements, a more detailed indicator is worth developing.
All in all, Obj2Seq points a promising direction for general vision models, and it may inspire further studies.
Acknowledgments and Disclosure of Funding
This work was supported by National Key R&D Program of China under Grant No.2021ZD0110403,
National Natural Science Foundation of China (No.62002357, No.61976210, No.62176254,
No.61876086, No.62076235), the InnoHK program and also sponsored by Zhejiang Lab (No.2021KH0AB07).
Checklist
For all authors... (a) Do the main claims made in the abstract and introduction accurately reflect the paper’s contributions and scope?
[Yes] (b) Did you describe the limitations of your work?
[Yes] See conclusion.
(c) Did you discuss any potential negative societal impacts of your work?
[No] Our work proposes a framework for visual tasks.
It does not involve social impacts.
(d) Have you read the ethics review guidelines and ensured that your paper conforms to them?
[Yes] 2.
If you are including theoretical results... (a) Did you state the full set of assumptions of all theoretical results?
[N/A] (b) Did you include complete proofs of all theoretical results?
[N/A] 3.
If you ran experiments... (a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)?
[Yes] The code is included in the supplemental material.
We will also release it later.
(b) Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)?
[Yes] See Appendix and the code.
(c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)?
[No] (d) Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)?
[Yes] See Appendix. 4.
If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... (a) If your work uses existing assets, did you cite the creators?
[Yes] (b) Did you mention the license of the assets?
[Yes] See Appendix.
(c) Did you include any new assets either in the supplemental material or as a URL?
[Yes] Our code is included in the supplemental material (d) Did you discuss whether and how consent was obtained from people whose data you’re using/curating?
[Yes] (e) Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content?
[No] 5.
If you used crowdsourcing or conducted research with human subjects... (a) Did you include the full text of instructions given to participants and screenshots, if applicable?
[N/A] (b) Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable?
[N/A] (c) Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation?
[N/A]
Appendix A Experiments on Object Detection A.1 Implementation Details
Datasets We conduct object detection experiments on MS COCO [34], which is a publicly available large-scale detection benchmark.
MS COCO contains 118K images in the training set and 5K images in the validation set.
All instances in these images belong to 80 different categories.
The performance of a detector is evaluated with mean Average Precision (mAP) of all categories.
Hyperparameters During Training, Prompted Visual Indicator takes all 80 categories as inputs, and the retention policy retains K ′ = 20 categories.
The indicator then generates N = 100 object queries for each of these remaining categories.
As to the losses, we implement Focal Loss [33] for objectness branch, and a combination of ℓ 1 loss and the generalized IoU loss [45] for box regression in Sequence
Predictor.
The loss weights for them are 2, 5, 2 separately, which are similar to Deformable-DETR [64].
As to the auxiliary asymmetric loss [46] in Prompt Visual Indicator, the loss weight is set to be 0 .
25 for a comparable loss scale.
Training configuration
Our training configuration directly follows Deformable-DETR [64].
Obj2Seq takes 16 images as a training batch.
It is trained with an AdamW optimizer [38] for 50 epochs, with β 1 = 0 .
9 , β 2 = 0 .
999 and weight decay 1 × 10 − 4 .
The initial learning rate is 2 × 10 − 4 , and it decays by 0 .
1 after the 40th epoch.
As to the input images, we apply scale augmentation and scale augmentation as in [4, 64].
We train Obj2Seq with 16 Nvidia V100 GPUs.
A.2 Further Improvements on Transformer Structure
[Table]
Currently, there emerge many variations of the visual transformer decoder with more efficient attention mechanisms or improved position embeddings.
Though Obj2Seq mainly focuses on the unified framework that can process different tasks, it can also benefit from advanced structure modifications.
Here we take a trail of iterative box refinement as in [64].
In Table 5, Obj2Seq with box refinement achieves 46.7%.
It is +1.0% higher than the basic version, and also outperforms Deformable DETR with the same decoder structure by +0.4%.
This indicates that iterative box refine is also available for
Obj2Seq, and we are willing to test with more up-to-date improvements.
B More comparison on Multi-Label Classification
As in Section 4.2, Obj2Seq trained for object detection can also be applied to predict the existence of different categories.
Therefore, it has the ability to perform multi-label classification.
Since object detection always has a larger input resolution ( 800 × 1333 ), the result is not that convincible.
Here we evaluate with a smaller resolution, and provide a more detailed comparison with some other multi-label classification algorithms in Table 6.
Obj2Seq achieves comparable performance with most methods.
These results indicate that Obj2Seq can be extended to different usages.
[Table]
C Experiments on Human Pose Estimation C.1 Implementation Details
Datasets We also conduct experiments on MS COCO [34], but with keypoint annotataions.
We filter images in the training set, and retain the 4.8K images with at least 10 valid keypoint annotations as in [23].
As to the evaluation metric, we utilize Object Keypoint Similarity (OKS).
Model structure Our model consists of Image Feature Encoder, Object Transformer Decoder and
General Sequence Predictor.
Object Transformer Decoder consists of 6 decoder layers and 100 object queries.
Sequence Predictor predicts 38 attributes for each object query.
After predicting x, y, w, h , it continues to predict δx, δy for all 17 keypoints.
These attributes represent the offsets of these keypoints.
Losses and training configurations We implement binary cross entropy for the objectness branch, a combination of ℓ 1 loss and the generalized IoU loss [45] for box regression and a combination of ℓ 1 loss and oks loss [39] for keypoint offset prediction.
All losses are normalized by the number of instances in ground truth, except that ℓ 1 for offsets is normalized by the number of valid keypoint annotations.
They loss weights are 2, 5, 2, 40, 5 separately.
The training scheduler is almost the same as in object detection.
The only difference is that we construct a batch with 32 images, and the initial learning rate is set to 3 ×
10 − 4 .
When training with a 150-epoch schedule, we drop the learning rate by 0.1 after the 120th epoch instead.
We train Obj2Seq for human pose estimation with 16 Nvidia
V100 GPUs.
C.2 More comparisons
Here we provide a more complete table that lists most of the popular human pose estimation algorithms, including bottom-up methods, top-down methods with crop operation and top-down methods in an end-to-end way.
Obj2Seq outperforms most of end-to-end top-down algorithms, and achieves a comparable performance with bottom-up ones.
However, it still falls behind a lot when comparing with crop-based algorithms.
This difference mainly attributes to the crop operation.
This operation allows the model to extract related features from the exact position of each person.
In order to achieve better results, some specific design for human pose estimation may benefit, which is beyond the topic of this paper.
C.3 Effect of General Sequence Predictor on multi-task training
In order to demonstrate the performance of the sequence output format under multi-task training, we provide both metrics for human detection and pose estimation in this section.
These experiments are conducted with three different multi-task prediction heads in Table 8.
Baseline utilizes 2 separate MLPs ( 4 d and 34 d ) to predict detection and keypoint results from the processed object tokens.
We follow previous DETRs to use 3-layer MLPs here.
[Table]
2-Token combines the object queries with two additional task embeddings for detection and pose estimation
[Table]
and obtains two task-specific tokens for each object.
These queries are then fed into a transformer layer, with a self-attention between tokens of different tasks and a cross-attention layer inside.
After that, MLPs are utilized to predict results for each task with corresponding task-specific tokens.
[Table]
We conduct experiments with the same 50-epoch training schedule.
With the help of task embeddings, 2-Token head achieves higher performance than the simple MLP baseline.
It makes use of selfattention among different tasks to enhance the performance.
However, since Obj2Seq takes definite outputs from previous steps and utilizes them as inputs for subsequent steps, it is able to capture more explicit intra- and inter-task relations.
Therefore, Obj2Seq achieves even better results.
Moreover, this unified sequence format is consistent with text and audio tasks.
It is more friendly to be extended for other multi-model applications.
D Code Details and Licenses D.1 Details
Here we provide detailed algorithm for better understanding how Obj2Seq works.
We mainly elaborate on two aspects.
The first is to formulate the function of Prompted Visual Indicator in the pseudo code in Algorithm 1.
The second is to demonstrate how the output logits z t in Eq.
(2) are transformed into final outputs exactly.
We take object detection and human pose estimation as examples in Algorithm
D.2 Licenses
The code for Obj2Seq is attached in the supplymentary meterial, and it will also be released to public later.
Our code base is constructed mainly based on DETR [4], Deforamble DETR [64] and Anchor
DETR [57].
For all code assets we refer to and their licenses, please see Table 9.
In addition, we have also listed references at the beginning of each file in our code
[Table] [Table]