Abstract
Multi-label image classification is the task of predicting a set of labels corresponding to objects, attributes or other entities present in an image. In this work we propose the Classification Transformer (C-Tran), a general framework for multi-label image classification that leverages Transformers to exploit the complex dependencies among visual features and labels. Our approach consists of a Transformer encoder trained to predict a set of target labels given an input set of masked labels, and visual features from a convolutional neural network. A key ingredient of our method is a label mask training objective that uses a ternary encoding scheme to represent the state of the labels as positive, negative, or unknown during training. Our model shows state-of-the-art performance on challenging datasets such as COCO and Visual Genome. Moreover, because our model explicitly represents the label state during training, it is more general by allowing us to produce improved results for images with partial or extra label annotations during inference. We demonstrate this additional capability in the COCO, Visual Genome, News-500, and CUB image datasets.
Introduction
In real-world scenarios, images rarely contain just a single object. Multi-label image classification—the task of predicting a set of labels for an image—is a fundamental computer vision challenge. However, it is inherently difficult because objects often exhibit strong correlations; for instance, a "fork" is highly likely to appear with a "knife" but rarely with "grass."
Traditional approaches often treat labels as independent or rely on rigid, pre-defined graphs to model relationships. Furthermore, most existing models are not designed to incorporate "prior knowledge" during inference. If a user already knows an image contains a "car," standard classifiers cannot easily leverage that information to refine predictions for related objects like "tires" or "traffic lights." C-Tran addresses these limitations by creating a flexible, unified model that learns label dependencies directly from data.
Methods: The C-Tran Architecture
The Classification Transformer (C-Tran) architecture treats multi-label classification as a relational reasoning task. It consists of three primary components:
- Feature Extraction: A standard CNN backbone (ResNet-101) extracts high-level visual features from the input image.
- State Embeddings: Each possible label is represented by a learnable embedding. Crucially, each label is assigned one of three states: Positive (P), Negative (N), or Unknown (U).
- Transformer Encoder: The visual features and the label embeddings (with their associated states) are concatenated and fed into a Transformer encoder. Through self-attention, the model learns the relationships between specific image regions and labels, as well as the dependencies between the labels themselves.
Label Mask Training (LMT)
The "secret sauce" of C-Tran is the Label Mask Training (LMT) objective. Inspired by BERT’s masked language modeling, LMT involves randomly masking a subset of labels during training (setting them to "Unknown"). The model is then tasked with predicting these masked labels based on the visual features and the remaining "Known" (Positive or Negative) labels.
Key Insights and Flexibility
C-Tran's design offers several conceptual advantages:
- Labels as Context: By treating labels as input tokens, the model learns that labels provide context for each other. Knowing "water" is present significantly shifts the probability of detecting a "boat" versus a "car."
- Ternary Encoding and Inference Flexibility: The P/N/U state system allows the model to reason under uncertainty. While standard inference starts with all labels as "Unknown," the model can seamlessly accept "Partial Labels" (user-provided hints) or "Extra Labels" (metadata like location) by simply setting their state to P or N.
Experimental Results
The authors evaluated C-Tran on several large-scale benchmarks, including COCO-80, COCO-1000, Visual Genome (VG-500), News-500, and CUB-312.
- State-of-the-Art Performance: C-Tran achieved SOTA results on COCO and Visual Genome, outperforming previous methods like ML-GCN and SSGRL. On COCO, it reached a mean Average Precision (mAP) of 85.1.
- The Power of Partial Labels: The model's performance scales impressively with additional information. On the News-500 dataset, providing 75% of the labels as known information boosted the mAP from 18.1% to 39.4%.
- Efficiency: Unlike iterative "feedback" methods, C-Tran incorporates partial labels in a single Transformer pass, making it highly efficient for real-time applications.
Conclusion and Future Work
C-Tran demonstrates the power of Transformers in capturing complex label dependencies for multi-label classification. While highly effective, the model faces challenges in scaling to tens of thousands of labels due to the memory intensity of Transformers. Future work may explore more efficient Transformer variants (e.g., Linformer) or hierarchical reasoning to further improve accuracy and scalability.
Summary updated