InstructCV: Instruction-Tuned Text-to-Image Diffusion Models as Vision Generalists

Yulu Gan, Sungwoo Park, Alexander Schubert, Anthony Philippakis, Ahmed M. Alaa

TL;DR

InstructCV repurposes generative text-to-image diffusion models (like Stable Diffusion) into versatile "vision generalists" capable of performing multiple computer vision tasks through natural language instructions. By casting tasks like segmentation and object detection as image-to-image generation problems, the model achieves competitive performance and demonstrates remarkable zero-shot generalization to unseen categories and user prompts.

What Problem Does This Paper Address?

Traditionally, computer vision has been a field of specialists. If you want to detect objects, you build a detection architecture; if you want to estimate depth, you design a depth-specific loss function. While "generalist" models have emerged recently, they often rely on complex sequence-to-sequence architectures that represent images as discrete tokens. These models can be slow to run and often struggle to generalize when faced with natural language instructions or object categories they didn't see during training.

The authors of InstructCV ask: Can we take the massive representational power of generative diffusion models and "steer" them to perform standard vision tasks instead of just making pretty pictures?

Methods

The core innovation of InstructCV is treating various computer vision tasks as a unified text-to-image generation problem.

  1. Visual Encoding of Outputs: Instead of predicting coordinates or labels, the model is trained to generate an image that represents the task output.
  2. Segmentation: Generates a binary mask.
  3. Object Detection: Generates the original image with a bounding box drawn over the target.
  4. Depth Estimation: Generates a color-coded depth map.
  5. Classification: Generates a solid color block if a category is present.
  6. Instruction Tuning: Building on the InstructPix2Pix architecture, the researchers fine-tuned a pre-trained Stable Diffusion model. The model takes two inputs—an image and a natural language instruction—and produces the visually encoded output.
  7. LLM-Powered Robustness: To ensure the model understands more than just rigid templates, the authors used a Large Language Model (LLM) to paraphrase task instructions. Instead of just learning "Segment the cat," the model learns to respond to "Can you help me isolate the feline in this photo?"
The InstructCV training pipeline involves visual encoding of task outputs and LLM-based instruction generation.

Datasets

The authors pooled four major datasets to create a multi-task training set of approximately 180,000 images:

  • MS-COCO: For object detection.
  • ADE20K: For semantic segmentation.
  • NYUv2: For monocular depth estimation.
  • Oxford-III-Pets: For image classification.

To test generalization, they evaluated the model on "external" datasets not seen during training, including ImageNet (classification), SUNRGB-D (detection/depth), VOC (segmentation), and FSS-1000 (open-vocabulary segmentation).

Key Insights and Ideas

  • Generative Models as Discriminative Learners: The paper proves that the "world knowledge" embedded in generative models can be successfully repurposed for analytical vision tasks.
  • Language as a Universal Interface: By using natural language, the model can perform "zero-shot" tasks on categories it never saw in its specific vision training data (e.g., detecting specific landmarks like MIT's Great Dome) by relying on the prior knowledge of the base Stable Diffusion model.
  • The Importance of Paraphrasing: Training on diverse phrasings (the "RP" or Rephrased Prompt dataset) significantly improves robustness. Without it, slight changes in how a user asks for a task can lead to a massive drop in accuracy.
InstructCV generalizes to new, unseen images and user-written instructions across various tasks.

Key Results

  • Depth Estimation: InstructCV achieved a 10% improvement in RMSE over the specialized BinsFormer model on in-distribution data.
  • Generalization: On the VOC dataset (unseen during training), InstructCV outperformed the generalist model Unified-IO by a staggering +24.4 mIoU in semantic segmentation.
  • Open-Vocabulary Segmentation: On the FSS-1000 benchmark, InstructCV-RP achieved 69.8 mIoU, surpassing other generalist models like Painter (62.3) and Inpainting (58.5).
  • Efficiency: InstructCV boasts an inference time of roughly 5 seconds on an NVIDIA A100, which is significantly faster than the 40 seconds required by Unified-IO.

Limitations and Future Work

While impressive, InstructCV has notable hurdles:

  • Inference Speed: While faster than some generalists, 5 seconds per image is still far too slow for real-time applications like robotics or self-driving cars.
  • Geometric Precision: Because it is a generative model, it sometimes struggles to produce perfectly "admissible" outputs, such as perfectly rectangular bounding boxes for object detection.
  • Task Complexity: The current framework uses relatively simple instructions. The authors suggest that future work could involve Learning from Human Feedback (RLHF) to help the model handle more nuanced, complex multi-step instructions.
The impact of guidance scales on depth estimation shows the trade-off between following the image structure and the depth instruction.

Summary updated

BibTeX
@inproceedings{gan2024instructcv,
  author = {Yulu Gan and Sungwoo Park and Alexander Schubert and Anthony Philippakis and Ahmed M. Alaa},
  title = {{InstructCV: Instruction-Tuned Text-to-Image Diffusion Models as Vision Generalists}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=Nu9mOSq7eH},
}
Figure