Spaces:
Running
Running
salomonsky
commited on
Commit
•
8c36a1f
1
Parent(s):
fef6d06
Update app.py
Browse files
app.py
CHANGED
@@ -140,6 +140,15 @@ def delete_image(image_path):
|
|
140 |
except Exception as e:
|
141 |
st.error(f"Error al borrar la imagen: {e}")
|
142 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
def main():
|
144 |
st.set_page_config(layout="wide")
|
145 |
prompt = st.sidebar.text_input("Descripción de la imagen", max_chars=900)
|
@@ -196,12 +205,19 @@ def main():
|
|
196 |
|
197 |
if st.button(f"Borrar Imagen {idx+1}", key=f"delete_{idx}"):
|
198 |
try:
|
199 |
-
os.remove(
|
200 |
-
|
201 |
-
os.remove(prompt_file)
|
202 |
-
st.success(f"Imagen {idx+1} y su prompt fueron borrados.")
|
203 |
except Exception as e:
|
204 |
-
st.error(f"Error al borrar la imagen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
|
206 |
if __name__ == "__main__":
|
207 |
-
main()
|
|
|
140 |
except Exception as e:
|
141 |
st.error(f"Error al borrar la imagen: {e}")
|
142 |
|
143 |
+
def swap_faces(image_path):
|
144 |
+
try:
|
145 |
+
client = Client("deepfakes/faceswap")
|
146 |
+
result = client.predict(input_image=handle_file(image_path))
|
147 |
+
return result[1] if isinstance(result, list) and len(result) > 1 else None
|
148 |
+
except Exception as e:
|
149 |
+
st.error(f"Error en el faceswap: {e}")
|
150 |
+
return None
|
151 |
+
|
152 |
def main():
|
153 |
st.set_page_config(layout="wide")
|
154 |
prompt = st.sidebar.text_input("Descripción de la imagen", max_chars=900)
|
|
|
205 |
|
206 |
if st.button(f"Borrar Imagen {idx+1}", key=f"delete_{idx}"):
|
207 |
try:
|
208 |
+
os.remove(prompt_file)
|
209 |
+
st.success(f"Imagen {idx+1} borrada.")
|
|
|
|
|
210 |
except Exception as e:
|
211 |
+
st.error(f"Error al borrar la imagen: {e}")
|
212 |
+
|
213 |
+
if st.button(f"Swap Face {idx+1}", key=f"swap_{idx}"):
|
214 |
+
with st.spinner(f"Swapping faces en Imagen {idx+1}..."):
|
215 |
+
swapped_image_path = swap_faces(file)
|
216 |
+
if swapped_image_path:
|
217 |
+
swapped_image = Image.open(swapped_image_path)
|
218 |
+
st.image(swapped_image, caption=f"Imagen con Face Swap {idx+1}")
|
219 |
+
else:
|
220 |
+
st.error("Error en el face swap.")
|
221 |
|
222 |
if __name__ == "__main__":
|
223 |
+
main()
|