Skip to content

Question about how to use batches of images in ControlNet+ip-Adapter to generate images separately without the influence of the condition images in one batch #7933

Answered by xingyouxin
xingyouxin asked this question in Q&A
Discussion options

You must be logged in to vote

It seems that loading multiple ip-adapters together to deal with a batch in the above way is designed to affect the generated results uniformly. I have changed my mind and wrote the following codes to figure out my problem.

from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, DDIMScheduler
from diffusers.utils import load_image
import torch
from PIL import Image

from ip_adapter.ip_adapter import IPAdapter

device = "cuda"

def image_grid(imgs, rows, cols):
    assert len(imgs) == rows * cols

    w, h = imgs[0].size
    grid = Image.new("RGB", size=(cols * w, rows * h))
    grid_w, grid_h = grid.size

    for i, img in enumerate(imgs):
        grid.paste(img, box=(i …

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by xingyouxin
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants