ZhenglinZhou / STAR

[CVPR 2023] STAR Loss: Reducing Semantic Ambiguity in Facial Landmark Detection
157 stars 17 forks source link

About Datasets Variables #13

Closed aylinSyntonym closed 12 months ago

aylinSyntonym commented 1 year ago

What is center_w and center_h which use in Alignment process in evaluation?

ZhenglinZhou commented 1 year ago

Hi @aylinSyntonym, thanks for your interest!

The center_w and center_h is the centric point of the face box. More details can be found here.

In my exp, to calculate these params of your own image, the following code could be considered:

import dlib

detector = dlib.get_frontal_face_detector()
sp = dlib.shape_predictor(predictor_path)

dets = detector(input_image, 1)
num_faces = len(dets)
results = []
for detection in dets:
    face = sp(input_image, detection)
    shape = []
    for i in range(68):
        x = face.part(i).x
        y = face.part(i).y
        shape.append((x, y))
    shape = np.array(shape)
    x1, x2 = shape[:, 0].min(), shape[:, 0].max()
    y1, y2 = shape[:, 1].min(), shape[:, 1].max()
    scale = min(x2 - x1, y2 - y1) / 200 * 1.05
    center_w = (x2 + x1) / 2
    center_h = (y2 + y1) / 2