Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -330,43 +330,48 @@ def main_app():
|
|
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 |
-
|
334 |
-
|
335 |
-
|
|
|
336 |
|
337 |
# Create left and right arrow buttons
|
338 |
col_left, col_center, col_right = st.columns([1,8,1])
|
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.
|
343 |
|
344 |
with col_right:
|
345 |
if st.button("▶️"):
|
346 |
-
st.session_state.current_window_start += st.session_state.
|
347 |
|
348 |
# Dynamically load images for the window
|
349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
|
351 |
-
|
352 |
-
|
353 |
-
num_images = len(images_for_window)
|
354 |
-
num_images_to_display = min(st.session_state.max_images_to_display, num_images) # To limit max images to display
|
355 |
|
356 |
cols = st.columns(num_images_to_display)
|
357 |
-
|
358 |
-
start_index = max(0, num_images - num_images_to_display)
|
359 |
-
|
360 |
-
for i, image_data in enumerate(images_for_window[start_index:]):
|
361 |
-
if i < num_images_to_display:
|
362 |
with cols[i]:
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
|
|
368 |
else:
|
369 |
-
|
370 |
|
371 |
# Logout button
|
372 |
if st.button("Logout", on_click=logout_callback):
|
|
|
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 |
+
if "window_size" not in st.session_state:
|
336 |
+
st.session_state.window_size = 5 # The number of images to display at a time
|
337 |
|
338 |
# Create left and right arrow buttons
|
339 |
col_left, col_center, col_right = st.columns([1,8,1])
|
340 |
|
341 |
with col_left:
|
342 |
if st.button("◀️"):
|
343 |
+
st.session_state.current_window_start = max(0, st.session_state.current_window_start - st.session_state.window_size)
|
344 |
|
345 |
with col_right:
|
346 |
if st.button("▶️"):
|
347 |
+
st.session_state.current_window_start += st.session_state.window_size
|
348 |
|
349 |
# Dynamically load images for the window
|
350 |
+
all_images = load_image_data(st.session_state.current_user, 0, 1000) # load all images
|
351 |
+
|
352 |
+
if all_images:
|
353 |
+
num_images = len(all_images)
|
354 |
+
|
355 |
+
# Calculate the range for images to display
|
356 |
+
start_index = st.session_state.current_window_start
|
357 |
+
end_index = min(start_index + st.session_state.window_size, num_images)
|
358 |
+
|
359 |
+
images_for_window = all_images[start_index:end_index]
|
360 |
|
361 |
+
# Setup columns for horizontal slider layout
|
362 |
+
num_images_to_display = len(images_for_window)
|
|
|
|
|
363 |
|
364 |
cols = st.columns(num_images_to_display)
|
365 |
+
for i, image_data in enumerate(images_for_window):
|
|
|
|
|
|
|
|
|
366 |
with cols[i]:
|
367 |
+
st.image(image_data['image_url'], width = 150)
|
368 |
+
st.write(f"**Prompt:** {image_data['prompt']}")
|
369 |
+
st.write(f"**Aspect Ratio:** {image_data['aspect_ratio']}")
|
370 |
+
st.write(f"**Realism:** {image_data['realism']}")
|
371 |
+
st.markdown("---")
|
372 |
+
|
373 |
else:
|
374 |
+
st.write("No image generated yet!")
|
375 |
|
376 |
# Logout button
|
377 |
if st.button("Logout", on_click=logout_callback):
|