HReynaud commited on
Commit
ca40f6b
·
1 Parent(s): dab5199

adjusted for zeroGPU

Browse files
Files changed (2) hide show
  1. demo.py +4 -3
  2. requirements.txt +2 -1
demo.py CHANGED
@@ -15,6 +15,7 @@ from PIL import Image, ImageOps
15
  from safetensors.torch import load_file
16
  from torch.nn import functional as F
17
  from torchdiffeq import odeint_adjoint as odeint
 
18
 
19
  from echoflow.common import instantiate_class_from_config, unscale_latents
20
  from echoflow.common.models import (
@@ -238,7 +239,7 @@ def preprocess_mask(mask):
238
  # Convert back to numpy array
239
  return np.array(mask_pil)
240
 
241
-
242
  def generate_latent_image(mask, class_selection, sampling_steps=50):
243
  """Generate a latent image based on mask, class selection, and sampling steps"""
244
 
@@ -300,7 +301,7 @@ def generate_latent_image(mask, class_selection, sampling_steps=50):
300
 
301
  return latent_image # B x C x H x W
302
 
303
-
304
  def decode_images(latents, vae):
305
  """Decode latent representations to pixel space using a VAE.
306
 
@@ -400,7 +401,7 @@ def check_privacy(latent_image_numpy, class_selection):
400
  f"✅ **Success:** Generated image passed privacy check (corr = {corr:.4f} / tau = {tau:.4f})",
401
  )
402
 
403
-
404
  def generate_animation(
405
  latent_image, ejection_fraction, sampling_steps=50, cfg_scale=1.0
406
  ):
 
15
  from safetensors.torch import load_file
16
  from torch.nn import functional as F
17
  from torchdiffeq import odeint_adjoint as odeint
18
+ import spaces
19
 
20
  from echoflow.common import instantiate_class_from_config, unscale_latents
21
  from echoflow.common.models import (
 
239
  # Convert back to numpy array
240
  return np.array(mask_pil)
241
 
242
+ @spaces.GPU
243
  def generate_latent_image(mask, class_selection, sampling_steps=50):
244
  """Generate a latent image based on mask, class selection, and sampling steps"""
245
 
 
301
 
302
  return latent_image # B x C x H x W
303
 
304
+ @spaces.GPU
305
  def decode_images(latents, vae):
306
  """Decode latent representations to pixel space using a VAE.
307
 
 
401
  f"✅ **Success:** Generated image passed privacy check (corr = {corr:.4f} / tau = {tau:.4f})",
402
  )
403
 
404
+ @spaces.GPU
405
  def generate_animation(
406
  latent_image, ejection_fraction, sampling_steps=50, cfg_scale=1.0
407
  ):
requirements.txt CHANGED
@@ -11,4 +11,5 @@ torch==2.2.2
11
  torchdiffeq==0.2.4
12
  xformers==0.0.25.post1
13
  timm==0.9.16
14
- accelerate==0.34.2
 
 
11
  torchdiffeq==0.2.4
12
  xformers==0.0.25.post1
13
  timm==0.9.16
14
+ accelerate==0.34.2
15
+ spaces==0.33.1