VisualCloze: A Universal Image Generation Framework via Visual In-Context Learning

Zhong-Yu Li, Ruoyi Du, Juncheng Yan, Le Zhuo, Zhen Li, Peng Gao, Zhanyu Ma, Ming-Ming Cheng

TL;DR

This paper introduces VisualCloze, a universal framework for image generation that leverages visual in-context learning to understand tasks from examples, rather than relying solely on text instructions. By introducing a novel graph-structured dataset, Graph200K, and building upon existing image infilling models, VisualCloze achieves strong performance across diverse tasks and generalizes well to unseen ones.

What Problem Does This Paper Address?

The field of image generation has seen remarkable progress with diffusion models, but existing models are often task-specific, limiting their efficiency and scalability. While universal models aim to address this, they face challenges in designing generalizable instructions, handling the sparsity of visual tasks, and creating unified architectures. Current approaches often rely on language instructions, which can lead to ambiguity and poor generalization due to the inherent gap between vision and language. Furthermore, visual tasks are inherently sparse, making it difficult for models to learn transferable knowledge across different tasks.

Methods

VisualCloze tackles these challenges through several key innovations:

  • Visual In-Context Learning: Instead of relying on text prompts, VisualCloze uses a few visual examples (demonstrations) to teach the model a specific task. This approach mitigates task ambiguity and improves generalization, especially for unseen tasks.
  • Graph-Structured Dataset (Graph200K): To address the sparsity of visual tasks, the authors introduce Graph200K. This dataset structures various interrelated tasks into a graph, increasing task density and promoting the learning of shared, transferable representations. Tasks are defined by paths within this graph.
  • Unified Image Infilling Framework: The core architecture of VisualCloze is based on general image infilling models. The authors observe that image infilling and universal image generation share a consistent objective. By framing any generation task as filling a blank grid within a larger image context (similar to a visual cloze puzzle), they can leverage powerful pre-trained infilling models (like FLUX.1-Fill-dev) without architectural modifications. This allows for efficient fine-tuning and utilization of existing knowledge.

Datasets

  • Graph200K: This is a newly introduced dataset designed to address the sparsity of visual tasks. It is built upon the Subject200K dataset and structures data into graphs where each image is associated with annotations for various tasks, including conditional generation, image restoration, editing, and style transfer. This graph structure allows for flexible task sampling and promotes inter-task knowledge transfer.
  • Subjects200K: Used as a base for constructing Graph200K.

Key Insights and Ideas

  • Visuals as Instructions: The paper strongly advocates for using visual examples as task instructions, arguing they are more intuitive and effective than language alone for visual generative models.
  • Infilling as a Universal Paradigm: The insight that image infilling and universal image generation share a fundamental objective is crucial. This allows for a unified framework that can adapt existing powerful infilling models without complex architectural changes.
  • Graph Structure for Task Density: Representing tasks as a graph is a novel way to increase the density and interconnectedness of visual tasks, facilitating better knowledge transfer and generalization.
  • In-Context Learning for Generalization: The experiments demonstrate that even a small number of in-context examples can significantly improve performance and generalization, particularly for unseen tasks.

Key Results

  • VisualCloze achieves strong performance across various in-domain tasks, including conditional generation, image restoration, editing, and style transfer.
  • The framework exhibits significant generalization capabilities to unseen tasks in few-shot and zero-shot settings.
  • Compared to specialized models, VisualCloze demonstrates comparable or superior controllability and visual quality.
  • In style transfer, VisualCloze shows improvements in text alignment and style consistency compared to universal models like OmniGen.
  • The paper shows that using in-context learning can improve FID scores and reduce RMSE in tasks like canny-to-image generation and depth-to-image generation.

Limitations and Future Work

  • Resolution: The current implementation is limited to a relatively low resolution (384x384), though the authors note that post-upscaling techniques can be used for higher-resolution outputs.
  • Task Complexity: While the framework supports diverse tasks, the paper doesn't explicitly detail the upper bounds of task complexity it can handle.
  • Future Work: The authors suggest that their approach can be extended to more complex tasks and potentially higher resolutions. The unified framework also opens avenues for further exploration of cross-task learning and adaptation.

Summary updated

BibTeX
@inproceedings{li2025visualcloze,
  author = {Zhong-Yu Li and Ruoyi Du and Juncheng Yan and Le Zhuo and Zhen Li and Peng Gao and Zhanyu Ma and Ming-Ming Cheng},
  title = {{VisualCloze: A Universal Image Generation Framework via Visual In-Context Learning}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2025},
}
Figure