Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
InsightFace demo for face detection
# Reference: 1. Getting Started with Pre-trained Model from RetinaFace — insightface 0.1.5 documentation
# How to install insightface
# pip install insightface
# pip install mxnet-cu100
import insightface
import urllib
import urllib.request
import cv2
import numpy as np
def url_to_image(url):
resp = urllib.request.urlopen(url)
image = np.asarray(bytearray(, dtype="uint8")
image = cv2.imdecode(image, cv2.IMREAD_COLOR)
return image
url = ''
img = url_to_image(url)
model = insightface.model_zoo.get_model('retinaface_r50_v1')
# if you use gpu, set ctx_id=0
model.prepare(ctx_id=-1, nms=0.4)
bbox, landmark = model.detect(img, threshold=0.5, scale=1.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.