Abstract
Recent advances in generative diffusion models have enabled text-controlled synthesis of realistic and diverse images with impressive quality. Despite these remarkable advances, the application of text-to-image generative models in computer vision for standard visual recognition tasks remains limited. The current de-facto approach for these tasks is to design model architectures and loss functions that are tailored to the task at hand. In this paper, we develop a unified language interface for computer vision tasks that abstracts away task-specific design choices and enables task execution by following natural language instructions. Our approach involves casting multiple computer vision tasks as text-to-image generation problems. Here, the text represents an instruction describing the task, and the resulting image is a visually-encoded task output. To train our model, we pool commonly-used computer vision datasets covering a range of tasks, including segmentation, object detection, depth estimation, and classification. We then use a large language model to paraphrase prompt templates that convey the specific tasks to be conducted on each image, and through this process, we create a multi-modal and multi-task training dataset comprising input and output images along with annotated instructions. Following the InstructPix2Pix architecture, we apply instruction-tuning to a text-to-image diffusion model using our constructed dataset, steering its functionality from a generative model to an instruction-guided multi-task vision learner. Experiments demonstrate that our model, dubbed InstructCV, performs competitively compared to other generalist and task-specific vision models. Moreover, it exhibits compelling generalization capabilities to unseen data, categories, and user instructions.
Introduction
In the field of computer vision, the prevailing paradigm has been the development of "specialist" models. For instance, object detection, semantic segmentation, and depth estimation typically require distinct architectures and specialized loss functions. While "generalist" models have begun to emerge, they often rely on complex sequence-to-sequence frameworks or discrete numerical codes that can be difficult to interpret.
InstructCV proposes a different path: repurposing the latent knowledge within large-scale generative diffusion models. These models, such as Stable Diffusion, already possess a deep understanding of visual concepts from being trained on billions of images. The challenge lies in "steering" these generative capabilities toward precise, discriminative vision tasks. By treating vision outputs as images and using a unified natural language interface, InstructCV acts as a versatile vision generalist.
Methodology
The core innovation of InstructCV is casting every computer vision task as an image-to-image translation problem guided by natural language instructions.
Unified Visual Encoding
Rather than predicting coordinates or class labels as text tokens, InstructCV predicts an output image that visually encodes the task result:
- Segmentation: The model generates a binary mask of the target object.
- Object Detection: The model outputs the original image with a bounding box overlaid.
- Depth Estimation: The model produces a color-coded depth map.
- Classification: The model generates a solid color block corresponding to a specific category.
Instruction Tuning and Prompt Diversity
The researchers adapted the InstructPix2Pix architecture, fine-tuning a pre-trained Stable Diffusion model on a multi-task dataset. To ensure robustness to human language, they utilized a Large Language Model (T5) to paraphrase task templates. Instead of learning only a single command like "Segment the tree," the model is trained on diverse variations such as "Can you help me segment the tree?" or "Highlight the image parts corresponding to the tree."
Datasets
The training set comprises approximately 180,000 images pooled from major datasets: ADE20K and MS-COCO for segmentation and detection, NYUv2 for depth estimation, and Oxford-IIIT Pet for classification. Generalization was tested on unseen datasets including ImageNet, SUNRGB-D, VOC, and FSS-1000.
Results and Generalization
InstructCV demonstrates that generative backbones are powerful discriminators. Because Stable Diffusion was trained on a vast array of internet data, InstructCV can segment or detect objects like "Spider-Man" or "The Sphinx" even if they were not present in its specific computer vision training sets.
Key performance highlights include:
- Depth Estimation: InstructCV achieved a 10% improvement in RMSE over specialized models like BinsFormer on in-distribution data and showed significantly better zero-shot generalization on the SUNRGB-D dataset.
- Open-Vocabulary Segmentation: On the FSS-1000 benchmark for unseen categories, InstructCV achieved 69.8 mIoU, outperforming other generalist models like Painter (62.3).
- Robustness to Instructions: The rephrased-prompt (RP) training proved crucial; the model showed only a 6% performance dip when faced with unseen user instructions, compared to a 51.8% drop for a model trained on fixed templates.
- Efficiency: Inference takes approximately 5 seconds on an NVIDIA A100, which is considerably faster than some sequence-based generalists like Unified-IO.
Conclusion
InstructCV successfully demonstrates that text-to-image diffusion models can be effectively tuned to serve as multi-task vision generalists. By operating in a unified pixel space and utilizing natural language instructions, the model achieves impressive generalization across tasks and domains. While challenges remain regarding inference speed for real-time applications and pixel-perfect precision in generative outputs, InstructCV represents a significant step toward more flexible and intuitive computer vision systems.
Summary updated