mariamSoub commited on
Commit
dc93d50
·
verified ·
1 Parent(s): d954537

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -14
app.py CHANGED
@@ -380,24 +380,12 @@ def parse_bias_response(bias_analysis_text):
380
 
381
  return result
382
 
383
- def run_auto_fairness_test():
384
- global ALL_Y_TRUE, ALL_Y_PRED, ALL_GROUPS
385
-
386
- # reset
387
- ALL_Y_TRUE = []
388
- ALL_Y_PRED = []
389
- ALL_GROUPS = []
390
 
391
- # 🔥 ONLY RUN FIRST 10–15 (NOT 50)
392
- for sample in AUTO_TEST_SAMPLES[:15]:
393
- analyze_response(sample)
394
-
395
- print("Auto samples loaded:", len(ALL_Y_TRUE))
396
 
397
  print("Loading models...")
398
  bias_pipe, regard_classifier = setup_models()
399
  print("Models loaded successfully!")
400
- run_auto_fairness_test()
401
 
402
  AUTO_TEST_SAMPLES = [
403
  # Gender bias
@@ -462,6 +450,21 @@ AUTO_TEST_SAMPLES = [
462
  "Women prefer less demanding careers.",
463
  "Men are naturally more competitive."
464
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
465
  def analyze_response(user_response):
466
  """Main analysis function for Gradio"""
467
 
@@ -624,5 +627,5 @@ with gr.Blocks(title="Bias Detection & Mitigation Tool") as demo:
624
  """)
625
 
626
  if __name__ == "__main__":
627
-
628
  demo.launch()
 
380
 
381
  return result
382
 
 
 
 
 
 
 
 
383
 
 
 
 
 
 
384
 
385
  print("Loading models...")
386
  bias_pipe, regard_classifier = setup_models()
387
  print("Models loaded successfully!")
388
+
389
 
390
  AUTO_TEST_SAMPLES = [
391
  # Gender bias
 
450
  "Women prefer less demanding careers.",
451
  "Men are naturally more competitive."
452
  ]
453
+ def run_auto_fairness_test():
454
+ global ALL_Y_TRUE, ALL_Y_PRED, ALL_GROUPS
455
+
456
+ # reset
457
+ ALL_Y_TRUE = []
458
+ ALL_Y_PRED = []
459
+ ALL_GROUPS = []
460
+
461
+ # 🔥 ONLY RUN FIRST 10–15 (NOT 50)
462
+ for sample in AUTO_TEST_SAMPLES[:15]:
463
+ analyze_response(sample)
464
+
465
+ print("Auto samples loaded:", len(ALL_Y_TRUE))
466
+
467
+
468
  def analyze_response(user_response):
469
  """Main analysis function for Gradio"""
470
 
 
627
  """)
628
 
629
  if __name__ == "__main__":
630
+ run_auto_fairness_test()
631
  demo.launch()