Update app.py
Browse files
app.py
CHANGED
@@ -2,28 +2,30 @@ import os
|
|
2 |
import subprocess
|
3 |
import gradio as gr
|
4 |
|
5 |
-
# Clone the GitHub repository
|
6 |
-
|
7 |
-
|
8 |
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
# Install
|
|
|
|
|
13 |
subprocess.run(["pip", "install", "-r", "requirements.txt"])
|
14 |
|
15 |
-
# Now import the
|
16 |
from roop import ROOP
|
17 |
|
18 |
-
# Initialize ROOP model
|
19 |
roop_model = ROOP()
|
20 |
|
21 |
-
# Gradio function
|
22 |
def process_face_swap(image, video):
|
23 |
output = roop_model.swap_faces(image, video)
|
24 |
return output
|
25 |
|
26 |
-
# Gradio interface
|
27 |
iface = gr.Interface(
|
28 |
fn=process_face_swap,
|
29 |
inputs=["image", "video"],
|
|
|
2 |
import subprocess
|
3 |
import gradio as gr
|
4 |
|
5 |
+
# Clone the GitHub repository if it's not already present
|
6 |
+
repo_url = "https://github.com/lvalics/roopapi.git"
|
7 |
+
repo_dir = "roopapi"
|
8 |
|
9 |
+
if not os.path.exists(repo_dir):
|
10 |
+
subprocess.run(["git", "clone", repo_url])
|
11 |
|
12 |
+
# Install any necessary dependencies from requirements.txt
|
13 |
+
# Change directory to the repo folder and install dependencies
|
14 |
+
os.chdir(repo_dir)
|
15 |
subprocess.run(["pip", "install", "-r", "requirements.txt"])
|
16 |
|
17 |
+
# Now import the required modules from the repo
|
18 |
from roop import ROOP
|
19 |
|
20 |
+
# Initialize the ROOP face-swapping model
|
21 |
roop_model = ROOP()
|
22 |
|
23 |
+
# Define a simple Gradio function for face swapping
|
24 |
def process_face_swap(image, video):
|
25 |
output = roop_model.swap_faces(image, video)
|
26 |
return output
|
27 |
|
28 |
+
# Create the Gradio interface
|
29 |
iface = gr.Interface(
|
30 |
fn=process_face_swap,
|
31 |
inputs=["image", "video"],
|