SPP commited on
Commit ยท
38d0e2a
1
Parent(s): 3e70669
fix: dark hero header, colored submit button, path-safe examples
Browse files
app.py
CHANGED
|
@@ -174,15 +174,16 @@ def _build_tab(spec):
|
|
| 174 |
|
| 175 |
image_comp.change(fn=_on_image_change, inputs=[image_comp], outputs=all_outputs)
|
| 176 |
|
|
|
|
| 177 |
valid_examples = [
|
| 178 |
row for row in spec.examples
|
| 179 |
-
if row and
|
| 180 |
]
|
| 181 |
if valid_examples:
|
| 182 |
gr.Examples(
|
| 183 |
examples=valid_examples,
|
| 184 |
inputs=all_inputs,
|
| 185 |
-
label="Try an example",
|
| 186 |
cache_examples=False,
|
| 187 |
)
|
| 188 |
|
|
@@ -190,15 +191,36 @@ def _build_tab(spec):
|
|
| 190 |
# โโ Main demo โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 191 |
|
| 192 |
css = """
|
| 193 |
-
.submit-btn { font-size: 16px !important; padding: 12px 0 !important; }
|
| 194 |
footer { display: none !important; }
|
| 195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
@keyframes fadeSlideUp {
|
| 197 |
from { opacity: 0; transform: translateY(10px); }
|
| 198 |
to { opacity: 1; transform: translateY(0); }
|
| 199 |
}
|
| 200 |
.result-reveal { animation: fadeSlideUp 0.35s ease; }
|
| 201 |
|
|
|
|
| 202 |
@keyframes shimmer {
|
| 203 |
0% { background-position: -600px 0; }
|
| 204 |
100% { background-position: 600px 0; }
|
|
@@ -215,14 +237,30 @@ footer { display: none !important; }
|
|
| 215 |
|
| 216 |
with gr.Blocks(title="Vision Base", css=css, theme=gr.themes.Soft()) as demo:
|
| 217 |
gr.HTML(
|
| 218 |
-
'<div style="
|
| 219 |
-
'
|
| 220 |
-
'<
|
| 221 |
-
'
|
| 222 |
-
'
|
| 223 |
-
'<
|
| 224 |
-
'
|
| 225 |
-
'<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
)
|
| 227 |
|
| 228 |
with gr.Tabs():
|
|
@@ -232,8 +270,11 @@ with gr.Blocks(title="Vision Base", css=css, theme=gr.themes.Soft()) as demo:
|
|
| 232 |
_build_tab(spec)
|
| 233 |
|
| 234 |
gr.HTML(
|
| 235 |
-
'<div style="text-align:center;color:#
|
| 236 |
-
'
|
|
|
|
|
|
|
|
|
|
| 237 |
'</div>'
|
| 238 |
)
|
| 239 |
|
|
|
|
| 174 |
|
| 175 |
image_comp.change(fn=_on_image_change, inputs=[image_comp], outputs=all_outputs)
|
| 176 |
|
| 177 |
+
_app_root = Path(__file__).parent
|
| 178 |
valid_examples = [
|
| 179 |
row for row in spec.examples
|
| 180 |
+
if row and (_app_root / str(row[0])).exists()
|
| 181 |
]
|
| 182 |
if valid_examples:
|
| 183 |
gr.Examples(
|
| 184 |
examples=valid_examples,
|
| 185 |
inputs=all_inputs,
|
| 186 |
+
label="โฆ Try an example",
|
| 187 |
cache_examples=False,
|
| 188 |
)
|
| 189 |
|
|
|
|
| 191 |
# โโ Main demo โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 192 |
|
| 193 |
css = """
|
|
|
|
| 194 |
footer { display: none !important; }
|
| 195 |
|
| 196 |
+
/* โโ Submit button โโ */
|
| 197 |
+
.submit-btn {
|
| 198 |
+
font-size: 17px !important;
|
| 199 |
+
padding: 14px 0 !important;
|
| 200 |
+
margin-top: 6px !important;
|
| 201 |
+
background: linear-gradient(135deg, #1565c0 0%, #283593 100%) !important;
|
| 202 |
+
color: white !important;
|
| 203 |
+
border: none !important;
|
| 204 |
+
border-radius: 10px !important;
|
| 205 |
+
transition: opacity 0.15s !important;
|
| 206 |
+
}
|
| 207 |
+
.submit-btn:hover { opacity: 0.88 !important; }
|
| 208 |
+
|
| 209 |
+
/* โโ Tab bar โโ */
|
| 210 |
+
.tab-nav button {
|
| 211 |
+
font-size: 14px !important;
|
| 212 |
+
font-weight: 600 !important;
|
| 213 |
+
padding: 10px 16px !important;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
/* โโ Result reveal animation โโ */
|
| 217 |
@keyframes fadeSlideUp {
|
| 218 |
from { opacity: 0; transform: translateY(10px); }
|
| 219 |
to { opacity: 1; transform: translateY(0); }
|
| 220 |
}
|
| 221 |
.result-reveal { animation: fadeSlideUp 0.35s ease; }
|
| 222 |
|
| 223 |
+
/* โโ Shimmer loading skeleton โโ */
|
| 224 |
@keyframes shimmer {
|
| 225 |
0% { background-position: -600px 0; }
|
| 226 |
100% { background-position: 600px 0; }
|
|
|
|
| 237 |
|
| 238 |
with gr.Blocks(title="Vision Base", css=css, theme=gr.themes.Soft()) as demo:
|
| 239 |
gr.HTML(
|
| 240 |
+
'<div style="background:linear-gradient(135deg,#1a1a2e 0%,#16213e 55%,#0f3460 100%);'
|
| 241 |
+
'border-radius:14px;padding:28px 32px;margin-bottom:8px;color:white">'
|
| 242 |
+
'<div style="display:flex;align-items:center;gap:18px;flex-wrap:wrap">'
|
| 243 |
+
'<span style="font-size:52px;line-height:1">๐๏ธ</span>'
|
| 244 |
+
'<div style="flex:1;min-width:200px">'
|
| 245 |
+
'<h1 style="margin:0;font-size:28px;font-weight:800;color:white;letter-spacing:-.3px">'
|
| 246 |
+
'Vision Base</h1>'
|
| 247 |
+
'<p style="margin:5px 0 0;color:#a0b8d8;font-size:14px;line-height:1.5">'
|
| 248 |
+
'Four practical vision tools โ scan labels, raid your fridge,<br>'
|
| 249 |
+
'decode error codes, reveal object mysteries.</p>'
|
| 250 |
+
'</div>'
|
| 251 |
+
'<span style="background:#6a1b9a;color:white;padding:5px 14px;border-radius:20px;'
|
| 252 |
+
'font-size:12px;font-weight:700;letter-spacing:.4px;white-space:nowrap">'
|
| 253 |
+
'โก 1.3B params ยท Tiny Titan</span>'
|
| 254 |
+
'</div>'
|
| 255 |
+
'<div style="margin-top:16px;padding-top:14px;border-top:1px solid rgba(255,255,255,.1);'
|
| 256 |
+
'display:flex;gap:24px;flex-wrap:wrap">'
|
| 257 |
+
'<span style="color:#7090b8;font-size:12px">๐ Allergen Lens</span>'
|
| 258 |
+
'<span style="color:#7090b8;font-size:12px">๐ฝ๏ธ Fridge Dinner</span>'
|
| 259 |
+
'<span style="color:#9070b8;font-size:12px">๐ฎ Object Oracle</span>'
|
| 260 |
+
'<span style="color:#b07070;font-size:12px">๐ ๏ธ What\'s That Error?</span>'
|
| 261 |
+
'<span style="margin-left:auto;color:#506080;font-size:11px">MiniCPM-V 4.6 ยท ZeroGPU</span>'
|
| 262 |
+
'</div>'
|
| 263 |
+
'</div>'
|
| 264 |
)
|
| 265 |
|
| 266 |
with gr.Tabs():
|
|
|
|
| 270 |
_build_tab(spec)
|
| 271 |
|
| 272 |
gr.HTML(
|
| 273 |
+
'<div style="text-align:center;color:#bbb;font-size:11px;margin-top:12px;'
|
| 274 |
+
'padding-top:8px;border-top:1px solid #eee">'
|
| 275 |
+
'Powered by <b>MiniCPM-V 4.6 (1.3B)</b> ยท ZeroGPU ยท '
|
| 276 |
+
'<a href="https://huggingface.co/openbmb/MiniCPM-V-4.6" '
|
| 277 |
+
'style="color:#9090cc;text-decoration:none" target="_blank">OpenBMB</a>'
|
| 278 |
'</div>'
|
| 279 |
)
|
| 280 |
|