YiftachEde commited on
Commit
d7e594b
·
verified ·
1 Parent(s): 1908f03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -16
app.py CHANGED
@@ -312,6 +312,7 @@ class ShapERenderer:
312
  self.diffusion = diffusion_from_config(load_config('diffusion'))
313
  print("Shap-E models initialized!")
314
 
 
315
  def generate_views(self, prompt, guidance_scale=15.0, num_steps=64):
316
  try:
317
  torch.cuda.empty_cache() # Clear GPU memory before generation
@@ -322,22 +323,22 @@ class ShapERenderer:
322
 
323
  with torch.amp.autocast('cuda'): # Use automatic mixed precision
324
  # spaces duration is 20 seconds, so we need to be careful here
325
- with spaces.GPU(duration=20):
326
- latents = sample_latents(
327
- batch_size=batch_size,
328
- model=self.model,
329
- diffusion=self.diffusion,
330
- guidance_scale=guidance_scale,
331
- model_kwargs=dict(texts=[prompt] * batch_size),
332
- progress=True,
333
- clip_denoised=True,
334
- use_fp16=True,
335
- use_karras=True,
336
- karras_steps=num_steps,
337
- sigma_min=1e-3,
338
- sigma_max=160,
339
- s_churn=0,
340
- )
341
 
342
  # Render the 6 views we need with specific viewing angles
343
  size = 320 # Size of each rendered image
 
312
  self.diffusion = diffusion_from_config(load_config('diffusion'))
313
  print("Shap-E models initialized!")
314
 
315
+ @spaces.GPU(duration=80)
316
  def generate_views(self, prompt, guidance_scale=15.0, num_steps=64):
317
  try:
318
  torch.cuda.empty_cache() # Clear GPU memory before generation
 
323
 
324
  with torch.amp.autocast('cuda'): # Use automatic mixed precision
325
  # spaces duration is 20 seconds, so we need to be careful here
326
+
327
+ latents = sample_latents(
328
+ batch_size=batch_size,
329
+ model=self.model,
330
+ diffusion=self.diffusion,
331
+ guidance_scale=guidance_scale,
332
+ model_kwargs=dict(texts=[prompt] * batch_size),
333
+ progress=True,
334
+ clip_denoised=True,
335
+ use_fp16=True,
336
+ use_karras=True,
337
+ karras_steps=num_steps,
338
+ sigma_min=1e-3,
339
+ sigma_max=160,
340
+ s_churn=0,
341
+ )
342
 
343
  # Render the 6 views we need with specific viewing angles
344
  size = 320 # Size of each rendered image