Closed martinenkoEduard closed 1 year ago
Does GhostFace needs face aligment / warping?
Hi,
Any face recognition model needs a face to be detected, cropped, and aligned before any inference.
Hello,
I have a clarification question, in the inference code you provided you did not mention about face detection. Does this mean that the model expects and image that already has the face detected and cropped from any face detection model?
def prepare_image_and_embedding(self, img_path, output_dir):
img_shape = (112, 112)
img = cv2.imread(img_path)
img = cv2.resize(img, img_shape, interpolation=cv2.INTER_AREA)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = np.expand_dims(img, axis=0)
emb = self.model_interf(img)
emb = normalize(np.array(emb).astype("float32"))[0]
img_class = int(img_path.split('/')[-2])
filename = os.path.basename(img_path)
np.savez(output_dir, embs=emb, imm_classes=img_class, filenames=filename)
return emb, img_class, filename
Hello,
I have a clarification question, in the inference code you provided you did not mention about face detection. Does this mean that the model expects and image that already has the face detected and cropped from any face detection model?
def prepare_image_and_embedding(self, img_path, output_dir): img_shape = (112, 112) img = cv2.imread(img_path) img = cv2.resize(img, img_shape, interpolation=cv2.INTER_AREA) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) img = np.expand_dims(img, axis=0) emb = self.model_interf(img) emb = normalize(np.array(emb).astype("float32"))[0] img_class = int(img_path.split('/')[-2]) filename = os.path.basename(img_path) np.savez(output_dir, embs=emb, imm_classes=img_class, filenames=filename) return emb, img_class, filename
Hi,
Yes for sure, any face recognition model expect the provided face image to be cropped, and aligned before passing it through the face recognition model.
You can use MTCNN to preprocess your data or you can inherently use face detector, and alignment before the face recognition model.
Please refer to: 1) https://github.com/leondgarse/Keras_insightface/blob/master/eval_folder.py
Does GhostFace needs face aligment / warping?