Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -174,6 +174,13 @@ def invert_displayed_image(image):
|
|
| 174 |
return Image.fromarray(inverted)
|
| 175 |
return inverted
|
| 176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
@spaces.GPU()
|
| 178 |
def inference(
|
| 179 |
qr_code_content: str,
|
|
@@ -207,6 +214,13 @@ def inference(
|
|
| 207 |
if qrcode_image is None and qr_code_content == "":
|
| 208 |
raise gr.Error("QR Code Image or QR Code Content is required")
|
| 209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
pipe.scheduler = SAMPLER_MAP[sampler](pipe.scheduler.config)
|
| 211 |
|
| 212 |
if seed == -1:
|
|
@@ -265,7 +279,7 @@ def inference(
|
|
| 265 |
controlnet_conditioning_scale=float(controlnet_conditioning_scale),
|
| 266 |
generator=generator,
|
| 267 |
strength=float(strength),
|
| 268 |
-
num_inference_steps=
|
| 269 |
)
|
| 270 |
final_image = out.images[0] if final_image is None else final_image
|
| 271 |
|
|
@@ -354,7 +368,7 @@ with gr.Blocks(theme='Hev832/Applio', css=css) as blocks:
|
|
| 354 |
prompt = gr.Textbox(
|
| 355 |
label="Artistic Prompt",
|
| 356 |
placeholder="Describe the style or theme for your QR code art",
|
| 357 |
-
value="A high-
|
| 358 |
info="Be specific and creative! This guides the AI in creating your unique QR code art.",
|
| 359 |
)
|
| 360 |
negative_prompt = gr.Textbox(
|
|
|
|
| 174 |
return Image.fromarray(inverted)
|
| 175 |
return inverted
|
| 176 |
|
| 177 |
+
|
| 178 |
+
MAX_TOKENS = 100
|
| 179 |
+
|
| 180 |
+
def count_tokens(text):
|
| 181 |
+
"""Count the number of tokens in the text."""
|
| 182 |
+
return len(text.split())
|
| 183 |
+
|
| 184 |
@spaces.GPU()
|
| 185 |
def inference(
|
| 186 |
qr_code_content: str,
|
|
|
|
| 214 |
if qrcode_image is None and qr_code_content == "":
|
| 215 |
raise gr.Error("QR Code Image or QR Code Content is required")
|
| 216 |
|
| 217 |
+
# Validate the length of the prompt
|
| 218 |
+
if count_tokens(prompt) > MAX_TOKENS:
|
| 219 |
+
raise gr.Error(f"Prompt exceeds the maximum allowed tokens of {MAX_TOKENS}")
|
| 220 |
+
|
| 221 |
+
if count_tokens(negative_prompt) > MAX_TOKENS:
|
| 222 |
+
raise gr.Error(f"Negative prompt exceeds the maximum allowed tokens of {MAX_TOKENS}")
|
| 223 |
+
|
| 224 |
pipe.scheduler = SAMPLER_MAP[sampler](pipe.scheduler.config)
|
| 225 |
|
| 226 |
if seed == -1:
|
|
|
|
| 279 |
controlnet_conditioning_scale=float(controlnet_conditioning_scale),
|
| 280 |
generator=generator,
|
| 281 |
strength=float(strength),
|
| 282 |
+
num_inference_steps=100,
|
| 283 |
)
|
| 284 |
final_image = out.images[0] if final_image is None else final_image
|
| 285 |
|
|
|
|
| 368 |
prompt = gr.Textbox(
|
| 369 |
label="Artistic Prompt",
|
| 370 |
placeholder="Describe the style or theme for your QR code art",
|
| 371 |
+
value="A high-res, photo-realistic minimalist rendering of Mount Fuji as a sharp, semi-realistic silhouette on the horizon. The mountain conveys strength and motion with clean, crisp lines and natural flow. Features detailed snow textures, subtle ridge highlights, and a powerful yet serene atmosphere. Emphasizes strength with clarity and precision in texture and light. (Sharp outlines:1.5), (Photo-realistic:1.4), (Detailed textures:1.3), (Minimalist:1.3), (Semi-realistic:1.3), (Monochrome contrast:1.2), (Crisp detail:1.2), (Evoking strength:1.2). Inspired by traditional Japanese woodblock prints, nature photography, and minimalist design principles.",
|
| 372 |
info="Be specific and creative! This guides the AI in creating your unique QR code art.",
|
| 373 |
)
|
| 374 |
negative_prompt = gr.Textbox(
|