Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -162,19 +162,25 @@ GPU_DURATION_OPTIONS = {
|
|
162 |
"Long (140s)": 140,
|
163 |
}
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
def generate(
|
179 |
model_choice: str,
|
180 |
prompt: str,
|
@@ -322,8 +328,11 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
322 |
placeholder="Enter your prompt",
|
323 |
container=False,
|
324 |
)
|
325 |
-
|
326 |
cpu_run_button = gr.Button("CPU Run", scale=0)
|
|
|
|
|
|
|
327 |
result = gr.Gallery(label="Result", columns=1, show_label=False)
|
328 |
|
329 |
with gr.Row():
|
@@ -422,12 +431,56 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
422 |
|
423 |
gr.on(
|
424 |
triggers=[
|
425 |
-
|
426 |
-
|
427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
428 |
],
|
429 |
-
|
430 |
-
fn=
|
431 |
inputs=[
|
432 |
model_choice,
|
433 |
prompt,
|
@@ -447,10 +500,10 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
447 |
|
448 |
gr.on(
|
449 |
triggers=[
|
450 |
-
|
451 |
],
|
452 |
-
|
453 |
-
fn=
|
454 |
inputs=[
|
455 |
model_choice,
|
456 |
prompt,
|
|
|
162 |
"Long (140s)": 140,
|
163 |
}
|
164 |
|
165 |
+
def set_gpu_duration(duration_choice):
|
166 |
+
os.environ["GPU_DURATION"] = str(GPU_DURATION_OPTIONS[duration_choice])
|
167 |
+
|
168 |
+
@gpu_with_duration(duration=45)
|
169 |
+
def generate_45s(*args, **kwargs):
|
170 |
+
return generate(*args, **kwargs) # Call the common generate function
|
171 |
+
|
172 |
+
@gpu_with_duration(duration=60)
|
173 |
+
def generate_60s(*args, **kwargs):
|
174 |
+
return generate(*args, **kwargs)
|
175 |
+
|
176 |
+
@gpu_with_duration(duration=80)
|
177 |
+
def generate_80s(*args, **kwargs):
|
178 |
+
return generate(*args, **kwargs)
|
179 |
+
|
180 |
+
@gpu_with_duration(duration=100)
|
181 |
+
def generate_100s(*args, **kwargs):
|
182 |
+
return generate(*args, **kwargs)
|
183 |
+
|
184 |
def generate(
|
185 |
model_choice: str,
|
186 |
prompt: str,
|
|
|
328 |
placeholder="Enter your prompt",
|
329 |
container=False,
|
330 |
)
|
331 |
+
run_button_45 = gr.Button("Run_45", scale=0)
|
332 |
cpu_run_button = gr.Button("CPU Run", scale=0)
|
333 |
+
run_button_60 = gr.Button("Run_60", scale=0)
|
334 |
+
run_button_80 = gr.Button("Run_80", scale=0)
|
335 |
+
run_button_100 = gr.Button("Run_100", scale=0)
|
336 |
result = gr.Gallery(label="Result", columns=1, show_label=False)
|
337 |
|
338 |
with gr.Row():
|
|
|
431 |
|
432 |
gr.on(
|
433 |
triggers=[
|
434 |
+
run_button_100.click,
|
435 |
+
],
|
436 |
+
# api_name="generate", # Add this line
|
437 |
+
fn=generate_100s,
|
438 |
+
inputs=[
|
439 |
+
model_choice,
|
440 |
+
prompt,
|
441 |
+
negative_prompt,
|
442 |
+
use_negative_prompt,
|
443 |
+
style_selection,
|
444 |
+
seed,
|
445 |
+
width,
|
446 |
+
height,
|
447 |
+
guidance_scale,
|
448 |
+
num_inference_steps,
|
449 |
+
randomize_seed,
|
450 |
+
num_images,
|
451 |
+
],
|
452 |
+
outputs=[result, seed],
|
453 |
+
)
|
454 |
+
|
455 |
+
gr.on(
|
456 |
+
triggers=[
|
457 |
+
run_button_80.click,
|
458 |
+
],
|
459 |
+
# api_name="generate", # Add this line
|
460 |
+
fn=generate_80s,
|
461 |
+
inputs=[
|
462 |
+
model_choice,
|
463 |
+
prompt,
|
464 |
+
negative_prompt,
|
465 |
+
use_negative_prompt,
|
466 |
+
style_selection,
|
467 |
+
seed,
|
468 |
+
width,
|
469 |
+
height,
|
470 |
+
guidance_scale,
|
471 |
+
num_inference_steps,
|
472 |
+
randomize_seed,
|
473 |
+
num_images,
|
474 |
+
],
|
475 |
+
outputs=[result, seed],
|
476 |
+
)
|
477 |
+
|
478 |
+
gr.on(
|
479 |
+
triggers=[
|
480 |
+
run_button_60.click,
|
481 |
],
|
482 |
+
# api_name="generate", # Add this line
|
483 |
+
fn=generate_60s,
|
484 |
inputs=[
|
485 |
model_choice,
|
486 |
prompt,
|
|
|
500 |
|
501 |
gr.on(
|
502 |
triggers=[
|
503 |
+
run_button_45.click,
|
504 |
],
|
505 |
+
# api_name="generate", # Add this line
|
506 |
+
fn=generate_45s,
|
507 |
inputs=[
|
508 |
model_choice,
|
509 |
prompt,
|