Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
import streamlit as st
|
2 |
-
from diffusers import DiffusionPipeline
|
3 |
from PIL import Image
|
4 |
import torch
|
5 |
|
6 |
-
#
|
7 |
@st.cache_resource
|
8 |
-
def
|
9 |
-
|
10 |
-
|
11 |
-
return
|
12 |
|
13 |
-
|
14 |
|
15 |
# Streamlit app
|
16 |
-
st.title("Text-to-Image Generation
|
17 |
|
18 |
# User input for prompt
|
19 |
-
user_prompt = st.text_input("Enter your image prompt", value="Astronaut in a jungle
|
20 |
|
21 |
# Button to generate the image
|
22 |
if st.button("Generate Image"):
|
23 |
if user_prompt:
|
24 |
with st.spinner("Generating image..."):
|
25 |
-
#
|
26 |
-
|
|
|
27 |
|
28 |
# Display the generated image
|
29 |
st.image(image, caption="Generated Image", use_column_width=True)
|
|
|
1 |
import streamlit as st
|
|
|
2 |
from PIL import Image
|
3 |
import torch
|
4 |
|
5 |
+
# Optimized lightweight image generation (example)
|
6 |
@st.cache_resource
|
7 |
+
def load_lightweight_model():
|
8 |
+
# Assuming there's a lightweight model for CPU
|
9 |
+
# Placeholder: Replace this with actual lightweight model loading
|
10 |
+
return "lightweight_model"
|
11 |
|
12 |
+
model = load_lightweight_model()
|
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 |
+
# Simulated fast image generation (substitute with lightweight model logic)
|
25 |
+
# Example: Generate a simple placeholder image
|
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)
|