Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import os | |
| from facefusion import core | |
| # Ensure environment variables are set properly | |
| os.environ['OMP_NUM_THREADS'] = '1' | |
| def face_swap(image1, image2): | |
| """Runs FaceFusion CLI with the provided images.""" | |
| input_path1 = "input1.jpg" | |
| input_path2 = "input2.jpg" | |
| output_path = "output.jpg" | |
| # Save uploaded images | |
| image1.save(input_path1) | |
| image2.save(input_path2) | |
| # Run FaceFusion with command-line arguments | |
| os.system(f"facefusion -s {input_path1} -t {input_path2} -o {output_path}") | |
| return output_path | |
| # Gradio interface | |
| iface = gr.Interface( | |
| fn=face_swap, | |
| inputs=[ | |
| gr.Image(type="pil", label="Source Face"), | |
| gr.Image(type="pil", label="Target Face") | |
| ], | |
| outputs=gr.Image(type="file", label="Swapped Face"), | |
| title="FaceFusion AI", | |
| description="Upload two images and let FaceFusion swap the faces." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |