Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -162,10 +162,10 @@ GPU_DURATION_OPTIONS = {
|
|
162 |
"Long (140s)": 140,
|
163 |
}
|
164 |
|
165 |
-
#
|
166 |
-
|
167 |
|
168 |
-
@spaces.GPU(duration=
|
169 |
def generate(
|
170 |
model_choice: str,
|
171 |
prompt: str,
|
@@ -270,7 +270,8 @@ def generate_cpu(
|
|
270 |
return image_paths, seed
|
271 |
|
272 |
def set_gpu_duration(duration_choice):
|
273 |
-
|
|
|
274 |
|
275 |
def load_predefined_images1():
|
276 |
predefined_images1 = [
|
@@ -324,19 +325,13 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
324 |
)
|
325 |
|
326 |
with gr.Accordion("Advanced options", open=False, visible=True):
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
"
|
331 |
-
"Medium (60s)",
|
332 |
-
"Medium (80s)",
|
333 |
-
"Long (100s)",
|
334 |
-
"Long (120s)",
|
335 |
-
"Long (140s)",
|
336 |
-
]
|
337 |
)
|
338 |
|
339 |
-
|
340 |
|
341 |
style_selection = gr.Radio(
|
342 |
show_label=True,
|
|
|
162 |
"Long (140s)": 140,
|
163 |
}
|
164 |
|
165 |
+
# Global variable to store GPU duration
|
166 |
+
global_gpu_duration = 60 # Initial value
|
167 |
|
168 |
+
@spaces.GPU(duration=global_gpu_duration)
|
169 |
def generate(
|
170 |
model_choice: str,
|
171 |
prompt: str,
|
|
|
270 |
return image_paths, seed
|
271 |
|
272 |
def set_gpu_duration(duration_choice):
|
273 |
+
global global_gpu_duration
|
274 |
+
global_gpu_duration = GPU_DURATION_OPTIONS[duration_choice]
|
275 |
|
276 |
def load_predefined_images1():
|
277 |
predefined_images1 = [
|
|
|
325 |
)
|
326 |
|
327 |
with gr.Accordion("Advanced options", open=False, visible=True):
|
328 |
+
gpu_duration = gr.Dropdown(
|
329 |
+
label="GPU Duration",
|
330 |
+
choices=list(GPU_DURATION_OPTIONS.keys()),
|
331 |
+
value="Medium (60s)" # Default value
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
)
|
333 |
|
334 |
+
gpu_duration.change(fn=set_gpu_duration, inputs=gpu_duration, outputs=[])
|
335 |
|
336 |
style_selection = gr.Radio(
|
337 |
show_label=True,
|