ford442 commited on
Commit
e7981bf
·
1 Parent(s): 9a2fe8f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -162,7 +162,13 @@ GPU_DURATION_OPTIONS = {
162
  "Long (140s)": 140,
163
  }
164
 
165
- @spaces.GPU(duration=int(os.getenv("GPU_DURATION", "0"))) # Dynamic duration
 
 
 
 
 
 
166
  def generate(
167
  model_choice: str,
168
  prompt: str,
@@ -237,7 +243,7 @@ def generate_cpu(
237
  pipe.to("cpu")
238
 
239
  seed = int(randomize_seed_fn(seed, randomize_seed))
240
- generator = torch.Generator(device='cuda').manual_seed(seed)
241
 
242
  prompt, negative_prompt = apply_style(style_selection, prompt, negative_prompt)
243
 
 
162
  "Long (140s)": 140,
163
  }
164
 
165
+ # Set the default GPU duration here
166
+ DEFAULT_DURATION_CHOICE = "Medium (60s)"
167
+
168
+ # Set the GPU duration environment variable
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,
 
243
  pipe.to("cpu")
244
 
245
  seed = int(randomize_seed_fn(seed, randomize_seed))
246
+ generator = torch.Generator(device='cpu').manual_seed(seed) # cpu function seed
247
 
248
  prompt, negative_prompt = apply_style(style_selection, prompt, negative_prompt)
249