anurag629 commited on
Commit
a6a443d
·
1 Parent(s): cd2fab0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -6,6 +6,7 @@ from io import BytesIO
6
 
7
  # Function to run the provided script and return the path of the generated video
8
  def run_script(image_path, video_path):
 
9
  script = """
10
  !git clone https://github.com/s0md3v/roop.git
11
  %cd roop
@@ -14,13 +15,13 @@ def run_script(image_path, video_path):
14
  !mkdir models
15
  !mv inswapper_128.onnx ./models
16
 
17
- !python run.py --target {} --output-video-quality 80 --source {} -o /content/swapped.mp4 --execution-provider cuda --frame-processor face_swapper face_enhancer
18
- """.format(video_path, image_path)
19
 
20
  subprocess.run(script, shell=True)
21
 
22
  # Return the path of the generated video
23
- return "/root/roop/content/swapped.mp4"
24
 
25
  # Streamlit app
26
  def main():
@@ -34,8 +35,8 @@ def main():
34
  if st.sidebar.button("Swap Faces"):
35
  if image_file is not None and video_file is not None:
36
  # Save uploaded files
37
- image_path = "./uploaded_image.jpg"
38
- video_path = "./uploaded_video.mp4"
39
 
40
  with open(image_path, "wb") as f:
41
  f.write(image_file.read())
 
6
 
7
  # Function to run the provided script and return the path of the generated video
8
  def run_script(image_path, video_path):
9
+ output_video_path = "/content/swapped.mp4"
10
  script = """
11
  !git clone https://github.com/s0md3v/roop.git
12
  %cd roop
 
15
  !mkdir models
16
  !mv inswapper_128.onnx ./models
17
 
18
+ !python run.py --target {} --output-video-quality 80 --source {} -o {} --execution-provider cuda --frame-processor face_swapper face_enhancer
19
+ """.format(video_path, image_path, output_video_path)
20
 
21
  subprocess.run(script, shell=True)
22
 
23
  # Return the path of the generated video
24
+ return output_video_path
25
 
26
  # Streamlit app
27
  def main():
 
35
  if st.sidebar.button("Swap Faces"):
36
  if image_file is not None and video_file is not None:
37
  # Save uploaded files
38
+ image_path = "/content/uploaded_image.jpg"
39
+ video_path = "/content/uploaded_video.mp4"
40
 
41
  with open(image_path, "wb") as f:
42
  f.write(image_file.read())