Manireddy1508 commited on
Commit
64855f6
·
verified ·
1 Parent(s): 2aa608d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -13,8 +13,9 @@ from utils.planner import (
13
  # ----------------------------
14
  # 🖥️ Device Setup
15
  # ----------------------------
16
- device = "cuda" if torch.cuda.is_available() else "cpu"
17
- dtype = torch.float16 if device == "cuda" else torch.float32
 
18
 
19
  # ----------------------------
20
  # 🧠 Load SDXL Img2Img Pipeline (no ControlNet)
@@ -22,7 +23,7 @@ dtype = torch.float16 if device == "cuda" else torch.float32
22
  pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(
23
  "stabilityai/stable-diffusion-xl-base-1.0",
24
  torch_dtype=dtype,
25
- variant="fp16" if device == "cuda" else None,
26
  use_safetensors=True,
27
  )
28
  pipe.to(device)
@@ -94,3 +95,4 @@ demo = gr.Interface(
94
  if __name__ == "__main__":
95
  demo.launch()
96
 
 
 
13
  # ----------------------------
14
  # 🖥️ Device Setup
15
  # ----------------------------
16
+ use_gpu = torch.cuda.is_available()
17
+ device = "cuda" if use_gpu else "cpu"
18
+ dtype = torch.float16 if use_gpu else torch.float32
19
 
20
  # ----------------------------
21
  # 🧠 Load SDXL Img2Img Pipeline (no ControlNet)
 
23
  pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(
24
  "stabilityai/stable-diffusion-xl-base-1.0",
25
  torch_dtype=dtype,
26
+ variant="fp16" if use_gpu else None,
27
  use_safetensors=True,
28
  )
29
  pipe.to(device)
 
95
  if __name__ == "__main__":
96
  demo.launch()
97
 
98
+