Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -162,13 +162,10 @@ GPU_DURATION_OPTIONS = {
|
|
162 |
"Long (140s)": 140,
|
163 |
}
|
164 |
|
165 |
-
#
|
166 |
-
|
167 |
|
168 |
-
#
|
169 |
-
os.environ["GPU_DURATION"] = str(GPU_DURATION_OPTIONS[DEFAULT_DURATION_CHOICE])
|
170 |
-
|
171 |
-
@spaces.GPU(duration=int(os.getenv("GPU_DURATION"))) # Dynamic duration
|
172 |
def generate(
|
173 |
model_choice: str,
|
174 |
prompt: str,
|
@@ -273,7 +270,7 @@ def generate_cpu(
|
|
273 |
return image_paths, seed
|
274 |
|
275 |
def set_gpu_duration(duration_choice):
|
276 |
-
|
277 |
|
278 |
def load_predefined_images1():
|
279 |
predefined_images1 = [
|
@@ -327,13 +324,18 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
327 |
)
|
328 |
|
329 |
with gr.Accordion("Advanced options", open=False, visible=True):
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
|
|
|
|
|
|
|
|
|
|
334 |
)
|
335 |
|
336 |
-
|
337 |
|
338 |
style_selection = gr.Radio(
|
339 |
show_label=True,
|
|
|
162 |
"Long (140s)": 140,
|
163 |
}
|
164 |
|
165 |
+
# Initialize Gradio state
|
166 |
+
gpu_duration_state = gr.State(60) # Initial value
|
167 |
|
168 |
+
@spaces.GPU(duration=gpu_duration_state.value) # Access state value
|
|
|
|
|
|
|
169 |
def generate(
|
170 |
model_choice: str,
|
171 |
prompt: str,
|
|
|
270 |
return image_paths, seed
|
271 |
|
272 |
def set_gpu_duration(duration_choice):
|
273 |
+
return GPU_DURATION_OPTIONS[duration_choice] # Update state
|
274 |
|
275 |
def load_predefined_images1():
|
276 |
predefined_images1 = [
|
|
|
324 |
)
|
325 |
|
326 |
with gr.Accordion("Advanced options", open=False, visible=True):
|
327 |
+
duration_dropdown = gr.Dropdown(
|
328 |
+
choices=[
|
329 |
+
"Short (25s)",
|
330 |
+
"Short (45s)",
|
331 |
+
"Medium (60s)",
|
332 |
+
"Medium (80s)",
|
333 |
+
"Long (100s)",
|
334 |
+
"Long (120s)",
|
335 |
+
"Long (140s)",
|
336 |
)
|
337 |
|
338 |
+
duration_dropdown.change(set_gpu_duration, inputs=duration_dropdown, outputs=gpu_duration_state)
|
339 |
|
340 |
style_selection = gr.Radio(
|
341 |
show_label=True,
|