| giolekva | edbaf32 | 2020-05-05 18:17:37 +0400 | [diff] [blame] | 1 | from facenet_pytorch import MTCNN |
| 2 | from PIL import Image | ||||
| 3 | |||||
| 4 | |||||
| 5 | def detect_faces(img_file): | ||||
| 6 | mtcnn = MTCNN(keep_all=True) | ||||
| 7 | ret = [] | ||||
| 8 | with Image.open(img_file) as img: | ||||
| 9 | for box in mtcnn.detect(img)[0]: | ||||
| 10 | ret.append((box[0], box[1], box[2], box[3])) | ||||
| 11 | return ret | ||||