File size: 862 Bytes
55ced80
 
 
 
e419bb4
9b73ca2
55ced80
 
 
 
 
 
859f6d1
8bcf713
e419bb4
55ced80
 
 
 
 
 
2e5ae1e
55ced80
07e1899
2e5ae1e
 
55ced80
 
 
d8c73e5
55ced80
 
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
31
32

import insightface
from insightface.app import FaceAnalysis
import gradio as gr
#import gfpgan
import onnxruntime


def Swap_Face(image1,image2):
    app = FaceAnalysis(name='buffalo_l')
    app.prepare(ctx_id=0, det_size=(640, 640))

    swapper = insightface.model_zoo.get_model("inswapper_128.onnx", download=False,
                                              download_zip=False,providers=onnxruntime.get_available_providers())
    #face_enhancer = gfpgan.GFPGANer(model_path="GFPGANv1.4.pth", upscale=1)

    # Do the swap
    face1 = app.get(image1)[0]
    face2 = app.get(image2)[0]

    img1_ = image1.copy()
    result = swapper.get(img1_, face1, face2, paste_back=True)

    

    return result


title = "Swap Faces Using Our Model!!!"
iface = gr.Interface(fn=Swap_Face,inputs=["image","image"],outputs="image",title=title)

iface.launch(share=True)