john1246 commited on
Commit
b1d1c6f
Β·
verified Β·
1 Parent(s): 5d0165f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -2,28 +2,30 @@ import os
2
  import subprocess
3
  import gradio as gr
4
 
5
- # Clone the GitHub repository
6
- if not os.path.exists("roopapi"):
7
- subprocess.run(["git", "clone", "https://github.com/lvalics/roopapi.git"])
8
 
9
- # Change the working directory to the cloned repository
10
- os.chdir("roopapi")
11
 
12
- # Install the required dependencies from requirements.txt (if it's not already installed)
 
 
13
  subprocess.run(["pip", "install", "-r", "requirements.txt"])
14
 
15
- # Now import the ROOP API (assuming `roop.py` is in the cloned repo)
16
  from roop import ROOP
17
 
18
- # Initialize ROOP model
19
  roop_model = ROOP()
20
 
21
- # Gradio function to swap faces
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"],