Last active
December 23, 2019 11:43
-
-
Save iamatulsingh/94d18ff80d73fa599443f2ef1c1d4e97 to your computer and use it in GitHub Desktop.
face recognition model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def crop_face(filename, required_size=(224, 224)): | |
img = cv2.imread(filename) | |
detector = MTCNN() | |
results = detector.detect_faces(img) | |
x, y, width, height = results[0]['box'] | |
face = img[y:y+height, x:x+width] | |
image = Image.fromarray(face) | |
image = image.resize(required_size) | |
face_array = np.asarray(image) | |
return face_array, face |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment