estellea commited on
Commit
016532e
1 Parent(s): 864964a

Update app_main.py

Browse files
Files changed (1) hide show
  1. app_main.py +9 -12
app_main.py CHANGED
@@ -1,4 +1,4 @@
1
- from diffusers import StableDiffusionLDM3DPipeline
2
  import gradio as gr
3
  import torch
4
  from PIL import Image
@@ -8,19 +8,16 @@ from tempfile import NamedTemporaryFile
8
  from pathlib import Path
9
 
10
  Path("tmp").mkdir(exist_ok=True)
11
- device = "cuda" if torch.cuda.is_available() else "cpu"
12
  print(f"Device is {device}")
13
- torch_type = torch.float16 if device == "cuda" else torch.float32
14
- pipe = StableDiffusionLDM3DPipeline.from_pretrained(
15
- "Intel/ldm3d-pano",
16
- torch_dtype=torch_type
17
- # , safety_checker=None
18
- )
 
19
  pipe.to(device)
20
- if device == "cuda":
21
- pipe.enable_xformers_memory_efficient_attention()
22
- pipe.enable_model_cpu_offload()
23
-
24
 
25
  def get_iframe(rgb_path: str, depth_path: str, viewer_mode: str = "6DOF"):
26
  # buffered = BytesIO()
 
1
+ from optimum.habana.diffusers import GaudiDDIMScheduler, GaudiStableDiffusionLDM3DPipeline
2
  import gradio as gr
3
  import torch
4
  from PIL import Image
 
8
  from pathlib import Path
9
 
10
  Path("tmp").mkdir(exist_ok=True)
11
+ device = "hpu"
12
  print(f"Device is {device}")
13
+ model_name = "Intel/ldm3d-pano"
14
+ scheduler = GaudiDDIMScheduler.from_pretrained(model_name, subfolder="scheduler")
15
+ pipe = GaudiStableDiffusionLDM3DPipeline.from_pretrained( model_name,
16
+ scheduler=scheduler,
17
+ use_habana=True,
18
+ use_hpu_graphs=True,
19
+ gaudi_config="Habana/stable-diffusion")
20
  pipe.to(device)
 
 
 
 
21
 
22
  def get_iframe(rgb_path: str, depth_path: str, viewer_mode: str = "6DOF"):
23
  # buffered = BytesIO()