-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ai.py
40 lines (33 loc) · 1.08 KB
/
Ai.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import qrcode
import torch
from PIL import Image # Corrected PIL import
import qrcode as qr
from transformers import ControlNetModel, StableDiffusionControlNetPipeline # Corrected imports
controlnet = ControlNetModel.from_pretrained(
"DionTimmer/controlnet_qrcode-control_v1p_sd15", # Removed the full URL
torch_dtype=torch.float16,
)
pipe = StableDiffusionControlNetPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5",
controlnet=controlnet,
torch_dtype=torch.float16,
safety_checker=None,
).to("cuda")
pipe.enable_xformers_memory_efficient_attention()
def genqrcode():
qr_code = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_H,
box_size=16,
border=0,
)
qr.add_data(content)
qr.make(fit=True)
img=qr.make_image(fill_color="Black",black_color="white")
offset=8*16
w,h=img.size
w=(w+225+offset)//256*256
h = (h + 225 + offset) // 256 * 256
if w>1024:
raise
genqrcode("https://www.linkedin.com/in/chetan-gudditi-922b38272/")