Commit ·
788dc63
1
Parent(s): 4cc7b30
Initial Commit
Browse files
app.py
CHANGED
|
@@ -5,8 +5,11 @@ from diffusers import StableDiffusionPipeline
|
|
| 5 |
model_name = "runwayml/stable-diffusion-v1-5"
|
| 6 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 7 |
|
| 8 |
-
|
| 9 |
-
pipe =
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
def generate_image(prompt):
|
| 12 |
with torch.no_grad():
|
|
|
|
| 5 |
model_name = "runwayml/stable-diffusion-v1-5"
|
| 6 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 7 |
|
| 8 |
+
if device == "cuda":
|
| 9 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_name, torch_dtype=torch.float16)
|
| 10 |
+
pipe = pipe.to(device)
|
| 11 |
+
else:
|
| 12 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_name).to(device)
|
| 13 |
|
| 14 |
def generate_image(prompt):
|
| 15 |
with torch.no_grad():
|