🚀 VisualCloze: ビジュアルなインコンテキスト学習による汎用画像生成フレームワーク (Diffusers での実装)
VisualClozeは、ビジュアルなインコンテキスト学習を用いた汎用画像生成フレームワークです。様々なドメイン内タスクをサポートし、インコンテキスト学習を通じて未知のタスクにも対応できます。

もしVisualClozeが役に立った場合は、Githubリポジトリにスターをつけることを検討してください。ありがとう!
🚀 クイックスタート
VisualClozeを始めるには、まず必要なライブラリをインストールする必要があります。以下の手順に従ってセットアップしましょう。
✨ 主な機能
- インコンテキスト学習に基づく汎用画像生成フレームワークです。
- 様々なドメイン内タスクをサポートします。
- インコンテキスト学習を通じて、未知のタスクにも汎化できます。
- 複数のタスクを1つのステップに統合し、ターゲット画像と中間結果の両方を生成します。
- ターゲット画像から一連の条件を逆エンジニアリングすることができます。
🔥 具体的な例はプロジェクトページをご覧ください。
📦 インストール
公式の diffusers をインストールすることができます。
pip install git+https://github.com/huggingface/diffusers.git
💻 使用例
基本的な使用法
深度画像から画像への変換の例:
import torch
from diffusers import VisualClozePipeline
from diffusers.utils import load_image
image_paths = [
[
load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/93bc1c43af2d6c91ac2fc966bf7725a2/93bc1c43af2d6c91ac2fc966bf7725a2_depth-anything-v2_Large.jpg'),
load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/93bc1c43af2d6c91ac2fc966bf7725a2/93bc1c43af2d6c91ac2fc966bf7725a2.jpg'),
],
[
load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/79f2ee632f1be3ad64210a641c4e201b/79f2ee632f1be3ad64210a641c4e201b_depth-anything-v2_Large.jpg'),
None,
],
]
task_prompt = "Each row outlines a logical process, starting from [IMAGE1] gray-based depth map with detailed object contours, to achieve [IMAGE2] an image with flawless clarity."
content_prompt = """A serene portrait of a young woman with long dark hair, wearing a beige dress with intricate
gold embroidery, standing in a softly lit room. She holds a large bouquet of pale pink roses in a black box,
positioned in the center of the frame. The background features a tall green plant to the left and a framed artwork
on the wall to the right. A window on the left allows natural light to gently illuminate the scene.
The woman gazes down at the bouquet with a calm expression. Soft natural lighting, warm color palette,
high contrast, photorealistic, intimate, elegant, visually balanced, serene atmosphere."""
pipe = VisualClozePipeline.from_pretrained("VisualCloze/VisualClozePipeline-384", resolution=384, torch_dtype=torch.bfloat16)
pipe.to("cuda")
image_result = pipe(
task_prompt=task_prompt,
content_prompt=content_prompt,
image=image_paths,
upsampling_width=1024,
upsampling_height=1024,
upsampling_strength=0.4,
guidance_scale=30,
num_inference_steps=30,
max_sequence_length=512,
generator=torch.Generator("cpu").manual_seed(0)
).images[0][0]
image_result.save("visualcloze.png")
バーチャルトライオンの例:
import torch
from diffusers import VisualClozePipeline
from diffusers.utils import load_image
image_paths = [
[
load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/tryon/00700_00.jpg'),
load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/tryon/03673_00.jpg'),
load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/tryon/00700_00_tryon_catvton_0.jpg'),
],
[
load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/tryon/00555_00.jpg'),
load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/tryon/12265_00.jpg'),
None
],
]
task_prompt = "Each row shows a virtual try-on process that aims to put [IMAGE2] the clothing onto [IMAGE1] the person, producing [IMAGE3] the person wearing the new clothing."
content_prompt = None
pipe = VisualClozePipeline.from_pretrained("VisualCloze/VisualClozePipeline-384", resolution=384, torch_dtype=torch.bfloat16)
pipe.to("cuda")
image_result = pipe(
task_prompt=task_prompt,
content_prompt=content_prompt,
image=image_paths,
upsampling_height=1632,
upsampling_width=1232,
upsampling_strength=0.3,
guidance_scale=30,
num_inference_steps=30,
max_sequence_length=512,
generator=torch.Generator("cpu").manual_seed(0)
).images[0][0]
image_result.save("visualcloze.png")
📚 ドキュメント
引用
もしVisualClozeがあなたの研究やアプリケーションに役立った場合は、次のBibTeXを使用して引用してください。
@article{li2025visualcloze,
title={VisualCloze: A Universal Image Generation Framework via Visual In-Context Learning},
author={Li, Zhong-Yu and Du, Ruoyi and Yan, Juncheng and Zhuo, Le and Li, Zhen and Gao, Peng and Ma, Zhanyu and Cheng, Ming-Ming},
journal={arXiv preprint arXiv:2504.07960},
year={2025}
}
📄 ライセンス
このプロジェクトはApache-2.0ライセンスの下で公開されています。