Spaces:
Runtime error
Runtime error
File size: 908 Bytes
5664dc5 53333b0 5664dc5 53333b0 5664dc5 53333b0 0972d04 53333b0 |
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 33 34 |
#! /usr/bin/env python
import os
import cv2
import argparse
from face_detection import select_face, select_all_faces
from face_swap import face_swap
import gradio as gr
from PIL import Image
def swap(src_img, dst_img):
# src_img = cv2.imread(src_img.name)
# dst_img = cv2.imread(Image.open(dst_img))
src_points, src_shape, src_face = select_face(src_img)
dst_faceBoxes = select_all_faces(dst_img)
if dst_faceBoxes is None:
print('Detect 0 Face !!')
exit(-1)
output = dst_img
for k, dst_face in dst_faceBoxes.items():
output = face_swap(src_face, dst_face["face"], src_points,
dst_face["points"], dst_face["shape"],
output, "correct color")
return output
if __name__ == '__main__':
# swap()
demo = gr.Interface(fn=swap, inputs=["image", "image"], outputs="image")
demo.launch()
|