|
import os |
|
import subprocess |
|
import gradio as gr |
|
|
|
|
|
if not os.path.exists("roopapi"): |
|
subprocess.run(["git", "clone", "https://github.com/lvalics/roopapi.git"]) |
|
|
|
|
|
os.chdir("roopapi") |
|
|
|
|
|
subprocess.run(["pip", "install", "-r", "requirements.txt"]) |
|
|
|
|
|
from roop import ROOP |
|
|
|
|
|
roop_model = ROOP() |
|
|
|
|
|
def process_face_swap(image, video): |
|
output = roop_model.swap_faces(image, video) |
|
return output |
|
|
|
|
|
iface = gr.Interface( |
|
fn=process_face_swap, |
|
inputs=["image", "video"], |
|
outputs="video", |
|
live=True, |
|
title="ROOP Face Swapping API", |
|
description="Upload an image and a video to swap faces." |
|
) |
|
|
|
iface.launch() |
|
|