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)