File size: 772 Bytes
5da5004
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

import gradio as gr
import os
from run import run_faceswap

def process_face_swap(source_image, target_media):
    source_path = "face.png"
    target_path = "target"

    source_image.save(source_path)
    ext = os.path.splitext(target_media.name)[-1]
    target_path += ext
    target_media.save(target_path)

    output_path = run_faceswap(source_path, target_path)
    return output_path

iface = gr.Interface(
    fn=process_face_swap,
    inputs=[
        gr.Image(label="Source Face (face.png)"),
        gr.File(label="Target Image or Video (.jpg/.mp4)")
    ],
    outputs=gr.File(label="Swapped Output"),
    title="Lightweight Roop Face Swap",
    description="Upload face.png and target image/video. Output will be result.jpg or result.mp4"
)

iface.launch()