Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -75,7 +75,7 @@ def load_models_on_launch():
|
|
75 |
loaded_controlnet = ControlNetModel.from_pretrained(
|
76 |
controlnet_path,
|
77 |
torch_dtype=torch.float16
|
78 |
-
).to("
|
79 |
|
80 |
diffusion_path = snapshot_download(DIFFUSION_MODELS["GhostMix"])
|
81 |
loaded_pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
@@ -83,7 +83,7 @@ def load_models_on_launch():
|
|
83 |
controlnet=loaded_controlnet,
|
84 |
torch_dtype=torch.float16,
|
85 |
safety_checker=None,
|
86 |
-
).to("
|
87 |
print("Models loaded successfully!")
|
88 |
|
89 |
# Modify the load_models function to use global variables
|
@@ -234,7 +234,7 @@ def inference(
|
|
234 |
if count_tokens(prompt) > MAX_TOKENS:
|
235 |
raise gr.Error(f"Prompt exceeds the maximum allowed tokens of {MAX_TOKENS}")
|
236 |
|
237 |
-
if
|
238 |
raise gr.Error(f"Negative prompt exceeds the maximum allowed tokens of {MAX_TOKENS}")
|
239 |
|
240 |
pipe.scheduler = SAMPLER_MAP[sampler](pipe.scheduler.config)
|
@@ -243,7 +243,7 @@ def inference(
|
|
243 |
seed = torch.seed() # Generate a truly random seed
|
244 |
generator = torch.manual_seed(seed)
|
245 |
|
246 |
-
if qr_code_content != "" or
|
247 |
print("Generating QR Code from content")
|
248 |
qr = qrcode.QRCode(
|
249 |
version=1,
|
@@ -256,11 +256,9 @@ def inference(
|
|
256 |
|
257 |
qrcode_image = qr.make_image(fill_color=qr_color, back_color=bg_color)
|
258 |
qrcode_image = resize_for_condition_image(qrcode_image, 1024)
|
259 |
-
|
260 |
print("Using QR Code Image")
|
261 |
qrcode_image = resize_for_condition_image(qrcode_image, 1024)
|
262 |
-
else:
|
263 |
-
raise gr.Error("No valid QR code content or image provided")
|
264 |
|
265 |
# Determine which image to use as init_image and control_image
|
266 |
if use_qr_code_as_init_image:
|
@@ -370,8 +368,8 @@ with gr.Blocks(theme='Hev832/Applio', css=css, fill_width=True, fill_height=True
|
|
370 |

|
371 |
# 🎨 Yamamoto QR Code Art Generator
|
372 |
## Transform Your QR Codes into Brand Masterpieces
|
373 |
-
|
374 |
-
|
375 |
## 🚀 How It Works:
|
376 |
1. **Enter Your QR Code Content**: Start by inputting the URL or text for your QR code.
|
377 |
2. **Craft Your Prompt**: Describe the artistic style or theme you envision for your QR code.
|
|
|
75 |
loaded_controlnet = ControlNetModel.from_pretrained(
|
76 |
controlnet_path,
|
77 |
torch_dtype=torch.float16
|
78 |
+
).to("cuda")
|
79 |
|
80 |
diffusion_path = snapshot_download(DIFFUSION_MODELS["GhostMix"])
|
81 |
loaded_pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
|
|
83 |
controlnet=loaded_controlnet,
|
84 |
torch_dtype=torch.float16,
|
85 |
safety_checker=None,
|
86 |
+
).to("cuda")
|
87 |
print("Models loaded successfully!")
|
88 |
|
89 |
# Modify the load_models function to use global variables
|
|
|
234 |
if count_tokens(prompt) > MAX_TOKENS:
|
235 |
raise gr.Error(f"Prompt exceeds the maximum allowed tokens of {MAX_TOKENS}")
|
236 |
|
237 |
+
if count_tokens(negative_prompt) > MAX_TOKENS:
|
238 |
raise gr.Error(f"Negative prompt exceeds the maximum allowed tokens of {MAX_TOKENS}")
|
239 |
|
240 |
pipe.scheduler = SAMPLER_MAP[sampler](pipe.scheduler.config)
|
|
|
243 |
seed = torch.seed() # Generate a truly random seed
|
244 |
generator = torch.manual_seed(seed)
|
245 |
|
246 |
+
if qr_code_content != "" or qrcode_image.size == (1, 1):
|
247 |
print("Generating QR Code from content")
|
248 |
qr = qrcode.QRCode(
|
249 |
version=1,
|
|
|
256 |
|
257 |
qrcode_image = qr.make_image(fill_color=qr_color, back_color=bg_color)
|
258 |
qrcode_image = resize_for_condition_image(qrcode_image, 1024)
|
259 |
+
else:
|
260 |
print("Using QR Code Image")
|
261 |
qrcode_image = resize_for_condition_image(qrcode_image, 1024)
|
|
|
|
|
262 |
|
263 |
# Determine which image to use as init_image and control_image
|
264 |
if use_qr_code_as_init_image:
|
|
|
368 |

|
369 |
# 🎨 Yamamoto QR Code Art Generator
|
370 |
## Transform Your QR Codes into Brand Masterpieces
|
371 |
+
This cutting-edge tool empowers our creative team to craft visually stunning,<br>
|
372 |
+
on-brand QR codes that perfectly blend functionality with artistic expression.
|
373 |
## 🚀 How It Works:
|
374 |
1. **Enter Your QR Code Content**: Start by inputting the URL or text for your QR code.
|
375 |
2. **Craft Your Prompt**: Describe the artistic style or theme you envision for your QR code.
|