ford442 commited on
Commit
b05433d
·
1 Parent(s): b1ad971

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -165,7 +165,16 @@ GPU_DURATION_OPTIONS = {
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,
 
165
  # Global variable to store GPU duration
166
  global_gpu_duration = 60 # Initial value
167
 
168
+ def gpu_with_dynamic_duration(func):
169
+ def wrapper(*args, **kwargs):
170
+ # Apply @spaces.GPU with the current global_gpu_duration
171
+ @spaces.GPU(duration=global_gpu_duration)
172
+ def inner(*args, **kwargs):
173
+ return func(*args, **kwargs)
174
+ return inner(*args, **kwargs)
175
+ return wrapper
176
+
177
+ @gpu_with_dynamic_duration
178
  def generate(
179
  model_choice: str,
180
  prompt: str,