Spaces:
Running
Running
salomonsky
commited on
Commit
•
ce98b47
1
Parent(s):
b6a9749
Update app.py
Browse files
app.py
CHANGED
@@ -99,6 +99,31 @@ def gen(prompts, width, height, model_name, num_variants=1, use_enhanced=True):
|
|
99 |
st.error(f"Error al generar imágenes: {e}")
|
100 |
return images
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
def improve_prompt(prompt):
|
103 |
try:
|
104 |
instructions = [
|
|
|
99 |
st.error(f"Error al generar imágenes: {e}")
|
100 |
return images
|
101 |
|
102 |
+
def display_gallery():
|
103 |
+
st.header("Galería de Imágenes Guardadas")
|
104 |
+
images = list_saved_images()
|
105 |
+
if images:
|
106 |
+
cols = st.columns(8)
|
107 |
+
for i, image_file in enumerate(images):
|
108 |
+
with cols[i % 8]:
|
109 |
+
st.image(str(image_file), caption=image_file.name, use_column_width=True)
|
110 |
+
prompt = get_prompt_for_image(image_file.name)
|
111 |
+
st.write(prompt[:300])
|
112 |
+
|
113 |
+
if st.button(f"FaceSwap", key=f"select_{i}_{image_file.name}"):
|
114 |
+
st.session_state['generated_image_path'] = str(image_file)
|
115 |
+
st.success("Imagen seleccionada")
|
116 |
+
|
117 |
+
if st.button(f"Borrar", key=f"delete_{i}_{image_file.name}"):
|
118 |
+
if os.path.exists(image_file):
|
119 |
+
os.remove(image_file)
|
120 |
+
st.success("Imagen borrada")
|
121 |
+
display_gallery()
|
122 |
+
else:
|
123 |
+
st.warning("La imagen no existe.")
|
124 |
+
else:
|
125 |
+
st.info("No hay imágenes guardadas.")
|
126 |
+
|
127 |
def improve_prompt(prompt):
|
128 |
try:
|
129 |
instructions = [
|