kkAsmaa commited on
Commit
e832ad0
·
verified ·
1 Parent(s): b95a972

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -67,6 +67,7 @@ def predict_safety_api(text):
67
  total_windows_count = len(windows)
68
  is_blocked = False
69
  highest_unsafe_prob = 0.0
 
70
  windows_analysis = []
71
  triggered_windows = []
72
 
@@ -99,8 +100,13 @@ def predict_safety_api(text):
99
  is_blocked = True
100
  highest_unsafe_prob = max(highest_unsafe_prob, unsafe_prob)
101
  triggered_windows.append(idx + 1)
 
 
 
102
 
103
  final_prediction = "UNSAFE" if is_blocked else "SAFE"
 
 
104
 
105
  unsafe_confidence_score = round(highest_unsafe_prob, 4)
106
  safe_confidence_score = round(1.0 - highest_unsafe_prob, 4)
 
67
  total_windows_count = len(windows)
68
  is_blocked = False
69
  highest_unsafe_prob = 0.0
70
+ highest_safe_prob = 0.0
71
  windows_analysis = []
72
  triggered_windows = []
73
 
 
100
  is_blocked = True
101
  highest_unsafe_prob = max(highest_unsafe_prob, unsafe_prob)
102
  triggered_windows.append(idx + 1)
103
+
104
+ else:
105
+ highest_safe_prob = max(highest_safe_prob, safe_prob)
106
 
107
  final_prediction = "UNSAFE" if is_blocked else "SAFE"
108
+ winning_probability = highest_unsafe_prob if is_blocked else highest_safe_prob
109
+ formatted_confidence= f"{winning_probability *100:.2f}%"
110
 
111
  unsafe_confidence_score = round(highest_unsafe_prob, 4)
112
  safe_confidence_score = round(1.0 - highest_unsafe_prob, 4)