muhammadsalmanalfaridzi
commited on
Commit
β’
cd57dbe
1
Parent(s):
ac9d9df
Update app.py
Browse files
app.py
CHANGED
@@ -15,9 +15,11 @@ import torch
|
|
15 |
|
16 |
# Load Stable Diffusion Model
|
17 |
def load_stable_diffusion_model():
|
18 |
-
|
19 |
-
pipe =
|
|
|
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):
|