KarthikAI commited on
Commit
ed018a7
·
verified ·
1 Parent(s): af969a2

Update face_to_prompt.py

Browse files
Files changed (1) hide show
  1. 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
- age = deepface_result['age']
16
- gender = deepface_result['dominant_gender']
17
- race = deepface_result['dominant_race']
18
- emotion = deepface_result['dominant_emotion']
 
 
 
 
 
 
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'])