Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,8 +26,8 @@ def get_model():
|
|
| 26 |
).to(device).eval()
|
| 27 |
return tokenizer, model
|
| 28 |
|
| 29 |
-
# Threshold for Verdict Label
|
| 30 |
-
THRESHOLD = 0.
|
| 31 |
|
| 32 |
# -----------------------------
|
| 33 |
# PROTECT STRUCTURE
|
|
@@ -126,12 +126,13 @@ def analyze(text):
|
|
| 126 |
highlighted_html += block
|
| 127 |
highlighted_html += "</div>"
|
| 128 |
|
| 129 |
-
# ---
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
| 135 |
|
| 136 |
df = pd.DataFrame({"Sentence": pure_sents, "AI Confidence": [f"{p:.1%}" for p in probs]})
|
| 137 |
return label, display_score, highlighted_html, df
|
|
@@ -141,7 +142,7 @@ def analyze(text):
|
|
| 141 |
# -----------------------------
|
| 142 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 143 |
gr.Markdown("## 🕵️ AI Detector Pro")
|
| 144 |
-
gr.Markdown("Sentence-level analysis. **
|
| 145 |
|
| 146 |
with gr.Row():
|
| 147 |
with gr.Column(scale=3):
|
|
|
|
| 26 |
).to(device).eval()
|
| 27 |
return tokenizer, model
|
| 28 |
|
| 29 |
+
# Threshold for Verdict Label (Updated to match your 40% logic)
|
| 30 |
+
THRESHOLD = 0.41
|
| 31 |
|
| 32 |
# -----------------------------
|
| 33 |
# PROTECT STRUCTURE
|
|
|
|
| 126 |
highlighted_html += block
|
| 127 |
highlighted_html += "</div>"
|
| 128 |
|
| 129 |
+
# --- UPDATED LOGIC PER REQUEST ---
|
| 130 |
+
if weighted_avg > 0.40:
|
| 131 |
+
label = f"{weighted_avg:.0%} AI Content Detected"
|
| 132 |
+
display_score = f"{weighted_avg:.1%}"
|
| 133 |
+
else:
|
| 134 |
+
label = "0 or * AI Content Detected"
|
| 135 |
+
display_score = "*"
|
| 136 |
|
| 137 |
df = pd.DataFrame({"Sentence": pure_sents, "AI Confidence": [f"{p:.1%}" for p in probs]})
|
| 138 |
return label, display_score, highlighted_html, df
|
|
|
|
| 142 |
# -----------------------------
|
| 143 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 144 |
gr.Markdown("## 🕵️ AI Detector Pro")
|
| 145 |
+
gr.Markdown("Sentence-level analysis. **Score is hidden (*) if at or below 40%.**")
|
| 146 |
|
| 147 |
with gr.Row():
|
| 148 |
with gr.Column(scale=3):
|