Views
No views yet

pip install git+https://github.com/huggingface/diffusers.gitresolution of 512 is released at Full Model Card 512 and LoRA Model Card 512,
while this model uses the resolution of 384. The resolution means that each image will be resized to it before being
concatenated to avoid the out-of-memory error. To generate high-resolution images, we use the SDEdit technology for upsampling the generated results.
1import torch
2from diffusers import VisualClozePipeline
3from diffusers.utils import load_image
4
5
6# Load in-context images (make sure the paths are correct and accessible)
7image_paths = [
8 # in-context examples
9 [
10 load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/93bc1c43af2d6c91ac2fc966bf7725a2/93bc1c43af2d6c91ac2fc966bf7725a2_depth-anything-v2_Large.jpg'),
11 load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/93bc1c43af2d6c91ac2fc966bf7725a2/93bc1c43af2d6c91ac2fc966bf7725a2.jpg'),
12 ],
13 # query with the target image
14 [
15 load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/79f2ee632f1be3ad64210a641c4e201b/79f2ee632f1be3ad64210a641c4e201b_depth-anything-v2_Large.jpg'),
16 None, # No image needed for the query in this case
17 ],
18]
19
20# Task and content prompt
21task_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."
22content_prompt = """A serene portrait of a young woman with long dark hair, wearing a beige dress with intricate
23gold embroidery, standing in a softly lit room. She holds a large bouquet of pale pink roses in a black box,
24positioned in the center of the frame. The background features a tall green plant to the left and a framed artwork
25on the wall to the right. A window on the left allows natural light to gently illuminate the scene.
26The woman gazes down at the bouquet with a calm expression. Soft natural lighting, warm color palette,
27high contrast, photorealistic, intimate, elegant, visually balanced, serene atmosphere."""
28
29# Load the VisualClozePipeline
30pipe = VisualClozePipeline.from_pretrained("VisualCloze/VisualClozePipeline-384", resolution=384, torch_dtype=torch.bfloat16)
31pipe.to("cuda")
32
33# Loading the VisualClozePipeline via LoRA
34# pipe = VisualClozePipeline.from_pretrained("black-forest-labs/FLUX.1-Fill-dev", resolution=384, torch_dtype=torch.bfloat16)
35# pipe.load_lora_weights('VisualCloze/VisualClozePipeline-LoRA-384', weight_name='visualcloze-lora-384.safetensors')
36# pipe.to("cuda")
37
38# Run the pipeline
39image_result = pipe(
40 task_prompt=task_prompt,
41 content_prompt=content_prompt,
42 image=image_paths,
43 upsampling_width=1024,
44 upsampling_height=1024,
45 upsampling_strength=0.4,
46 guidance_scale=30,
47 num_inference_steps=30,
48 max_sequence_length=512,
49 generator=torch.Generator("cpu").manual_seed(0)
50).images[0][0]
51
52# Save the resulting image
53image_result.save("visualcloze.png")
1import torch
2from diffusers import VisualClozePipeline
3from diffusers.utils import load_image
4
5
6# Load in-context images (make sure the paths are correct and accessible)
7# The images are from the VITON-HD dataset at https://github.com/shadow2496/VITON-HD
8image_paths = [
9 # in-context examples
10 [
11 load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/tryon/00700_00.jpg'),
12 load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/tryon/03673_00.jpg'),
13 load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/tryon/00700_00_tryon_catvton_0.jpg'),
14 ],
15 # query with the target image
16 [
17 load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/tryon/00555_00.jpg'),
18 load_image('https://github.com/lzyhha/VisualCloze/raw/main/examples/examples/tryon/12265_00.jpg'),
19 None
20 ],
21]
22
23# Task and content prompt
24task_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."
25content_prompt = None
26
27# Load the VisualClozePipeline
28pipe = VisualClozePipeline.from_pretrained("VisualCloze/VisualClozePipeline-384", resolution=384, torch_dtype=torch.bfloat16)
29pipe.to("cuda")
30
31# Loading the VisualClozePipeline via LoRA
32# pipe = VisualClozePipeline.from_pretrained("black-forest-labs/FLUX.1-Fill-dev", resolution=384, torch_dtype=torch.bfloat16)
33# pipe.load_lora_weights('VisualCloze/VisualClozePipeline-LoRA-384', weight_name='visualcloze-lora-384.safetensors')
34# pipe.to("cuda")
35
36# Run the pipeline
37image_result = pipe(
38 task_prompt=task_prompt,
39 content_prompt=content_prompt,
40 image=image_paths,
41 upsampling_height=1632,
42 upsampling_width=1232,
43 upsampling_strength=0.3,
44 guidance_scale=30,
45 num_inference_steps=30,
46 max_sequence_length=512,
47 generator=torch.Generator("cpu").manual_seed(0)
48).images[0][0]
49
50# Save the resulting image
51image_result.save("visualcloze.png")1@InProceedings{Li_2025_ICCV,
2 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},
3 title = {VisualCloze: A Universal Image Generation Framework via Visual In-Context Learning},
4 booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
5 month = {October},
6 year = {2025},
7 pages = {18969-18979}
8}