Spaces:
Runtime error
Runtime error
Commit
·
76d3903
1
Parent(s):
48b3618
add more
Browse files
app.py
CHANGED
@@ -75,7 +75,7 @@ def infer(prompt: str, negative: str, width: int, height: int, sampler: str,
|
|
75 |
client_ip = request.client.host
|
76 |
if client_ip != '127.0.0.1' and client_ip != 'localhost' and client_ip != '0.0.0.0':
|
77 |
if time_client_map.get(client_ip):
|
78 |
-
return "Too many requests
|
79 |
else:
|
80 |
time_client_map.put(client_ip, 1, 10) # 添加一个过期时间为 10 秒的项
|
81 |
|
@@ -85,7 +85,7 @@ def infer(prompt: str, negative: str, width: int, height: int, sampler: str,
|
|
85 |
|
86 |
count += 1
|
87 |
if count > 5:
|
88 |
-
return "Too many requests
|
89 |
else:
|
90 |
count_client_map.put(client_ip, count, 24 * 60 * 60) # 添加一个过期时间为 24 小时的项
|
91 |
|
@@ -165,7 +165,7 @@ def infer(prompt: str, negative: str, width: int, height: int, sampler: str,
|
|
165 |
|
166 |
images.append(output[0])
|
167 |
|
168 |
-
return images
|
169 |
|
170 |
|
171 |
css = """
|
@@ -467,7 +467,7 @@ with block:
|
|
467 |
# samples = gr.Slider(label="Images", minimum=1, maximum=4, value=4, step=1)
|
468 |
# steps = gr.Slider(label="Steps", minimum=1, maximum=50, value=45, step=1)
|
469 |
guidance_scale = gr.Slider(
|
470 |
-
label="Guidance Scale", minimum=0, maximum=
|
471 |
)
|
472 |
|
473 |
with gr.Row(elem_id="generate-container", elem_classes="generate-container").style(height="100"):
|
@@ -481,6 +481,8 @@ with block:
|
|
481 |
label="Generated images", show_label=False, elem_id="gallery"
|
482 |
).style()
|
483 |
|
|
|
|
|
484 |
# with gr.Group(elem_id="container-advanced-btns"):
|
485 |
# # advanced_button = gr.Button("Advanced options", elem_id="advanced-btn")
|
486 |
# with gr.Group(elem_id="share-btn-container"):
|
@@ -490,16 +492,16 @@ with block:
|
|
490 |
|
491 |
ex = gr.Examples(examples=examples, fn=infer,
|
492 |
inputs=[text, negative, width, height, sampler, steps, seed, guidance_scale],
|
493 |
-
outputs=[gallery],
|
494 |
examples_per_page=5,
|
495 |
cache_examples=False)
|
496 |
ex.dataset.headers = [""]
|
497 |
negative.submit(infer, inputs=[text, negative, width, height, sampler, steps, seed, guidance_scale],
|
498 |
-
outputs=[gallery], postprocess=False)
|
499 |
text.submit(infer, inputs=[text, negative, width, height, sampler, steps, seed, guidance_scale],
|
500 |
-
outputs=[gallery], postprocess=False)
|
501 |
btn.click(infer, inputs=[text, negative, width, height, sampler, steps, seed, guidance_scale],
|
502 |
-
outputs=[gallery], postprocess=False)
|
503 |
|
504 |
block.queue(concurrency_count=5,
|
505 |
max_size=100).launch(
|
|
|
75 |
client_ip = request.client.host
|
76 |
if client_ip != '127.0.0.1' and client_ip != 'localhost' and client_ip != '0.0.0.0':
|
77 |
if time_client_map.get(client_ip):
|
78 |
+
return None, "Too many requests, please try again later."
|
79 |
else:
|
80 |
time_client_map.put(client_ip, 1, 10) # 添加一个过期时间为 10 秒的项
|
81 |
|
|
|
85 |
|
86 |
count += 1
|
87 |
if count > 5:
|
88 |
+
return None, "Too many requests, please try again later."
|
89 |
else:
|
90 |
count_client_map.put(client_ip, count, 24 * 60 * 60) # 添加一个过期时间为 24 小时的项
|
91 |
|
|
|
165 |
|
166 |
images.append(output[0])
|
167 |
|
168 |
+
return images, ""
|
169 |
|
170 |
|
171 |
css = """
|
|
|
467 |
# samples = gr.Slider(label="Images", minimum=1, maximum=4, value=4, step=1)
|
468 |
# steps = gr.Slider(label="Steps", minimum=1, maximum=50, value=45, step=1)
|
469 |
guidance_scale = gr.Slider(
|
470 |
+
label="Guidance Scale", minimum=0, maximum=40, value=9, step=0.1
|
471 |
)
|
472 |
|
473 |
with gr.Row(elem_id="generate-container", elem_classes="generate-container").style(height="100"):
|
|
|
481 |
label="Generated images", show_label=False, elem_id="gallery"
|
482 |
).style()
|
483 |
|
484 |
+
result = gr.Textbox(label="Run Status")
|
485 |
+
|
486 |
# with gr.Group(elem_id="container-advanced-btns"):
|
487 |
# # advanced_button = gr.Button("Advanced options", elem_id="advanced-btn")
|
488 |
# with gr.Group(elem_id="share-btn-container"):
|
|
|
492 |
|
493 |
ex = gr.Examples(examples=examples, fn=infer,
|
494 |
inputs=[text, negative, width, height, sampler, steps, seed, guidance_scale],
|
495 |
+
outputs=[gallery, result],
|
496 |
examples_per_page=5,
|
497 |
cache_examples=False)
|
498 |
ex.dataset.headers = [""]
|
499 |
negative.submit(infer, inputs=[text, negative, width, height, sampler, steps, seed, guidance_scale],
|
500 |
+
outputs=[gallery, result], postprocess=False)
|
501 |
text.submit(infer, inputs=[text, negative, width, height, sampler, steps, seed, guidance_scale],
|
502 |
+
outputs=[gallery, result], postprocess=False)
|
503 |
btn.click(infer, inputs=[text, negative, width, height, sampler, steps, seed, guidance_scale],
|
504 |
+
outputs=[gallery, result], postprocess=False)
|
505 |
|
506 |
block.queue(concurrency_count=5,
|
507 |
max_size=100).launch(
|