Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,19 +2,18 @@ import streamlit as st
|
|
2 |
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler, AutoencoderKL
|
3 |
import torch
|
4 |
|
5 |
-
|
|
|
6 |
model_id = "sam749/Photon-v1"
|
7 |
-
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse", torch_dtype=torch.float16).to(
|
8 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
9 |
pipe.vae = vae
|
10 |
pipe.to("cuda")
|
11 |
|
12 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
13 |
|
14 |
-
# Streamlit interface
|
15 |
st.title("Text-to-Image Generator")
|
16 |
|
17 |
-
# Prompt inputs
|
18 |
prompt = st.text_input("Enter the prompt for the image:")
|
19 |
negative_prompt = "cartoon, painting, illustration, (worst quality, low quality, normal quality:2)"
|
20 |
|
|
|
2 |
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler, AutoencoderKL
|
3 |
import torch
|
4 |
|
5 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
6 |
+
|
7 |
model_id = "sam749/Photon-v1"
|
8 |
+
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse", torch_dtype=torch.float16 if device == "cuda" else torch.float32).to(device)
|
9 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16 if device == "cuda" else torch.float32)
|
10 |
pipe.vae = vae
|
11 |
pipe.to("cuda")
|
12 |
|
13 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
14 |
|
|
|
15 |
st.title("Text-to-Image Generator")
|
16 |
|
|
|
17 |
prompt = st.text_input("Enter the prompt for the image:")
|
18 |
negative_prompt = "cartoon, painting, illustration, (worst quality, low quality, normal quality:2)"
|
19 |
|