Spaces:
Paused
Paused
Commit
·
a2072c0
1
Parent(s):
82962fb
debug zerogpu
Browse files
model.py
CHANGED
@@ -42,7 +42,7 @@ class Model:
|
|
42 |
def __init__(
|
43 |
self, base_model_id: str = "stable-diffusion-v1-5/stable-diffusion-v1-5", task_name: str = "Canny"
|
44 |
) -> None:
|
45 |
-
self.device = torch.device("cuda
|
46 |
self.base_model_id = ""
|
47 |
self.task_name = ""
|
48 |
self.pipe = self.load_pipe(base_model_id, task_name)
|
@@ -62,9 +62,9 @@ class Model:
|
|
62 |
base_model_id, safety_checker=None, controlnet=controlnet, torch_dtype=torch.float16
|
63 |
)
|
64 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
|
|
65 |
if self.device.type == "cuda":
|
66 |
pipe.enable_xformers_memory_efficient_attention()
|
67 |
-
pipe.to(self.device)
|
68 |
torch.cuda.empty_cache()
|
69 |
gc.collect()
|
70 |
self.base_model_id = base_model_id
|
|
|
42 |
def __init__(
|
43 |
self, base_model_id: str = "stable-diffusion-v1-5/stable-diffusion-v1-5", task_name: str = "Canny"
|
44 |
) -> None:
|
45 |
+
self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
46 |
self.base_model_id = ""
|
47 |
self.task_name = ""
|
48 |
self.pipe = self.load_pipe(base_model_id, task_name)
|
|
|
62 |
base_model_id, safety_checker=None, controlnet=controlnet, torch_dtype=torch.float16
|
63 |
)
|
64 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
65 |
+
pipe.to(self.device)
|
66 |
if self.device.type == "cuda":
|
67 |
pipe.enable_xformers_memory_efficient_attention()
|
|
|
68 |
torch.cuda.empty_cache()
|
69 |
gc.collect()
|
70 |
self.base_model_id = base_model_id
|