bonito
Browse files
app.py
CHANGED
|
@@ -20,6 +20,26 @@ from transformers import (
|
|
| 20 |
AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 21 |
)
|
| 22 |
import re
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
CYRILLIC_RE = re.compile(r"[А-Яа-яЁё]")
|
| 25 |
|
|
@@ -156,12 +176,54 @@ def run_pipeline(user_text: str) -> tuple[str, str, str]:
|
|
| 156 |
return pretty, ru_text, info
|
| 157 |
|
| 158 |
# -------------------- Gradio UI --------------------
|
| 159 |
-
with gr.Blocks(theme=
|
| 160 |
-
|
| 161 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
""") as demo:
|
| 163 |
-
gr.Markdown("<h1 id='title'>DiMa_new — Discourse Marker Demo
|
| 164 |
-
gr.Markdown("
|
| 165 |
|
| 166 |
with gr.Row():
|
| 167 |
inp = gr.Textbox(label="English or Russian input", placeholder="e.g., In fact, we should probably leave now.", lines=3)
|
|
|
|
| 20 |
AutoTokenizer, AutoModelForSequenceClassification, pipeline
|
| 21 |
)
|
| 22 |
import re
|
| 23 |
+
from gradio.themes.utils import colors, sizes
|
| 24 |
+
|
| 25 |
+
THEME = gr.themes.Soft(
|
| 26 |
+
primary_hue=colors.red,
|
| 27 |
+
secondary_hue=colors.orange,
|
| 28 |
+
neutral_hue=colors.gray,
|
| 29 |
+
radius_size=sizes.radius_xxl, # todo redondito
|
| 30 |
+
)
|
| 31 |
+
THEME.set(
|
| 32 |
+
body_background_fill="#FFF7F2", # fondo crema
|
| 33 |
+
block_background_fill="#FFFFFF",
|
| 34 |
+
block_border_color="#FFD6C2",
|
| 35 |
+
block_border_width="1px",
|
| 36 |
+
block_shadow="0 10px 30px rgba(255, 107, 53, 0.10)",
|
| 37 |
+
input_background_fill="#FFFDFC",
|
| 38 |
+
input_border_color="#FFC7B3",
|
| 39 |
+
button_primary_background_fill="*primary_500",
|
| 40 |
+
button_primary_background_fill_hover="*primary_600",
|
| 41 |
+
button_primary_text_color="#FFFFFF",
|
| 42 |
+
)
|
| 43 |
|
| 44 |
CYRILLIC_RE = re.compile(r"[А-Яа-яЁё]")
|
| 45 |
|
|
|
|
| 176 |
return pretty, ru_text, info
|
| 177 |
|
| 178 |
# -------------------- Gradio UI --------------------
|
| 179 |
+
with gr.Blocks(theme=THEME, css="""
|
| 180 |
+
/* fondo suave con degradado */
|
| 181 |
+
.gradio-container {
|
| 182 |
+
background: radial-gradient(1200px 600px at 80% -10%, #FFE7DE 0%, rgba(255,231,222,0) 60%) ,
|
| 183 |
+
linear-gradient(180deg, #FFF7F2 0%, #FFFFFF 60%);
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
/* títulos */
|
| 187 |
+
#title { text-align:center; }
|
| 188 |
+
#title h1 {
|
| 189 |
+
font-weight: 800;
|
| 190 |
+
letter-spacing: .2px;
|
| 191 |
+
color: #E53935; /* rojo principal */
|
| 192 |
+
}
|
| 193 |
+
#subtitle {
|
| 194 |
+
text-align:center;
|
| 195 |
+
color: #FF7043; /* naranja suave */
|
| 196 |
+
margin-top: -8px;
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
/* componentes redonditos + sombras suaves */
|
| 200 |
+
.gr-box, .gr-panel, .gr-group { border-radius: 20px !important; }
|
| 201 |
+
button, .gr-button { border-radius: 999px !important; }
|
| 202 |
+
textarea, input, .gr-textbox { border-radius: 16px !important; }
|
| 203 |
+
|
| 204 |
+
/* botones primarios con leve glow */
|
| 205 |
+
button.primary, .gr-button-primary {
|
| 206 |
+
box-shadow: 0 8px 20px rgba(229,57,53,0.18);
|
| 207 |
+
}
|
| 208 |
+
button.primary:hover, .gr-button-primary:hover {
|
| 209 |
+
box-shadow: 0 10px 28px rgba(229,57,53,0.25);
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
/* cajitas informativas */
|
| 213 |
+
.accordion { border-radius: 16px !important; overflow: hidden; }
|
| 214 |
+
|
| 215 |
+
/* pill para el resultado */
|
| 216 |
+
#result-pill {
|
| 217 |
+
border-radius: 999px;
|
| 218 |
+
padding: 12px 18px;
|
| 219 |
+
background: #FFE6DE;
|
| 220 |
+
color: #D84315;
|
| 221 |
+
font-weight: 700;
|
| 222 |
+
display: inline-block;
|
| 223 |
+
}
|
| 224 |
""") as demo:
|
| 225 |
+
gr.Markdown("<h1 id='title'>DiMa_new — 🇷🇺✨ Discourse Marker Demo</h1>")
|
| 226 |
+
gr.Markdown("<div id='subtitle'>English <i>or</i> Russian → detect candidates → show only DMs</div>")
|
| 227 |
|
| 228 |
with gr.Row():
|
| 229 |
inp = gr.Textbox(label="English or Russian input", placeholder="e.g., In fact, we should probably leave now.", lines=3)
|