facenet-pytorch
facenet-pytorch copied to clipboard
Unaligned face and darkened result returned with certain config
I have small experiment to extract face from a photo. This is my config:
def face_detector(img):
mdl = MTCNN(image_size=256,
margin=0,
min_face_size=20,
thresholds=[0.6, 0.7, 0.7],
factor=0.709,
select_largest=True,
selection_method="largest",
post_process=True,
keep_all=False,
device=device)
detected,prob = mdl(img,return_prob=True)
return detected,prob
```
when i plot original and the faces. some of them are unaligned to vertical position. And most of the image are darker than original image.
Alignment in literature is often understood only as cropped (and padded) so the center of the face would be the same for all faces [1]. In this case, the result of this MTCNN's implementation is aligned. If you want to rotate the face so the eyes line would make a vertical line, then you have to do it yourself. Admittedly, it's not always trivial. The result of MTCNN is a tensor of the face region of the image, post-processed through some normalization, so the value would be between [-1,+1]. Therefore, if you show them using plt.imshow(), some clipping would happen (imshow() expects float values in [0,1] only), which causes the image to appear darker. But for further processing in Resnet (for example embedding), it would not affect the outcome.
because face had normalization in the script of mtcnn.py, which name "fixed_image_standardization"