linoyts HF Staff commited on
Commit
ec63cbd
·
verified ·
1 Parent(s): e2d89f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -162,7 +162,7 @@ Swap faces using Flux.2 Klein 9B [Alissonerdx/BFS-Best-Face-Swap](https://huggin
162
  type="pil"
163
  )
164
 
165
- run_button = gr.Button("Swap Face", variant="primary", size="lg")
166
 
167
  with gr.Accordion("Advanced Settings", open=False):
168
  seed = gr.Slider(
@@ -244,21 +244,23 @@ Swap faces using Flux.2 Klein 9B [Alissonerdx/BFS-Best-Face-Swap](https://huggin
244
  def auto_swap_wrapper(ref_face, target_img, s, rand_s, w, h, steps, cfg):
245
  """Only run face swap if both images are provided"""
246
  if ref_face is not None and target_img is not None:
247
- return face_swap(ref_face, target_img, s, rand_s, w, h, steps, cfg)
248
- return None, s
 
 
249
 
250
  # Trigger on reference face upload/change
251
  reference_face.change(
252
  fn=auto_swap_wrapper,
253
  inputs=swap_inputs,
254
- outputs=swap_outputs,
255
  )
256
 
257
  # Trigger on target image upload/change
258
  target_image.change(
259
  fn=auto_swap_wrapper,
260
  inputs=swap_inputs,
261
- outputs=swap_outputs,
262
  )
263
 
264
  if __name__ == "__main__":
 
162
  type="pil"
163
  )
164
 
165
+ run_button = gr.Button("Swap Face", variant="primary", size="lg", visible=False)
166
 
167
  with gr.Accordion("Advanced Settings", open=False):
168
  seed = gr.Slider(
 
244
  def auto_swap_wrapper(ref_face, target_img, s, rand_s, w, h, steps, cfg):
245
  """Only run face swap if both images are provided"""
246
  if ref_face is not None and target_img is not None:
247
+ result = face_swap(ref_face, target_img, s, rand_s, w, h, steps, cfg)
248
+ # Show the button after first generation
249
+ return result[0], result[1], gr.update(visible=True)
250
+ return None, s, gr.update(visible=False)
251
 
252
  # Trigger on reference face upload/change
253
  reference_face.change(
254
  fn=auto_swap_wrapper,
255
  inputs=swap_inputs,
256
+ outputs=[comparison_slider, seed_output, run_button],
257
  )
258
 
259
  # Trigger on target image upload/change
260
  target_image.change(
261
  fn=auto_swap_wrapper,
262
  inputs=swap_inputs,
263
+ outputs=[comparison_slider, seed_output, run_button],
264
  )
265
 
266
  if __name__ == "__main__":