Spaces:
Running
Running
salomonsky
commited on
Commit
•
db53266
1
Parent(s):
f00c319
Update app.py
Browse files
app.py
CHANGED
@@ -119,28 +119,26 @@ async def generate_variations(prompt, num_variants, use_enhanced, style):
|
|
119 |
def image_viewer():
|
120 |
images = list_saved_images()
|
121 |
if images:
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
st.session_state['current_image_index'] = i
|
135 |
-
|
136 |
-
|
137 |
-
col1, col2, col3 = st.columns([1, 2, 1])
|
138 |
-
with col1:
|
139 |
-
if st.button("⬅️", key="prev_image"):
|
140 |
-
st.session_state['current_image_index'] = (current_index - 1) % len(images)
|
141 |
-
with col3:
|
142 |
-
if st.button("➡️", key="next_image"):
|
143 |
-
st.session_state['current_image_index'] = (current_index + 1) % len(images)
|
144 |
else:
|
145 |
st.info("No hay imágenes guardadas.")
|
146 |
|
|
|
119 |
def image_viewer():
|
120 |
images = list_saved_images()
|
121 |
if images:
|
122 |
+
st.write("### Galería de Imágenes")
|
123 |
+
thumbnails = []
|
124 |
+
|
125 |
+
for image_file in images:
|
126 |
+
with Image.open(image_file) as img:
|
127 |
+
min_side = min(img.size)
|
128 |
+
cropped_img = img.crop(((img.width - min_side) // 2, (img.height - min_side) // 2,
|
129 |
+
(img.width + min_side) // 2, (img.height + min_side) // 2))
|
130 |
+
thumbnail = cropped_img.resize((100, 100))
|
131 |
+
thumbnails.append((image_file.name, thumbnail))
|
132 |
+
|
133 |
+
cols = st.columns(8)
|
134 |
+
|
135 |
+
for i, (name, thumbnail) in enumerate(thumbnails):
|
136 |
+
col = cols[i % 8]
|
137 |
+
with col:
|
138 |
+
st.image(thumbnail, use_column_width=False, width=100, caption=name)
|
139 |
+
if st.button("Ver", key=f"view_{i}"):
|
140 |
st.session_state['current_image_index'] = i
|
141 |
+
st.image(str(images[i]), caption=name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
else:
|
143 |
st.info("No hay imágenes guardadas.")
|
144 |
|