Spaces:
Running
Running
Update face_to_prompt.py
Browse files- face_to_prompt.py +10 -4
face_to_prompt.py
CHANGED
@@ -12,10 +12,16 @@ def extract_face_prompt(img_path):
|
|
12 |
deepface_result = DeepFace.analyze(
|
13 |
img_path, actions=['age', 'gender', 'race', 'emotion'], enforce_detection=False
|
14 |
)
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
# InsightFace analysis
|
21 |
model = insightface.app.FaceAnalysis(name='buffalo_l', providers=['CPUExecutionProvider'])
|
|
|
12 |
deepface_result = DeepFace.analyze(
|
13 |
img_path, actions=['age', 'gender', 'race', 'emotion'], enforce_detection=False
|
14 |
)
|
15 |
+
|
16 |
+
if isinstance(deepface_result, list):
|
17 |
+
result = deepface_result[0]
|
18 |
+
else:
|
19 |
+
result = deepface_result
|
20 |
+
|
21 |
+
age = result['age']
|
22 |
+
gender = result['dominant_gender']
|
23 |
+
race = result['dominant_race']
|
24 |
+
emotion = result['dominant_emotion']
|
25 |
|
26 |
# InsightFace analysis
|
27 |
model = insightface.app.FaceAnalysis(name='buffalo_l', providers=['CPUExecutionProvider'])
|