Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,13 +7,14 @@ import cv2
|
|
7 |
from PIL import Image
|
8 |
import time
|
9 |
|
|
|
10 |
# Load models from Hugging Face
|
11 |
sd_model_id = "bhoomikagp/sd2-interior-model-version2" ## test
|
12 |
# sd_model_id = "bhoomikagp/sd3-interior-model" ## SD3 model issue loading
|
13 |
controlnet_model_id = "lllyasviel/sd-controlnet-mlsd"
|
14 |
# Load Stable Diffusion pipeline CUDA
|
15 |
scheduler = EulerDiscreteScheduler.from_pretrained(sd_model_id, subfolder="scheduler")
|
16 |
-
sd_pipeline = StableDiffusionPipeline.from_pretrained(sd_model_id, torch_dtype=torch.float16,scheduler=scheduler).to("cuda")
|
17 |
# Load ControlNet and Stable Diffusion ControlNet pipeline
|
18 |
controlnet = ControlNetModel.from_pretrained(controlnet_model_id, torch_dtype=torch.float16).to("cuda")
|
19 |
controlnet_pipeline = StableDiffusionControlNetPipeline.from_pretrained(
|
@@ -22,6 +23,21 @@ controlnet_pipeline = StableDiffusionControlNetPipeline.from_pretrained(
|
|
22 |
scheduler=scheduler,
|
23 |
torch_dtype=torch.float16
|
24 |
).to("cuda")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
# choices lists
|
27 |
option_choices = ["living_room", "bedroom", "kitchen"]
|
|
|
7 |
from PIL import Image
|
8 |
import time
|
9 |
|
10 |
+
"""
|
11 |
# Load models from Hugging Face
|
12 |
sd_model_id = "bhoomikagp/sd2-interior-model-version2" ## test
|
13 |
# sd_model_id = "bhoomikagp/sd3-interior-model" ## SD3 model issue loading
|
14 |
controlnet_model_id = "lllyasviel/sd-controlnet-mlsd"
|
15 |
# Load Stable Diffusion pipeline CUDA
|
16 |
scheduler = EulerDiscreteScheduler.from_pretrained(sd_model_id, subfolder="scheduler")
|
17 |
+
#sd_pipeline = StableDiffusionPipeline.from_pretrained(sd_model_id, torch_dtype=torch.float16,scheduler=scheduler).to("cuda")
|
18 |
# Load ControlNet and Stable Diffusion ControlNet pipeline
|
19 |
controlnet = ControlNetModel.from_pretrained(controlnet_model_id, torch_dtype=torch.float16).to("cuda")
|
20 |
controlnet_pipeline = StableDiffusionControlNetPipeline.from_pretrained(
|
|
|
23 |
scheduler=scheduler,
|
24 |
torch_dtype=torch.float16
|
25 |
).to("cuda")
|
26 |
+
"""
|
27 |
+
sd_model_id = "stabilityai/stable-diffusion-2-1"
|
28 |
+
scheduler = DPMSolverMultistepScheduler.from_pretrained(sd_model_id, subfolder="scheduler")
|
29 |
+
|
30 |
+
# Check if CUDA is available
|
31 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
32 |
+
print(f"Using device: {device}")
|
33 |
+
|
34 |
+
# Initialize the pipeline with appropriate device and dtype
|
35 |
+
torch_dtype = torch.float16 if device == "cuda" else torch.float32
|
36 |
+
sd_pipeline = StableDiffusionPipeline.from_pretrained(
|
37 |
+
sd_model_id,
|
38 |
+
torch_dtype=torch_dtype,
|
39 |
+
scheduler=scheduler
|
40 |
+
).to(device)
|
41 |
|
42 |
# choices lists
|
43 |
option_choices = ["living_room", "bedroom", "kitchen"]
|