Views
No views yet
1import cv2
2import numpy as np
3import torch
4import os, sys
5
6from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, AutoencoderKL, EulerAncestralDiscreteScheduler
7from PIL import Image
8
9controlnet = ControlNetModel.from_pretrained("ghoskno/Fake-Qrcode")
10pipe = StableDiffusionControlNetPipeline.from_pretrained(
11 "runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16
12)
13pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
14pipe.enable_model_cpu_offload()
15
16generator = torch.manual_seed(412052000)
17
18qrcode = cv2.imread('path_to_qrcode.png')
19qrcode = cv2.resize(255 - qrcode, (1024, 1024))
20
21image = pipe(
22 "Blooming chinese chrysanthemum, green leaves growing wantonly, flowers, Complex patterns on the border, Masterpiece Art, Beauty, 8K, Unreal Engine",
23 Image.fromarray(qrcode),
24 generator=generator,
25 num_inference_steps=37,
26 guidance_scale=7,
27 controlnet_conditioning_scale=1.85
28).images[0]

