MTCNN using Pytorch.
Project description
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. Also this project is available to install from pypi: pip install torch-mtcnn
How to install
Install the package with pip: pip install torch-mtcnn
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pytorch-mtcnn-0.0.1.tar.gz
.
File metadata
- Download URL: pytorch-mtcnn-0.0.1.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
0edd2e46db6567d1d4824ad6d3cc3f79ba2dfce311d3122928d20ce58ff88218
|
|
MD5 |
c32a17152b9be6658b9a719b313a0b41
|
|
BLAKE2b-256 |
efa644a3793fe5b90033a019890c0399155399b4b80004ce666b76b57f970d2b
|