ProfessorLeVesseur
commited on
Commit
•
ff03303
1
Parent(s):
7498bae
Update app.py
Browse files
app.py
CHANGED
@@ -119,15 +119,17 @@ def main():
|
|
119 |
st.session_state["prompt"] = ""
|
120 |
|
121 |
# Input field for the prompt
|
122 |
-
prompt = st.text_input("Enter a prompt for image generation:", value="")
|
123 |
|
124 |
if st.button("Generate Image"):
|
125 |
if prompt:
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
|
|
|
|
131 |
else:
|
132 |
st.warning("Please enter a prompt.")
|
133 |
|
@@ -149,8 +151,8 @@ def main():
|
|
149 |
# Clear session state variables
|
150 |
st.session_state["image"] = None
|
151 |
st.session_state["prompt"] = ""
|
152 |
-
|
153 |
-
# Clear UI by
|
154 |
st.query_params = {}
|
155 |
|
156 |
#------------------------------------------------------------------------
|
|
|
119 |
st.session_state["prompt"] = ""
|
120 |
|
121 |
# Input field for the prompt
|
122 |
+
prompt = st.text_input("Enter a prompt for image generation:", value=st.session_state["prompt"])
|
123 |
|
124 |
if st.button("Generate Image"):
|
125 |
if prompt:
|
126 |
+
# Add a spinner while generating the image
|
127 |
+
with st.spinner('Generating image...'):
|
128 |
+
image = generate_image(prompt)
|
129 |
+
if image:
|
130 |
+
st.session_state["image"] = image # Store generated image in session state
|
131 |
+
st.image(image, caption="Generated Image")
|
132 |
+
st.session_state["prompt"] = prompt # Store the prompt in session state
|
133 |
else:
|
134 |
st.warning("Please enter a prompt.")
|
135 |
|
|
|
151 |
# Clear session state variables
|
152 |
st.session_state["image"] = None
|
153 |
st.session_state["prompt"] = ""
|
154 |
+
|
155 |
+
# Clear UI by resetting query params
|
156 |
st.query_params = {}
|
157 |
|
158 |
#------------------------------------------------------------------------
|