Spaces:
Runtime error
Runtime error
Vignesh455
commited on
Commit
•
d8c73e5
1
Parent(s):
327549e
Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,9 @@ def Swap_Face(image1,image2):
|
|
9 |
app = FaceAnalysis(name='buffalo_l')
|
10 |
app.prepare(ctx_id=0, det_size=(640, 640))
|
11 |
|
12 |
-
swapper = insightface.model_zoo.get_model("inswapper_128.onnx", download=False,
|
13 |
download_zip=False)
|
14 |
-
face_enhancer = gfpgan.GFPGANer(model_path=
|
15 |
|
16 |
# Do the swap
|
17 |
face1 = app.get(image1)[0]
|
@@ -20,16 +20,12 @@ def Swap_Face(image1,image2):
|
|
20 |
img1_ = image1.copy()
|
21 |
result = swapper.get(img1_, face1, face2, paste_back=True)
|
22 |
|
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=[
|
30 |
-
gr.inputs.Image(type="file", label="Target Image"),
|
31 |
-
gr.inputs.Image(type="file", label="Swap Image")
|
32 |
-
],
|
33 |
-
outputs=gr.outputs.Image(type="file", label="Result"),title=title)
|
34 |
|
35 |
iface.launch(share=True)
|
|
|
9 |
app = FaceAnalysis(name='buffalo_l')
|
10 |
app.prepare(ctx_id=0, det_size=(640, 640))
|
11 |
|
12 |
+
swapper = insightface.model_zoo.get_model(r"C:\Users\vigne\Downloads\inswapper_128.onnx", download=False,
|
13 |
download_zip=False)
|
14 |
+
face_enhancer = gfpgan.GFPGANer(model_path=r"C:\Users\vigne\Downloads\GFPGANv1.4.pth", upscale=1)
|
15 |
|
16 |
# Do the swap
|
17 |
face1 = app.get(image1)[0]
|
|
|
20 |
img1_ = image1.copy()
|
21 |
result = swapper.get(img1_, face1, face2, paste_back=True)
|
22 |
|
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)
|