Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,196 +1,210 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
title = "AI Text Detector"
|
|
|
4 |
description = """
|
5 |
-
<div class="
|
6 |
-
|
7 |
-
|
8 |
-
</
|
9 |
-
<
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
<a href="https://aclanthology.org/2025.genaidetect-1.15/" target="_blank"
|
|
|
16 |
</div>
|
17 |
-
<br>
|
18 |
-
Paste your text below to analyze its origin.
|
19 |
"""
|
|
|
20 |
bottom_text = "**Developed by SzegedAI**"
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
.
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
}
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
}
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
return '<span class="highlight-human" role="alert" aria-live="polite">Detected as: Human-written</span>'
|
174 |
|
175 |
with iface:
|
176 |
-
with gr.Column(
|
|
|
177 |
gr.Markdown(description)
|
|
|
|
|
178 |
text_input = gr.Textbox(
|
179 |
-
label="",
|
180 |
-
placeholder="
|
181 |
elem_id="text_input_box",
|
182 |
-
lines=
|
183 |
-
show_label=False
|
184 |
)
|
|
|
|
|
|
|
|
|
|
|
185 |
result_output = gr.Markdown("", elem_id="result_output_box")
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
|
196 |
iface.launch(share=True)
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
title = "AI Text Detector"
|
4 |
+
|
5 |
description = """
|
6 |
+
<div class="hero">
|
7 |
+
<h1>π AI Text Detector</h1>
|
8 |
+
<p>
|
9 |
+
Built on the <b>ModernBERT</b> ensemble (3 variants, soft-voting).<br>
|
10 |
+
<span class="point">β
Human verification</span> |
|
11 |
+
<span class="point">π Detects 40+ AI models</span> |
|
12 |
+
<span class="point">π Best on longer passages</span>
|
13 |
+
</p>
|
14 |
+
<p class="paper">
|
15 |
+
Read the full paper β
|
16 |
+
<a href="https://aclanthology.org/2025.genaidetect-1.15/" target="_blank">LINK</a>
|
17 |
+
</p>
|
18 |
</div>
|
|
|
|
|
19 |
"""
|
20 |
+
|
21 |
bottom_text = "**Developed by SzegedAI**"
|
22 |
|
23 |
+
# ---------- UI ----------
|
24 |
+
iface = gr.Blocks(
|
25 |
+
theme=gr.themes.Default(), # keep defaults; we'll override in CSS
|
26 |
+
css="""
|
27 |
+
/* ---------- Global tokens ---------- */
|
28 |
+
:root{
|
29 |
+
--primary:#203A6B; /* midnight-indigo */
|
30 |
+
--accent :#14B8A6; /* teal-mint */
|
31 |
+
--bg :#F8FAFC; /* light-gray */
|
32 |
+
--bg-card:rgba(255,255,255,0.55);
|
33 |
+
--radius :16px;
|
34 |
+
--shadow :0 6px 24px rgba(0,0,0,.08);
|
35 |
+
--transition:180ms cubic-bezier(.4,0,.2,1);
|
36 |
+
--font:'Inter',system-ui,-apple-system,'Segoe UI',sans-serif;
|
37 |
+
}
|
38 |
+
|
39 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');
|
40 |
+
|
41 |
+
html,body{
|
42 |
+
font-family:var(--font);
|
43 |
+
background: var(--bg);
|
44 |
+
color:var(--primary);
|
45 |
+
height:100%;
|
46 |
+
margin:0;
|
47 |
+
}
|
48 |
+
|
49 |
+
/* ---------- Main container ---------- */
|
50 |
+
.gradio-container{
|
51 |
+
display:grid;
|
52 |
+
place-items:center;
|
53 |
+
padding:5vmin;
|
54 |
+
min-height:100dvh;
|
55 |
+
animation:fade-slide-in .6s ease-out both;
|
56 |
+
}
|
57 |
+
|
58 |
+
.container{
|
59 |
+
background:var(--bg-card);
|
60 |
+
backdrop-filter:blur(12px) saturate(120%);
|
61 |
+
border:1px solid rgba(255,255,255,.35);
|
62 |
+
border-radius:var(--radius);
|
63 |
+
box-shadow:var(--shadow);
|
64 |
+
padding:clamp(1.5rem,4vw,3rem);
|
65 |
+
width:min(680px,90vw);
|
66 |
+
display:grid;
|
67 |
+
gap:2rem;
|
68 |
+
}
|
69 |
+
|
70 |
+
/* ---------- Hero / heading ---------- */
|
71 |
+
.hero{
|
72 |
+
text-align:center;
|
73 |
+
line-height:1.6;
|
74 |
+
}
|
75 |
+
.hero h1{
|
76 |
+
margin:0 0 .5rem;
|
77 |
+
font-size:clamp(1.8rem,4vw,2.4rem);
|
78 |
+
font-weight:700;
|
79 |
+
}
|
80 |
+
.point{
|
81 |
+
font-weight:600;
|
82 |
+
}
|
83 |
+
.paper a{
|
84 |
+
color:var(--accent);
|
85 |
+
text-decoration:none;
|
86 |
+
font-weight:600;
|
87 |
+
}
|
88 |
+
|
89 |
+
/* ---------- Inputs & button ---------- */
|
90 |
+
#text_input_box{
|
91 |
+
border:2px solid rgba(32,58,107,.25);
|
92 |
+
border-radius:var(--radius);
|
93 |
+
padding:1rem 1.25rem;
|
94 |
+
font-size:1rem;
|
95 |
+
width:100%;
|
96 |
+
transition:border-color var(--transition), box-shadow var(--transition);
|
97 |
+
}
|
98 |
+
#text_input_box:focus{
|
99 |
+
outline:none;
|
100 |
+
border-color:var(--accent);
|
101 |
+
box-shadow:0 0 0 4px rgba(20,184,166,.18);
|
102 |
+
}
|
103 |
+
|
104 |
+
.analyze-btn{
|
105 |
+
display:inline-flex;
|
106 |
+
align-items:center;
|
107 |
+
justify-content:center;
|
108 |
+
gap:.5rem;
|
109 |
+
font-weight:600;
|
110 |
+
font-size:1rem;
|
111 |
+
padding:.9rem 1.6rem;
|
112 |
+
background:var(--primary);
|
113 |
+
color:#fff;
|
114 |
+
border:none;
|
115 |
+
border-radius:var(--radius);
|
116 |
+
cursor:pointer;
|
117 |
+
transition:transform var(--transition), box-shadow var(--transition);
|
118 |
+
}
|
119 |
+
.analyze-btn:hover{
|
120 |
+
transform:translateY(-2px);
|
121 |
+
box-shadow:0 8px 24px rgba(0,0,0,.12);
|
122 |
+
}
|
123 |
+
.analyze-btn:active{
|
124 |
+
transform:translateY(1px) scale(.98);
|
125 |
+
}
|
126 |
+
|
127 |
+
/* spinner placeholder */
|
128 |
+
.spinner{
|
129 |
+
width:1rem;height:1rem;
|
130 |
+
border:3px solid rgba(255,255,255,.4);
|
131 |
+
border-top-color:#fff;
|
132 |
+
border-radius:50%;
|
133 |
+
animation:spin 1s linear infinite;
|
134 |
+
}
|
135 |
+
|
136 |
+
@keyframes spin{to{transform:rotate(360deg);}}
|
137 |
+
|
138 |
+
/* ---------- Output box ---------- */
|
139 |
+
#result_output_box{
|
140 |
+
text-align:center;
|
141 |
+
font-size:1.15rem;
|
142 |
+
padding:1rem 1.5rem;
|
143 |
+
border-radius:var(--radius);
|
144 |
+
border:2px solid transparent;
|
145 |
+
min-height:3.5rem;
|
146 |
+
word-wrap:break-word;
|
147 |
+
}
|
148 |
+
.highlight-human{color:var(--accent);}
|
149 |
+
.highlight-ai{color:#EF4444;} /* red-500 */
|
150 |
+
|
151 |
+
/* ---------- Tabs ---------- */
|
152 |
+
.gradio-container .tabs{
|
153 |
+
margin-top:1rem!important;
|
154 |
+
}
|
155 |
+
.gradio-container .tab{
|
156 |
+
border:none!important;
|
157 |
+
}
|
158 |
+
.gradio-container .tabitem{
|
159 |
+
padding:.35rem .75rem!important;
|
160 |
+
border-radius:var(--radius) var(--radius) 0 0!important;
|
161 |
+
}
|
162 |
+
|
163 |
+
/* ---------- Utilities & media ---------- */
|
164 |
+
@media(max-width:768px){
|
165 |
+
.container{padding:1.25rem;}
|
166 |
+
}
|
167 |
+
|
168 |
+
@keyframes fade-slide-in{
|
169 |
+
from{opacity:0;transform:translateY(12px);}
|
170 |
+
to{opacity:1;transform:none;}
|
171 |
+
}
|
172 |
+
"""
|
173 |
+
)
|
|
|
174 |
|
175 |
with iface:
|
176 |
+
with gr.Column(elem_classes="container"):
|
177 |
+
# Hero section
|
178 |
gr.Markdown(description)
|
179 |
+
|
180 |
+
# Input
|
181 |
text_input = gr.Textbox(
|
182 |
+
label="Paste or type your text...",
|
183 |
+
placeholder="Start writing hereβ¦",
|
184 |
elem_id="text_input_box",
|
185 |
+
lines=6
|
|
|
186 |
)
|
187 |
+
|
188 |
+
# Analyze button (triggers classify_text)
|
189 |
+
analyze_btn = gr.Button("Analyze", elem_classes="analyze-btn")
|
190 |
+
|
191 |
+
# Output
|
192 |
result_output = gr.Markdown("", elem_id="result_output_box")
|
193 |
+
|
194 |
+
# Example tabs
|
195 |
+
with gr.Tab("AI examples"):
|
196 |
+
gr.Examples(examples=AI_texts, inputs=text_input)
|
197 |
+
with gr.Tab("Human examples"):
|
198 |
+
gr.Examples(examples=Human_texts, inputs=text_input)
|
199 |
+
|
200 |
+
gr.Markdown(bottom_text, elem_id="bottom_text", elem_classes="footer")
|
201 |
+
|
202 |
+
# Wire the interaction
|
203 |
+
analyze_btn.click(
|
204 |
+
fn=classify_text,
|
205 |
+
inputs=text_input,
|
206 |
+
outputs=result_output,
|
207 |
+
show_progress="minimal" # toggles spinner internally
|
208 |
+
)
|
209 |
|
210 |
iface.launch(share=True)
|