Spaces:
Runtime error
Runtime error
File size: 975 Bytes
3dda64a f4d2bbb 3dda64a 3bd4e85 8cba427 f4d2bbb ad7b3d7 f4d2bbb 1842142 2689406 d5d890f 2d50172 3cd009b ceac16c 3dda64a |
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 gradio as gr
import RetinaFace
import numpy as np
def RFace(img):
faces = RetinaFace.extract_faces(img, align = True)
last = np.zeros((20,20), np.uint8)
for count, image in enumerate(faces):
if count == 0:
last = image
else:
h1, w1 = last.shape[:2]
h2, w2 = image.shape[:2]
#create empty matrix
vis = np.zeros((max(h1, h2), w1+w2,3), np.uint8)
#combine 2 images
vis[:h1, :w1,:3] = last
vis[:h2, w1:w1+w2,:3] = image
last = vis
return last
examples=[['Rdj.jpg'],['Rdj2.jpg'],['2.jpg'],['3.jpg'],['many.jpg']]
desc = "RetinaFace is a deep learning based cutting-edge facial detector for Python coming with facial landmarks. Its detection performance for faces is especially excellent for dense crowds."
gr.Interface(fn=RFace, inputs=gr.inputs.Image(type="filepath"), outputs="image", title="RetinaFace Face Detector and Extractor",examples=examples, description=desc).launch(inbrowser=True)
|