salomonsky commited on
Commit
35f506c
1 Parent(s): 8c36a1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -20
app.py CHANGED
@@ -142,11 +142,10 @@ def delete_image(image_path):
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():
@@ -203,21 +202,13 @@ def main():
203
  st.image(image, caption=f"Imagen {idx+1}")
204
  st.write(f"Prompt: {prompt_text}")
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()
 
142
 
143
  def swap_faces(image_path):
144
  try:
145
+ swapped_image_path = image_path
146
+ return swapped_image_path
 
147
  except Exception as e:
148
+ st.error(f"Error en el face swap: {e}")
149
  return None
150
 
151
  def main():
 
202
  st.image(image, caption=f"Imagen {idx+1}")
203
  st.write(f"Prompt: {prompt_text}")
204
 
205
+ if st.button(f"Borrar Imagen {idx+1}", key=f"delete_{idx+1}"):
206
+ delete_image(file)
207
+
208
+ if st.button(f"Swap Face {idx+1}", key=f"swap_{idx+1}"):
209
+ swapped_image_path = swap_faces(file)
210
+ if swapped_image_path:
211
+ st.image(swapped_image_path, caption=f"Imagen {idx+1} con Face Swap")
 
 
 
 
 
 
 
 
212
 
213
  if __name__ == "__main__":
214
+ main()