MaroofTechSorcerer commited on
Commit
68e60cb
·
verified ·
1 Parent(s): 3365d8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -28
app.py CHANGED
@@ -1,35 +1,37 @@
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)
 
 
 
 
 
 
 
 
 
 
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
 
19
+ style_modifiers = {
20
+ "Fantasy": "dreamlike fantasy art",
21
+ "Nightmare": "dark horror surrealism",
22
+ "Lucid": "vivid hyperreal dreamscape",
23
+ "Sci-Fi": "futuristic dream world",
24
+ "Mythical": "ancient mythical surrealism"
25
+ }
26
+
27
+ prompt = st.text_area("Describe your dream:", height=100)
28
+ style = st.selectbox("Choose a style:", list(style_modifiers.keys()))
29
+
30
+ if st.button("Visualize Dream"):
31
+ if not prompt.strip():
32
+ st.warning("Please enter a dream description.")
33
+ else:
34
+ with st.spinner("Generating your dreamscape..."):
35
+ final_prompt = f"{prompt}, {style_modifiers[style]}"
36
+ image = pipe(final_prompt).images[0]
37
+ st.image(image, caption="Here is your dreamscape!", use_column_width=True)