Skip to content

Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks

License

Notifications You must be signed in to change notification settings

cardinalblue/mtcnn-pytorch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project is belongs to the original creator (https://github.com/khrlimam/mtcnn-pytorch). I just fixed some problems that may have been caused by newer version of PyTorch.

How to install

Install the package with pip:

https

pip install git https://github.com/cardinalblue/mtcnn-pytorch.git

ssh

pip install git ssh://[email protected]/cardinalblue/mtcnn-pytorch.git

How to use

from torch_mtcnn import detect_faces
from PIL import Image

image = Image.open('image.jpg')
bounding_boxes, landmarks = detect_faces(image)

You can use the bounding_boxes to crop the image (assuming there is only 1 face):

bounding_boxes = list(map(int, bounding_boxes[0]))
img_1 = cv2.imread(path)
img_1[ bounding_boxes[1] : bounding_boxes[3], bounding_boxes[0] : bounding_boxes[2]]

Autocrop

I have included a utility function get_faces. This function gets the image path and returns all of the faces in the image:

from torch_mtcnn import get_faces

faces = get_faces('img.jpg')

Requirements

Please see the requirements.txt

Credit

The original project belongs to https://github.com/khrlimam/mtcnn-pytorch.

About

Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 97.8%
  • Python 2.2%