Views
No views yet
1git clone -b instancediffusion https://github.com/gokyeongryeol/diffusers.git
2cd diffusers & pip install -e .1import torch
2from diffusers import StableDiffusionINSTDIFFPipeline
3
4pipe = StableDiffusionINSTDIFFPipeline.from_pretrained(
5 "kyeongry/instancediffusion_sd15",
6 # variant="fp16", torch_dtype=torch.float16,
7)
8pipe = pipe.to("cuda")
9
10prompt = "a yellow American robin, brown Maltipoo dog, a gray British Shorthair in a stream, alongside with trees and rocks"
11negative_prompt = "longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality"
12
13# normalized (xmin,ymin,xmax,ymax)
14boxes = [
15 [0.0, 0.099609375, 0.349609375, 0.548828125],
16 [0.349609375, 0.19921875, 0.6484375, 0.498046875],
17 [0.6484375, 0.19921875, 0.998046875, 0.697265625],
18 [0.0, 0.69921875, 1.0, 0.998046875],
19]
20phrases = [
21 "a gray British Shorthair standing on a rock in the woods",
22 "a yellow American robin standing on the rock",
23 "a brown Maltipoo dog standing on the rock",
24 "a close up of a small waterfall in the woods",
25]
26
27image = pipe(
28 prompt=prompt,
29 negative_prompt=negative_prompt,
30 instdiff_phrases=phrases,
31 instdiff_boxes=boxes,
32 instdiff_scheduled_sampling_alpha=0.8, # proportion of using gated-self-attention
33 instdiff_scheduled_sampling_beta=0.36, # proportion of using multi-instance sampler
34 guidance_scale=7.5,
35 output_type="pil",
36 num_inference_steps=50,
37).images[0]
38
39image.save("./instancediffusion-sd15-layout2image-generation.jpg")