Gitiles
Code Review
Sign In
code.v1.dodo.cloud
/
pcloud
/
e25ce1c3c72fc5a8f319d54bb0edcf3e2326e912
/
.
/
apps
/
face_detection
/
mtcnn.py
blob: 3a128a0225fd8be4d0c7fdc1a9e78b9a069ab924 [
file
] [
log
] [
blame
]
from
facenet_pytorch
import
MTCNN
from
PIL
import
Image
def
detect_faces
(
img_file
):
mtcnn
=
MTCNN
(
keep_all
=
True
)
ret
=
[]
with
Image
.
open
(
img_file
)
as
img
:
for
box
in
mtcnn
.
detect
(
img
)[
0
]:
ret
.
append
((
box
[
0
],
box
[
1
],
box
[
2
],
box
[
3
]))
return
ret