VictorM-Coder commited on
Commit
3535cf7
·
verified ·
1 Parent(s): 6cabfbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -80,14 +80,21 @@ def classify_sentence_by_sentence(text, threshold=0.70, max_len=512):
80
  ai_p = float(probs[i-1, 1].item())
81
  label = "AI" if ai_p >= threshold else "Human"
82
  pct = f"{ai_p*100:.1f}%"
83
- # color
84
- if ai_p < 0.30: color = "#11823b" # green
85
- elif ai_p < 0.70: color = "#b8860b" # amber
86
- else: color = "#b80d0d" # red
 
 
 
 
 
 
 
 
87
  highlights.append(
88
- f"<div style='margin:6px 0; padding:6px 8px; border-radius:6px; background:rgba(0,0,0,0.03)'>"
89
- f"<strong style='color:{color}'>[{pct} {label}]</strong> "
90
- f"{re.sub(r'\\s+', ' ', s)}</div>"
91
  )
92
  rows.append([i, s, round(ai_p, 4), label])
93
 
 
80
  ai_p = float(probs[i-1, 1].item())
81
  label = "AI" if ai_p >= threshold else "Human"
82
  pct = f"{ai_p*100:.1f}%"
83
+
84
+ # choose color
85
+ if ai_p < 0.30:
86
+ color = "#11823b" # green
87
+ elif ai_p < 0.70:
88
+ color = "#b8860b" # amber
89
+ else:
90
+ color = "#b80d0d" # red
91
+
92
+ # ✅ avoid backslashes inside the f-string expression
93
+ normalized = re.sub(r"\s+", " ", s)
94
+
95
  highlights.append(
96
+ "<div style='margin:6px 0; padding:6px 8px; border-radius:6px; background:rgba(0,0,0,0.03)'>"
97
+ f"<strong style='color:{color}'>[{pct} {label}]</strong> {normalized}</div>"
 
98
  )
99
  rows.append([i, s, round(ai_p, 4), label])
100