sandrocalzada commited on
Commit
270b511
1 Parent(s): 7702267

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -34,6 +34,27 @@ def predict(image_in_video, image_in_img):
34
  image = image_in_video or image_in_img
35
  return image
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  with gr.Blocks() as blocks:
38
  gr.Markdown("### Capture Image Using WebCam or Upload")
39
 
 
34
  image = image_in_video or image_in_img
35
  return image
36
 
37
+ app = FaceAnalysis(name='buffalo_l')
38
+ app.prepare(ctx_id=0, det_size=(640, 640))
39
+ swapper = insightface.model_zoo.get_model('inswapper_128.onnx', download='FALSE', download_zip= 'FALSE')
40
+
41
+ img = ins_get_image('t1')
42
+ faces = app.get(img)
43
+
44
+ source_face = faces[0]
45
+ bbox = source_face['bbox']
46
+ bbox = [int(b) for b in bbox]
47
+
48
+ source_face = faces[0]
49
+ bbox = source_face['bbox']
50
+ bbox = [int(b) for b in bbox]
51
+
52
+ res = img.copy()
53
+ for face in faces:
54
+ res = swapper.get(res, face, source_face, paste_back=True)
55
+
56
+
57
+
58
  with gr.Blocks() as blocks:
59
  gr.Markdown("### Capture Image Using WebCam or Upload")
60