Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,27 @@
|
|
1 |
import streamlit as st
|
2 |
-
from
|
3 |
-
import torch
|
4 |
|
5 |
-
#
|
6 |
@st.cache_resource
|
7 |
-
def
|
8 |
-
#
|
9 |
-
|
10 |
-
return
|
11 |
|
12 |
-
|
13 |
|
14 |
# Streamlit app
|
15 |
-
st.title("Text-to-Image Generation (Fast)")
|
16 |
|
17 |
# User input for prompt
|
18 |
-
user_prompt = st.text_input("Enter your image prompt", value="Astronaut in a jungle")
|
19 |
|
20 |
# Button to generate the image
|
21 |
if st.button("Generate Image"):
|
22 |
if user_prompt:
|
23 |
with st.spinner("Generating image..."):
|
24 |
-
#
|
25 |
-
|
26 |
-
image = Image.new("RGB", (256, 256), color="blue") # Placeholder image
|
27 |
|
28 |
# Display the generated image
|
29 |
st.image(image, caption="Generated Image", use_column_width=True)
|
|
|
1 |
import streamlit as st
|
2 |
+
from diffusers import DiffusionPipeline
|
|
|
3 |
|
4 |
+
# Load the diffusion pipeline model
|
5 |
@st.cache_resource
|
6 |
+
def load_pipeline():
|
7 |
+
# Use the 'SaiRaj03/Text_To_Image' model for fast generation
|
8 |
+
pipe = DiffusionPipeline.from_pretrained("SaiRaj03/Text_To_Image")
|
9 |
+
return pipe
|
10 |
|
11 |
+
pipe = load_pipeline()
|
12 |
|
13 |
# Streamlit app
|
14 |
+
st.title("Text-to-Image Generation App (Fast)")
|
15 |
|
16 |
# User input for prompt
|
17 |
+
user_prompt = st.text_input("Enter your image prompt", value="Astronaut in a jungle, cold color palette, muted colors, detailed, 8k")
|
18 |
|
19 |
# Button to generate the image
|
20 |
if st.button("Generate Image"):
|
21 |
if user_prompt:
|
22 |
with st.spinner("Generating image..."):
|
23 |
+
# Generate the image using the new model
|
24 |
+
image = pipe(user_prompt).images[0]
|
|
|
25 |
|
26 |
# Display the generated image
|
27 |
st.image(image, caption="Generated Image", use_column_width=True)
|