Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
highlights.append(
|
| 88 |
-
|
| 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 |
|