Working!
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
parent
81c1591b6b
commit
733b8feeba
@ -55,24 +55,27 @@ def extract_faces(img_path, threshold=0.9, model = None, align = True, allow_ups
|
||||
nose[0] -= x
|
||||
nose[1] -= y
|
||||
|
||||
width *= 0.25
|
||||
height *= 0.25
|
||||
width *= 1.25
|
||||
height *= 1.25
|
||||
|
||||
left = round(x - width * 0.5)
|
||||
right = round(left + width)
|
||||
top = round(y - height * 0.5)
|
||||
bottom = round(top + height)
|
||||
|
||||
facial_img = img[left: right, top: bottom]
|
||||
facial_img = img[top: bottom, left: right]
|
||||
|
||||
print(left, right, top, bottom, left_eye, right_eye, nose)
|
||||
aligned = RetinaFace.postprocess.alignment_procedure(facial_img, left_eye, right_eye, nose)
|
||||
# Eye order is reversed as the routine does them backwards
|
||||
aligned = RetinaFace.postprocess.alignment_procedure(facial_img, right_eye, left_eye, nose)
|
||||
|
||||
image = Image.fromarray(aligned)
|
||||
image.resize(size = (224,224), resample = Image.ANTIALIAS)
|
||||
image = image.resize(size = (224,224), resample = Image.LANCZOS)
|
||||
resized = np.asarray(image)
|
||||
else:
|
||||
facial_img = img[facial_area[1]: facial_area[3], facial_area[0]: facial_area[2]]
|
||||
facial_img = img[
|
||||
facial_area[1]: facial_area[3],
|
||||
facial_area[0]: facial_area[2]
|
||||
]
|
||||
resized = facial_img
|
||||
|
||||
identity['vector'] = DeepFace.represent(img_path = resized, model_name = 'ArcFace', detector_backend = 'opencv', enforce_detection = False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user