Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from diffusers import StableDiffusionPipeline
|
3 |
+
import torch
|
4 |
+
|
5 |
+
st.set_page_config(page_title="Dreamscape Visualizer")
|
6 |
+
st.title("Dreamscape Visualizer")
|
7 |
+
|
8 |
+
@st.cache_resource
|
9 |
+
def load_pipeline():
|
10 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
11 |
+
"runwayml/stable-diffusion-v1-5",
|
12 |
+
torch_dtype=torch.float16
|
13 |
+
)
|
14 |
+
pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
15 |
+
return pipe
|
16 |
+
|
17 |
+
pipe = load_pipeline()
|
18 |
+
style_modifiers = {
|
19 |
+
"Fantasy": "dreamlike fantasy art",
|
20 |
+
"Nightmare": "dark horror surrealism",
|
21 |
+
"Lucid": "vivid hyperreal dreamscape",
|
22 |
+
"Sci-Fi": "futuristic dream world",
|
23 |
+
"Mythical": "ancient mythical surrealism"
|
24 |
+
}
|
25 |
+
|
26 |
+
prompt = st.text_area("Describe your dream:", height=100)
|
27 |
+
style = st.selectbox("Choose a style:", list(style_modifiers.keys()))
|
28 |
+
if st.button("Visualize Dream"):
|
29 |
+
if not prompt.strip():
|
30 |
+
st.warning("Please enter a dream description.")
|
31 |
+
else:
|
32 |
+
with st.spinner("Generating your dreamscape..."):
|
33 |
+
final_prompt = f"{prompt}, {style_modifiers[style]}"
|
34 |
+
image = pipe(final_prompt).images[0]
|
35 |
+
st.image(image, caption="Here is your dreamscape!",use_column_width=True)
|