Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -328,20 +328,32 @@ def main_app():
|
|
328 |
|
329 |
st.header("Your Generated Images")
|
330 |
|
331 |
-
|
332 |
-
if
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
343 |
cols = st.columns(num_images) # dynamically create columns according to data
|
344 |
-
for i, image_data in enumerate(
|
345 |
with cols[i]:
|
346 |
st.image(image_data['image_url'], width = 150)
|
347 |
st.write(f"**Prompt:** {image_data['prompt']}")
|
@@ -352,12 +364,6 @@ def main_app():
|
|
352 |
st.write("No image generated yet!")
|
353 |
|
354 |
|
355 |
-
# Load more button
|
356 |
-
if st.button("Load More Images"):
|
357 |
-
st.session_state.load_more_pressed = True
|
358 |
-
# No loading here, we are now loading all the images when `load_more_pressed` flag is set to True
|
359 |
-
|
360 |
-
|
361 |
# Logout button
|
362 |
if st.button("Logout", on_click=logout_callback):
|
363 |
pass
|
|
|
328 |
|
329 |
st.header("Your Generated Images")
|
330 |
|
331 |
+
# Initialize the current window, if it doesn't exist in session state
|
332 |
+
if "current_window_start" not in st.session_state:
|
333 |
+
st.session_state.current_window_start = 0
|
334 |
+
|
335 |
+
|
336 |
+
# Create left and right arrow buttons
|
337 |
+
col_left, col_center, col_right = st.columns([1,8,1])
|
338 |
+
|
339 |
+
|
340 |
+
with col_left:
|
341 |
+
if st.button("◀️"):
|
342 |
+
st.session_state.current_window_start = max(0, st.session_state.current_window_start - st.session_state.batch_size)
|
343 |
+
|
344 |
+
with col_right:
|
345 |
+
if st.button("▶️"):
|
346 |
+
st.session_state.current_window_start += st.session_state.batch_size
|
347 |
+
|
348 |
+
|
349 |
+
# Dynamically load images for the window
|
350 |
+
images_for_window = load_image_data(st.session_state.current_user, st.session_state.current_window_start, st.session_state.batch_size*3) # Load three batch sizes to cover sliding window
|
351 |
+
|
352 |
+
# Setup columns for horizontal slider layout
|
353 |
+
if images_for_window:
|
354 |
+
num_images = len(images_for_window)
|
355 |
cols = st.columns(num_images) # dynamically create columns according to data
|
356 |
+
for i, image_data in enumerate(images_for_window):
|
357 |
with cols[i]:
|
358 |
st.image(image_data['image_url'], width = 150)
|
359 |
st.write(f"**Prompt:** {image_data['prompt']}")
|
|
|
364 |
st.write("No image generated yet!")
|
365 |
|
366 |
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
# Logout button
|
368 |
if st.button("Logout", on_click=logout_callback):
|
369 |
pass
|