roop/core/config.py

14 lines
385 B
Python
Raw Normal View History

2023-05-28 17:49:40 +03:00
import insightface
2023-05-29 15:09:29 +03:00
import onnxruntime
2023-05-28 17:49:40 +03:00
2023-05-29 15:09:29 +03:00
face_analyser = insightface.app.FaceAnalysis(name='buffalo_l', providers=onnxruntime.get_available_providers())
2023-05-28 17:49:40 +03:00
face_analyser.prepare(ctx_id=0, det_size=(640, 640))
def get_face(img_data):
analysed = face_analyser.get(img_data)
2023-05-29 15:20:26 +03:00
try:
return sorted(analysed, key=lambda x: x.bbox[0])[0]
except IndexError:
return None