Spaces:
Runtime error
Runtime error
| 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']] | |
| gr.Interface(fn=RFace, inputs=gr.inputs.Image(type="filepath"), outputs="image", title="RetinaFace Face Detector and Extractor",examples=examples).launch(inbrowser=True) | |