muhammadsalmanalfaridzi commited on
Commit
fbc475b
β€’
1 Parent(s): b7c64e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -14,8 +14,11 @@ import json
14
  import torch
15
 
16
  # Load Stable Diffusion Model
17
- pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16)
18
- pipe = pipe.to("cuda") # Change to "cpu" if you don't have a GPU
 
 
 
19
 
20
  def remove_background_stable_diffusion(image_path):
21
  image = Image.open(image_path).convert("RGB")
 
14
  import torch
15
 
16
  # Load Stable Diffusion Model
17
+ def load_stable_diffusion_model():
18
+ device = "cuda" if torch.cuda.is_available() else "cpu"
19
+ return StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1", torch_dtype=torch.float32).to(device)
20
+
21
+ sd_model = load_stable_diffusion_model()
22
 
23
  def remove_background_stable_diffusion(image_path):
24
  image = Image.open(image_path).convert("RGB")