assile's picture
Update run.py
b098d52 verified
raw
history blame
1.2 kB
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)