assile commited on
Commit
169b981
·
verified ·
1 Parent(s): 06fb2dd

Update run.py

Browse files
Files changed (1) hide show
  1. run.py +14 -22
run.py CHANGED
@@ -1,34 +1,26 @@
1
  import gradio as gr
2
- from roop import core
3
 
4
  def launch_interface():
5
- # Initialisation EXPLICITE des composants Gradio
6
- with gr.Blocks() as app: # <-- Structure recommandée pour éviter les "NoneType"
7
- gr.Markdown("## 🔄 Face Swap avec Roop")
8
-
9
  with gr.Row():
10
- src_img = gr.Image(label="Image Source", type="filepath")
11
- tgt_img = gr.Image(label="Image Cible", type="filepath")
12
- result_img = gr.Image(label="Résultat", interactive=False)
13
-
14
- btn = gr.Button("Exécuter le swap")
15
-
16
- def swap_faces(source, target):
17
  try:
18
- # Appel à la logique roop (exemple simplifié)
19
  output_path = "result.jpg"
20
- core.process(source, target, output_path) # Adaptez à la vraie API roop
21
  return output_path
22
  except Exception as e:
23
- print(f"ERREUR: {str(e)}")
24
  return None
25
-
26
- btn.click(
27
- fn=swap_faces,
28
- inputs=[src_img, tgt_img],
29
- outputs=result_img
30
- )
31
-
32
  return app
33
 
34
  if __name__ == "__main__":
 
1
  import gradio as gr
2
+ from roop_unleashed import Core # Changement d'import
3
 
4
  def launch_interface():
5
+ with gr.Blocks() as app:
6
+ gr.Markdown("## Face Swap")
 
 
7
  with gr.Row():
8
+ src = gr.Image(label="Source", type="filepath")
9
+ target = gr.Image(label="Cible", type="filepath")
10
+ output = gr.Image(label="Résultat")
11
+
12
+ btn = gr.Button("Exécuter")
13
+
14
+ def process(src_path, tgt_path):
15
  try:
 
16
  output_path = "result.jpg"
17
+ Core().enhance_face(src_path, tgt_path, output_path) # Adaptez à l'API réelle
18
  return output_path
19
  except Exception as e:
20
+ print(f"Erreur : {e}")
21
  return None
22
+
23
+ btn.click(process, inputs=[src, target], outputs=output)
 
 
 
 
 
24
  return app
25
 
26
  if __name__ == "__main__":