Skip to content

Instantly share code, notes, and snippets.

@AlexeyLugovoy
Last active June 10, 2024 19:53
Show Gist options
  • Save AlexeyLugovoy/38b8b7c08a7ffb7f7d1c24c150419270 to your computer and use it in GitHub Desktop.
Save AlexeyLugovoy/38b8b7c08a7ffb7f7d1c24c150419270 to your computer and use it in GitHub Desktop.
from diffusers import StableDiffusionControlNetPipeline, UniPCMultistepScheduler, ControlNetModel
controlnet = ControlNetModel.from_pretrained(
"monster-labs/control_v1p_sd15_qrcode_monster",
torch_dtype=torch.float16,
cache_dir=CACHE_DIR
).to(DEVICE)
pipe = StableDiffusionControlNetPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5",
torch_dtype=torch.float16,
controlnet=controlnet,
cache_dir=CACHE_DIR
).to(DEVICE)
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
prompt = ["award winning photography shirts, pants, socks, linens, sheets on clothesline in the sun high definition"]
negative_prompt = ["ugly. disfigured. low quality. blurry. nsfw. trees. green leaves. leaf. vegetation. paint. oil painting"]
img_gen = pipe(
prompt=prompt,
negative_prompt=negative_prompt,
image=img_pil,
guidance_scale=9,
controlnet_conditioning_scale=1.2,
height=768, # init image size
width=768,
generator=torch.Generator(DEVICE).manual_seed(22),
num_inference_steps=100
)
img_gen.images[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment