updated
Browse files
app.py
CHANGED
|
@@ -40,7 +40,8 @@ from diffusers import StableDiffusionImg2ImgPipeline
|
|
| 40 |
# Load Stable Diffusion 2.1 img2img model
|
| 41 |
model_id = "stabilityai/stable-diffusion-2-1"
|
| 42 |
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
|
| 43 |
-
pipe.to("cpu") # Change to "cuda" for GPU
|
|
|
|
| 44 |
|
| 45 |
# Enable CPU optimizations
|
| 46 |
pipe.enable_attention_slicing()
|
|
|
|
| 40 |
# Load Stable Diffusion 2.1 img2img model
|
| 41 |
model_id = "stabilityai/stable-diffusion-2-1"
|
| 42 |
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
|
| 43 |
+
# pipe.to("cpu") # Change to "cuda" for GPU
|
| 44 |
+
pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
| 45 |
|
| 46 |
# Enable CPU optimizations
|
| 47 |
pipe.enable_attention_slicing()
|