muhammadsalmanalfaridzi commited on
Commit
cd57dbe
β€’
1 Parent(s): ac9d9df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -15,9 +15,11 @@ import torch
15
 
16
  # Load Stable Diffusion Model
17
  def load_stable_diffusion_model():
18
- pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1", torch_dtype=torch.float32)
19
- pipe = pipe.to("cpu")
 
20
 
 
21
  sd_model = load_stable_diffusion_model()
22
 
23
  def remove_background_stable_diffusion(image_path):
 
15
 
16
  # Load Stable Diffusion Model
17
  def load_stable_diffusion_model():
18
+ device = "cuda" if torch.cuda.is_available() else "cpu"
19
+ pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1", torch_dtype=torch.float32).to(device)
20
+ return pipe
21
 
22
+ # Initialize the model globally
23
  sd_model = load_stable_diffusion_model()
24
 
25
  def remove_background_stable_diffusion(image_path):