Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -306,7 +306,7 @@ def main_app():
|
|
306 |
image, image_url = image_result
|
307 |
st.image(image, caption="Generated Image", use_column_width=True)
|
308 |
|
309 |
-
|
310 |
cloud_storage_url = upload_image_to_storage(image, st.session_state.current_user)
|
311 |
|
312 |
if cloud_storage_url:
|
@@ -324,8 +324,11 @@ def main_app():
|
|
324 |
|
325 |
st.header("Your Generated Images")
|
326 |
|
327 |
-
|
328 |
if st.session_state.images_data == [] or st.session_state.load_more_pressed == True:
|
|
|
|
|
|
|
329 |
st.session_state.images_data = load_image_data(st.session_state.current_user, st.session_state.start_index, st.session_state.batch_size)
|
330 |
st.session_state.load_more_pressed = False
|
331 |
|
@@ -343,11 +346,11 @@ def main_app():
|
|
343 |
else:
|
344 |
st.write("No image generated yet!")
|
345 |
|
|
|
346 |
# Load more button
|
347 |
if st.button("Load More Images"):
|
348 |
-
st.session_state.start_index += st.session_state.batch_size
|
349 |
st.session_state.load_more_pressed = True
|
350 |
-
# No
|
351 |
|
352 |
|
353 |
# Logout button
|
|
|
306 |
image, image_url = image_result
|
307 |
st.image(image, caption="Generated Image", use_column_width=True)
|
308 |
|
309 |
+
# Upload image to cloud storage and store url
|
310 |
cloud_storage_url = upload_image_to_storage(image, st.session_state.current_user)
|
311 |
|
312 |
if cloud_storage_url:
|
|
|
324 |
|
325 |
st.header("Your Generated Images")
|
326 |
|
327 |
+
# Load initial batch of images
|
328 |
if st.session_state.images_data == [] or st.session_state.load_more_pressed == True:
|
329 |
+
if st.session_state.load_more_pressed == True:
|
330 |
+
st.session_state.start_index += st.session_state.batch_size
|
331 |
+
# load all images if new login or load_more is pressed, also reset the flag
|
332 |
st.session_state.images_data = load_image_data(st.session_state.current_user, st.session_state.start_index, st.session_state.batch_size)
|
333 |
st.session_state.load_more_pressed = False
|
334 |
|
|
|
346 |
else:
|
347 |
st.write("No image generated yet!")
|
348 |
|
349 |
+
|
350 |
# Load more button
|
351 |
if st.button("Load More Images"):
|
|
|
352 |
st.session_state.load_more_pressed = True
|
353 |
+
# No loading here, we are now loading all the images when `load_more_pressed` flag is set to True
|
354 |
|
355 |
|
356 |
# Logout button
|