Update app.py
Browse files
app.py
CHANGED
@@ -5,11 +5,11 @@ import numpy as np
|
|
5 |
# import face_recognition
|
6 |
import subprocess
|
7 |
import sys
|
8 |
-
subprocess.check_call([sys.executable, "-m", "pip", "install", 'git+https://github.com/bit-guber/retinaface.git', "--force-reinstall"])
|
9 |
-
|
10 |
-
from retinaface import RetinaFace
|
11 |
|
|
|
12 |
|
|
|
13 |
|
14 |
torch.backends.cudnn.benchmark = True
|
15 |
|
@@ -169,8 +169,9 @@ def image_inference(image):
|
|
169 |
# for name, keys in RetinaFace.detect_faces( image ).items():
|
170 |
# rawfaces.append( keys['facial_area'] )
|
171 |
# faces = [ image[top:bottom, left:right].copy() for (top, left, bottom, right) in rawfaces ]
|
172 |
-
faces = RetinaFace.extract_faces( image, align = True)
|
173 |
-
faces_mean = [ x.mean() for x in faces ]
|
|
|
174 |
# faces = [ image[x:w+x, y:h+y].copy() for (x, y, w, h) in rawfaces ]
|
175 |
faces = [ Image.fromarray(x, mode = 'RGB') for x in faces ]
|
176 |
ages, genders, beards, blurs, ethncities, masks = AnalysisFeatures( faces )
|
|
|
5 |
# import face_recognition
|
6 |
import subprocess
|
7 |
import sys
|
8 |
+
# subprocess.check_call([sys.executable, "-m", "pip", "install", 'git+https://github.com/bit-guber/retinaface.git', "--force-reinstall"])
|
|
|
|
|
9 |
|
10 |
+
# from retinaface import RetinaFace
|
11 |
|
12 |
+
from deepface import DeepFace
|
13 |
|
14 |
torch.backends.cudnn.benchmark = True
|
15 |
|
|
|
169 |
# for name, keys in RetinaFace.detect_faces( image ).items():
|
170 |
# rawfaces.append( keys['facial_area'] )
|
171 |
# faces = [ image[top:bottom, left:right].copy() for (top, left, bottom, right) in rawfaces ]
|
172 |
+
# faces = RetinaFace.extract_faces( image, align = True)
|
173 |
+
# faces_mean = [ x.mean() for x in faces ]
|
174 |
+
faces = [ x['face'] for x in DeepFace.extract_faces( image )]
|
175 |
# faces = [ image[x:w+x, y:h+y].copy() for (x, y, w, h) in rawfaces ]
|
176 |
faces = [ Image.fromarray(x, mode = 'RGB') for x in faces ]
|
177 |
ages, genders, beards, blurs, ethncities, masks = AnalysisFeatures( faces )
|