codic commited on
Commit
bfdd2d5
·
verified ·
1 Parent(s): 1faff0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -8,6 +8,8 @@ import os
8
  from rembg import remove
9
  import open3d as o3d
10
  from skimage import filters
 
 
11
 
12
  # Handle GPU availability in Hugging Face Spaces with ZeroGPU
13
  if os.environ.get("SPACES_ZERO_GPU") is not None:
@@ -38,6 +40,12 @@ pipe.vae = diffusers.AutoencoderTiny.from_pretrained(
38
  "madebyollin/taesd", torch_dtype=torch.float16
39
  ).cuda()
40
 
 
 
 
 
 
 
41
  # Depth and surface normals prediction function
42
  @spaces.GPU(enable_queue=True)
43
  def predict_depth(image: Image.Image):
 
8
  from rembg import remove
9
  import open3d as o3d
10
  from skimage import filters
11
+ import xformers
12
+
13
 
14
  # Handle GPU availability in Hugging Face Spaces with ZeroGPU
15
  if os.environ.get("SPACES_ZERO_GPU") is not None:
 
40
  "madebyollin/taesd", torch_dtype=torch.float16
41
  ).cuda()
42
 
43
+ # Enable XFormers
44
+ try:
45
+ pipe.enable_xformers_memory_efficient_attention()
46
+ except:
47
+ pass # run without xformers
48
+
49
  # Depth and surface normals prediction function
50
  @spaces.GPU(enable_queue=True)
51
  def predict_depth(image: Image.Image):