Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,18 @@
|
|
1 |
import streamlit as st
|
2 |
-
from diffusers import
|
3 |
import torch
|
4 |
from io import BytesIO
|
5 |
|
6 |
-
st.set_page_config(page_title="Dreamscape Visualizer (
|
7 |
-
st.title("π Dreamscape Visualizer
|
8 |
|
9 |
@st.cache_resource
|
10 |
def load_pipeline():
|
11 |
-
pipe =
|
12 |
-
"stabilityai/
|
13 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
14 |
-
variant="fp16" if torch.cuda.is_available() else None
|
|
|
15 |
)
|
16 |
pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
17 |
return pipe
|
@@ -33,20 +34,19 @@ if st.button("Generate Dream Image"):
|
|
33 |
if not prompt.strip():
|
34 |
st.warning("Please describe your dream first!")
|
35 |
else:
|
36 |
-
with st.spinner("
|
37 |
final_prompt = f"{prompt}, {style_modifiers[style]}"
|
38 |
-
result = pipe(prompt=final_prompt, guidance_scale=
|
39 |
image = result.images[0]
|
40 |
-
st.image(image, caption="β¨ Your Dream Visualized", use_column_width=True)
|
41 |
|
42 |
-
#
|
43 |
buf = BytesIO()
|
44 |
image.save(buf, format="PNG")
|
45 |
byte_im = buf.getvalue()
|
46 |
-
|
47 |
st.download_button(
|
48 |
label="π₯ Download Dream Image",
|
49 |
data=byte_im,
|
50 |
-
file_name="
|
51 |
mime="image/png"
|
52 |
)
|
|
|
1 |
import streamlit as st
|
2 |
+
from diffusers import StableDiffusionXLPipeline
|
3 |
import torch
|
4 |
from io import BytesIO
|
5 |
|
6 |
+
st.set_page_config(page_title="Dreamscape Visualizer (HD)")
|
7 |
+
st.title("π Dreamscape Visualizer β High Quality")
|
8 |
|
9 |
@st.cache_resource
|
10 |
def load_pipeline():
|
11 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(
|
12 |
+
"stabilityai/stable-diffusion-xl-base-1.0",
|
13 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
14 |
+
variant="fp16" if torch.cuda.is_available() else None,
|
15 |
+
use_safetensors=True
|
16 |
)
|
17 |
pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
18 |
return pipe
|
|
|
34 |
if not prompt.strip():
|
35 |
st.warning("Please describe your dream first!")
|
36 |
else:
|
37 |
+
with st.spinner("Generating your high-res dream..."):
|
38 |
final_prompt = f"{prompt}, {style_modifiers[style]}"
|
39 |
+
result = pipe(prompt=final_prompt, guidance_scale=7.5, num_inference_steps=30)
|
40 |
image = result.images[0]
|
41 |
+
st.image(image, caption="β¨ Your Dream Visualized in HD", use_column_width=True)
|
42 |
|
43 |
+
# Download Button
|
44 |
buf = BytesIO()
|
45 |
image.save(buf, format="PNG")
|
46 |
byte_im = buf.getvalue()
|
|
|
47 |
st.download_button(
|
48 |
label="π₯ Download Dream Image",
|
49 |
data=byte_im,
|
50 |
+
file_name="dreamscape_hd.png",
|
51 |
mime="image/png"
|
52 |
)
|