Vignesh455 commited on
Commit
b0d4608
1 Parent(s): 6f2ee5d

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +31 -0
  2. packages.txt +3 -0
  3. requirements.txt +16 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import insightface
3
+ from insightface.app import FaceAnalysis
4
+ import gradio as gr
5
+ from gfpgan.utils import GFPGANer
6
+ import onnxruntime
7
+
8
+
9
+ def Swap_Face(image1,image2):
10
+ app = FaceAnalysis(name='buffalo_l')
11
+ app.prepare(ctx_id=0, det_size=(640, 640))
12
+
13
+ swapper = insightface.model_zoo.get_model("inswapper_128.onnx", download=False,
14
+ download_zip=False,providers=onnxruntime.get_available_providers())
15
+ face_enhancer = GFPGANer(model_path="GFPGANv1.4.pth", upscale=1)
16
+
17
+ # Do the swap
18
+ face1 = app.get(image1)[0]
19
+ face2 = app.get(image2)[0]
20
+
21
+ img1_ = image1.copy()
22
+ result = swapper.get(img1_, face1, face2, paste_back=True)
23
+ _, _, result = face_enhancer.enhance(result)
24
+
25
+ return result
26
+
27
+
28
+ title = "Swap Faces Using Our Model!!!"
29
+ iface = gr.Interface(fn=Swap_Face,inputs=["image","image"],outputs="image",title=title)
30
+
31
+ iface.launch(share=True)
packages.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ ffmpeg
2
+ libsm6
3
+ libxext6
requirements.txt ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ insightface
2
+ onnxruntime
3
+ gradio
4
+ torchvision==0.16.2
5
+ torch
6
+ basicsr
7
+ facexlib
8
+ gfpgan==1.3.8
9
+ realesrgan>=0.2.5
10
+ numpy
11
+ opencv-python
12
+ scipy
13
+ tqdm
14
+ lmdb
15
+ pyyaml
16
+ yapf