muhammadsalmanalfaridzi
commited on
Commit
β’
fbc475b
1
Parent(s):
b7c64e6
Update app.py
Browse files
app.py
CHANGED
@@ -14,8 +14,11 @@ import json
|
|
14 |
import torch
|
15 |
|
16 |
# Load Stable Diffusion Model
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
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")
|