Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -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 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,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 qrcode_image.size == (1, 1):
|
247 |
print("Generating QR Code from content")
|
248 |
qr = qrcode.QRCode(
|
249 |
version=1,
|
@@ -256,9 +256,11 @@ 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 |
|
263 |
# Determine which image to use as init_image and control_image
|
264 |
if use_qr_code_as_init_image:
|
|
|
234 |
if count_tokens(prompt) > MAX_TOKENS:
|
235 |
raise gr.Error(f"Prompt exceeds the maximum allowed tokens of {MAX_TOKENS}")
|
236 |
|
237 |
+
if negative_prompt and 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 is not None and 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 |
+
elif qrcode_image is not None:
|
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:
|