2023-05-28 20:19:40 +05:30
|
|
|
import insightface
|
2023-05-29 17:39:29 +05:30
|
|
|
import onnxruntime
|
2023-05-29 19:04:00 +05:30
|
|
|
import core.globals
|
2023-05-28 20:19:40 +05:30
|
|
|
|
2023-05-29 19:04:00 +05:30
|
|
|
face_analyser = insightface.app.FaceAnalysis(name='buffalo_l', providers=core.globals.providers)
|
2023-05-28 20:19:40 +05:30
|
|
|
face_analyser.prepare(ctx_id=0, det_size=(640, 640))
|
|
|
|
|
|
|
|
|
|
|
|
def get_face(img_data):
|
|
|
|
analysed = face_analyser.get(img_data)
|
2023-05-29 17:50:26 +05:30
|
|
|
try:
|
|
|
|
return sorted(analysed, key=lambda x: x.bbox[0])[0]
|
|
|
|
except IndexError:
|
|
|
|
return None
|