VictorM-Coder commited on
Commit
6a9422a
·
verified ·
1 Parent(s): fbbdb4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
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.60
31
 
32
  # -----------------------------
33
  # PROTECT STRUCTURE
@@ -126,12 +126,13 @@ def analyze(text):
126
  highlighted_html += block
127
  highlighted_html += "</div>"
128
 
129
- # --- THE FIXES ---
130
- # 1. Verdict Label Fix
131
- label = "AI Content Detected" if weighted_avg >= THRESHOLD else "0 or * AI Content Detected"
132
-
133
- # 2. Weighted Score Fix: If below 50%, show '*'
134
- display_score = f"{weighted_avg:.1%}" if weighted_avg >= 0.50 else "*"
 
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. **Green < 60% | Score masked if < 50%**")
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):