Spaces:
Sleeping
Sleeping
File size: 1,198 Bytes
b098d52 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import gradio as gr
from roop import core
def launch_interface():
# Initialisation EXPLICITE des composants Gradio
with gr.Blocks() as app: # <-- Structure recommandée pour éviter les "NoneType"
gr.Markdown("## 🔄 Face Swap avec Roop")
with gr.Row():
src_img = gr.Image(label="Image Source", type="filepath")
tgt_img = gr.Image(label="Image Cible", type="filepath")
result_img = gr.Image(label="Résultat", interactive=False)
btn = gr.Button("Exécuter le swap")
def swap_faces(source, target):
try:
# Appel à la logique roop (exemple simplifié)
output_path = "result.jpg"
core.process(source, target, output_path) # Adaptez à la vraie API roop
return output_path
except Exception as e:
print(f"ERREUR: {str(e)}")
return None
btn.click(
fn=swap_faces,
inputs=[src_img, tgt_img],
outputs=result_img
)
return app
if __name__ == "__main__":
app = launch_interface()
app.launch(server_name="0.0.0.0", server_port=7860) |