primerz commited on
Commit
8d74c34
·
verified ·
1 Parent(s): 003dcbd

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +24 -5
utils.py CHANGED
@@ -300,11 +300,30 @@ def get_facial_attributes(face):
300
  confidence = float(emotion[emotion_idx])
301
 
302
  if confidence > 0.4: # Only add if confident
 
 
 
303
  if emotion_name == 'happiness':
304
- attributes['expression'] = 'smiling'
305
- attributes['description'].append('smiling')
306
- elif emotion_name not in ['neutral']:
307
- attributes['expression'] = emotion_name
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  except (ValueError, TypeError, AttributeError, IndexError) as e:
309
  # Expression not available in this model
310
  pass
@@ -506,4 +525,4 @@ def enhance_face_crop(face_crop):
506
  return face_crop_final
507
 
508
 
509
- print("[OK] Utilities loaded")
 
300
  confidence = float(emotion[emotion_idx])
301
 
302
  if confidence > 0.4: # Only add if confident
303
+
304
+ expression_desc = None
305
+
306
  if emotion_name == 'happiness':
307
+ expression_desc = 'smiling'
308
+ elif emotion_name == 'surprise':
309
+ expression_desc = 'surprised expression'
310
+ elif emotion_name == 'sadness':
311
+ expression_desc = 'sad expression'
312
+ elif emotion_name == 'anger':
313
+ expression_desc = 'angry expression'
314
+ elif emotion_name == 'neutral':
315
+ expression_desc = 'neutral expression'
316
+
317
+ # Add other emotions like 'disgust' or 'fear' if desired
318
+
319
+ if expression_desc:
320
+ attributes['expression'] = expression_desc
321
+
322
+ # Only add non-neutral expressions to the prompt description
323
+ if emotion_name != 'neutral':
324
+ if expression_desc not in attributes['description']:
325
+ attributes['description'].append(expression_desc)
326
+
327
  except (ValueError, TypeError, AttributeError, IndexError) as e:
328
  # Expression not available in this model
329
  pass
 
525
  return face_crop_final
526
 
527
 
528
+ print("[OK] Utilities loaded")