Delete app.py
Browse files
app.py
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import os
|
3 |
-
from run import run_faceswap
|
4 |
-
|
5 |
-
def process_face_swap(source_image, target_image, target_video):
|
6 |
-
source_path = "face.png"
|
7 |
-
target_path = "target"
|
8 |
-
|
9 |
-
# Save source image
|
10 |
-
source_image.save(source_path)
|
11 |
-
|
12 |
-
# Use whichever is provided (image or video)
|
13 |
-
if target_image is not None:
|
14 |
-
ext = ".jpg"
|
15 |
-
target_image.save(target_path + ext)
|
16 |
-
used_path = target_path + ext
|
17 |
-
elif target_video is not None:
|
18 |
-
ext = ".mp4"
|
19 |
-
target_video.save(target_path + ext)
|
20 |
-
used_path = target_path + ext
|
21 |
-
else:
|
22 |
-
raise ValueError("Please upload either an image or a video.")
|
23 |
-
|
24 |
-
output_path = run_faceswap(source_path, used_path)
|
25 |
-
return output_path
|
26 |
-
|
27 |
-
with gr.Blocks() as demo:
|
28 |
-
gr.Markdown("## Lightweight Roop Face Swap")
|
29 |
-
gr.Markdown("Upload face.png and target image or video. Output will be result.jpg or result.mp4")
|
30 |
-
|
31 |
-
with gr.Row():
|
32 |
-
source_image = gr.Image(label="Source Face (face.png)", type="pil")
|
33 |
-
|
34 |
-
with gr.Row():
|
35 |
-
with gr.Tab("Target Image"):
|
36 |
-
target_image = gr.Image(label="Upload Target Image (.jpg)", type="pil")
|
37 |
-
with gr.Tab("Target Video"):
|
38 |
-
target_video = gr.Video(label="Upload Target Video (.mp4)")
|
39 |
-
|
40 |
-
output_file = gr.File(label="Swapped Output")
|
41 |
-
|
42 |
-
submit_btn = gr.Button("Submit")
|
43 |
-
|
44 |
-
submit_btn.click(
|
45 |
-
fn=process_face_swap,
|
46 |
-
inputs=[source_image, target_image, target_video],
|
47 |
-
outputs=output_file
|
48 |
-
)
|
49 |
-
|
50 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|