Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -91,7 +91,6 @@ custom_css = f"""
|
|
| 91 |
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap');
|
| 92 |
|
| 93 |
/* --- 1. DEFAULT (DARK/NIGHT MODE) --- */
|
| 94 |
-
/* This applies when the page first loads or when 'light-mode' is NOT active */
|
| 95 |
:root, .dark, body {{
|
| 96 |
--bg-gradient: radial-gradient(circle at 50% 0%, #0a0a2e 0%, #000000 100%);
|
| 97 |
--card-bg: rgba(15, 15, 35, 0.7);
|
|
@@ -103,22 +102,23 @@ custom_css = f"""
|
|
| 103 |
--info-bg: rgba(212, 175, 55, 0.08);
|
| 104 |
--info-border: #d4af37;
|
| 105 |
--glow-color: rgba(212, 175, 55, 0.4);
|
|
|
|
| 106 |
}}
|
| 107 |
|
| 108 |
/* --- 2. LIGHT MODE OVERRIDE (PAPYRUS) --- */
|
| 109 |
-
/* We use high specificity (.gradio-container.light-mode) to defeat the OS dark mode */
|
| 110 |
body.light-mode, .gradio-container.light-mode {{
|
| 111 |
--bg-gradient: linear-gradient(135deg, #f0e6d2 0%, #e6dcc3 100%) !important;
|
| 112 |
--card-bg: rgba(255, 255, 255, 0.6) !important;
|
| 113 |
-
--text-primary: #3d342b !important;
|
| 114 |
-
--text-accent: #8b4513 !important;
|
| 115 |
--border-color: #8b4513 !important;
|
| 116 |
--btn-grad: linear-gradient(135deg, #cd853f 0%, #8b4513 100%) !important;
|
| 117 |
--btn-text: #fff !important;
|
| 118 |
--info-bg: rgba(139, 69, 19, 0.05) !important;
|
| 119 |
--info-border: #8b4513 !important;
|
| 120 |
--glow-color: rgba(139, 69, 19, 0.3) !important;
|
| 121 |
-
|
|
|
|
| 122 |
}}
|
| 123 |
|
| 124 |
/* --- GLOBAL LAYOUT --- */
|
|
@@ -147,13 +147,12 @@ button, a, .cursor-pointer {{
|
|
| 147 |
animation: fadeDust 0.6s linear forwards;
|
| 148 |
box-shadow: 0 0 5px var(--text-accent);
|
| 149 |
}}
|
| 150 |
-
|
| 151 |
@keyframes fadeDust {{
|
| 152 |
0% {{ opacity: 1; transform: scale(1); }}
|
| 153 |
100% {{ opacity: 0; transform: scale(0); }}
|
| 154 |
}}
|
| 155 |
|
| 156 |
-
/* --- CARDS --- */
|
| 157 |
.card {{
|
| 158 |
background: var(--card-bg) !important;
|
| 159 |
border: 1px solid rgba(128, 128, 128, 0.2) !important;
|
|
@@ -165,12 +164,26 @@ button, a, .cursor-pointer {{
|
|
| 165 |
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
|
| 166 |
color: var(--text-primary) !important;
|
| 167 |
}}
|
| 168 |
-
|
| 169 |
.card:hover {{
|
| 170 |
transform: translateY(-4px);
|
| 171 |
border-color: var(--border-color) !important;
|
| 172 |
box-shadow: 0 10px 40px rgba(0,0,0,0.2), 0 0 20px var(--glow-color);
|
| 173 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
|
| 175 |
/* --- BUTTONS --- */
|
| 176 |
button.primary-btn {{
|
|
@@ -188,7 +201,6 @@ button.primary-btn:hover {{
|
|
| 188 |
transform: scale(1.02);
|
| 189 |
box-shadow: 0 0 25px var(--glow-color);
|
| 190 |
}}
|
| 191 |
-
|
| 192 |
button.toggle-btn {{
|
| 193 |
background: transparent !important;
|
| 194 |
border: 1px solid var(--border-color) !important;
|
|
@@ -200,7 +212,7 @@ button.toggle-btn:hover {{
|
|
| 200 |
background: var(--info-bg) !important;
|
| 201 |
}}
|
| 202 |
|
| 203 |
-
/* --- GUIDE BOXES
|
| 204 |
.guide-step {{
|
| 205 |
background-color: var(--info-bg) !important;
|
| 206 |
border-left: 4px solid var(--info-border) !important;
|
|
@@ -210,9 +222,8 @@ button.toggle-btn:hover {{
|
|
| 210 |
font-family: 'Space Mono', monospace;
|
| 211 |
font-size: 13px;
|
| 212 |
line-height: 1.6;
|
| 213 |
-
color: var(--text-primary) !important;
|
| 214 |
}}
|
| 215 |
-
|
| 216 |
.step-number {{
|
| 217 |
color: var(--text-accent) !important;
|
| 218 |
font-weight: bold;
|
|
@@ -221,7 +232,6 @@ button.toggle-btn:hover {{
|
|
| 221 |
margin-bottom: 6px;
|
| 222 |
font-size: 12px;
|
| 223 |
}}
|
| 224 |
-
|
| 225 |
.path-highlight {{
|
| 226 |
background: rgba(128,128,128,0.2);
|
| 227 |
padding: 3px 8px;
|
|
@@ -231,27 +241,61 @@ button.toggle-btn:hover {{
|
|
| 231 |
border: 1px solid var(--border-color);
|
| 232 |
}}
|
| 233 |
|
| 234 |
-
/* --- FIXES --- */
|
| 235 |
-
.gradio-image, .gradio-json {{ background: transparent !important; border: none !important; }}
|
| 236 |
|
| 237 |
-
/*
|
| 238 |
-
body.light-mode .gradio-image
|
| 239 |
-
.
|
| 240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
border: 2px dashed var(--border-color) !important;
|
| 242 |
color: var(--text-primary) !important;
|
| 243 |
}}
|
| 244 |
|
|
|
|
| 245 |
.report-box textarea {{
|
| 246 |
-
background-color:
|
| 247 |
border: 1px solid var(--border-color) !important;
|
| 248 |
font-family: 'Space Mono', monospace !important;
|
| 249 |
-
color: var(--text-primary) !important;
|
| 250 |
font-size: 14px !important;
|
| 251 |
}}
|
| 252 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
.block-title {{ color: var(--text-accent) !important; }}
|
| 254 |
-
span {{ color: var(--text-primary); }}
|
| 255 |
"""
|
| 256 |
|
| 257 |
header_html = """
|
|
@@ -345,7 +389,7 @@ trail_script = """
|
|
| 345 |
<script>
|
| 346 |
document.addEventListener('DOMContentLoaded', () => {
|
| 347 |
document.addEventListener('mousemove', (e) => {
|
| 348 |
-
if (Math.random() > 0.7) return;
|
| 349 |
const dust = document.createElement('div');
|
| 350 |
dust.classList.add('gold-dust');
|
| 351 |
dust.style.left = e.clientX + 'px';
|
|
@@ -358,11 +402,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 358 |
"""
|
| 359 |
|
| 360 |
with gr.Blocks(title="Rosetta Decoder") as demo:
|
| 361 |
-
# Inject CSS & Trail Script
|
| 362 |
gr.HTML(f"<style>{custom_css}</style>")
|
| 363 |
gr.HTML(trail_script)
|
| 364 |
|
| 365 |
-
# Top Section
|
| 366 |
with gr.Row(elem_classes="header-row"):
|
| 367 |
with gr.Column(scale=4):
|
| 368 |
gr.HTML(header_html)
|
|
@@ -371,7 +413,6 @@ with gr.Blocks(title="Rosetta Decoder") as demo:
|
|
| 371 |
|
| 372 |
gr.HTML(mission_html)
|
| 373 |
|
| 374 |
-
# Workspace
|
| 375 |
with gr.Row():
|
| 376 |
with gr.Column(scale=1):
|
| 377 |
gr.HTML('<div class="card"><div class="card-title">INPUT IMAGE</div>')
|
|
@@ -396,13 +437,11 @@ with gr.Blocks(title="Rosetta Decoder") as demo:
|
|
| 396 |
out_json = gr.JSON(label="JSON Data")
|
| 397 |
gr.HTML('</div>')
|
| 398 |
|
| 399 |
-
# Footer
|
| 400 |
gr.HTML(guide_instructions_html)
|
| 401 |
gr.Code(value=claude_json_content, language="json", label="claude_desktop_config.json", interactive=False, lines=15)
|
| 402 |
gr.HTML("</div>")
|
| 403 |
|
| 404 |
-
#
|
| 405 |
-
# JS: Toggle 'light-mode' on body AND container to defeat OS dark mode
|
| 406 |
btn_toggle.click(None, None, None, js="() => { document.body.classList.toggle('light-mode'); document.querySelector('.gradio-container').classList.toggle('light-mode'); }")
|
| 407 |
|
| 408 |
btn_upload.click(fn=detect_hieroglyphs, inputs=[img_upload, slider_upload], outputs=[out_image, out_json, out_report, btn_download])
|
|
|
|
| 91 |
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap');
|
| 92 |
|
| 93 |
/* --- 1. DEFAULT (DARK/NIGHT MODE) --- */
|
|
|
|
| 94 |
:root, .dark, body {{
|
| 95 |
--bg-gradient: radial-gradient(circle at 50% 0%, #0a0a2e 0%, #000000 100%);
|
| 96 |
--card-bg: rgba(15, 15, 35, 0.7);
|
|
|
|
| 102 |
--info-bg: rgba(212, 175, 55, 0.08);
|
| 103 |
--info-border: #d4af37;
|
| 104 |
--glow-color: rgba(212, 175, 55, 0.4);
|
| 105 |
+
--input-bg: rgba(0,0,0,0.2);
|
| 106 |
}}
|
| 107 |
|
| 108 |
/* --- 2. LIGHT MODE OVERRIDE (PAPYRUS) --- */
|
|
|
|
| 109 |
body.light-mode, .gradio-container.light-mode {{
|
| 110 |
--bg-gradient: linear-gradient(135deg, #f0e6d2 0%, #e6dcc3 100%) !important;
|
| 111 |
--card-bg: rgba(255, 255, 255, 0.6) !important;
|
| 112 |
+
--text-primary: #3d342b !important;
|
| 113 |
+
--text-accent: #8b4513 !important;
|
| 114 |
--border-color: #8b4513 !important;
|
| 115 |
--btn-grad: linear-gradient(135deg, #cd853f 0%, #8b4513 100%) !important;
|
| 116 |
--btn-text: #fff !important;
|
| 117 |
--info-bg: rgba(139, 69, 19, 0.05) !important;
|
| 118 |
--info-border: #8b4513 !important;
|
| 119 |
--glow-color: rgba(139, 69, 19, 0.3) !important;
|
| 120 |
+
--input-bg: rgba(255, 255, 255, 0.7) !important;
|
| 121 |
+
color: var(--text-primary) !important;
|
| 122 |
}}
|
| 123 |
|
| 124 |
/* --- GLOBAL LAYOUT --- */
|
|
|
|
| 147 |
animation: fadeDust 0.6s linear forwards;
|
| 148 |
box-shadow: 0 0 5px var(--text-accent);
|
| 149 |
}}
|
|
|
|
| 150 |
@keyframes fadeDust {{
|
| 151 |
0% {{ opacity: 1; transform: scale(1); }}
|
| 152 |
100% {{ opacity: 0; transform: scale(0); }}
|
| 153 |
}}
|
| 154 |
|
| 155 |
+
/* --- CARDS & TITLES --- */
|
| 156 |
.card {{
|
| 157 |
background: var(--card-bg) !important;
|
| 158 |
border: 1px solid rgba(128, 128, 128, 0.2) !important;
|
|
|
|
| 164 |
transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
|
| 165 |
color: var(--text-primary) !important;
|
| 166 |
}}
|
|
|
|
| 167 |
.card:hover {{
|
| 168 |
transform: translateY(-4px);
|
| 169 |
border-color: var(--border-color) !important;
|
| 170 |
box-shadow: 0 10px 40px rgba(0,0,0,0.2), 0 0 20px var(--glow-color);
|
| 171 |
}}
|
| 172 |
+
.card-title {{
|
| 173 |
+
font-family: 'Cairo', sans-serif;
|
| 174 |
+
font-size: 20px;
|
| 175 |
+
font-weight: 700;
|
| 176 |
+
color: var(--text-accent) !important;
|
| 177 |
+
text-transform: uppercase;
|
| 178 |
+
letter-spacing: 2px;
|
| 179 |
+
border-bottom: 1px solid rgba(128,128,128, 0.2);
|
| 180 |
+
padding-bottom: 15px;
|
| 181 |
+
margin-bottom: 20px;
|
| 182 |
+
display: flex;
|
| 183 |
+
align-items: center;
|
| 184 |
+
justify-content: center;
|
| 185 |
+
gap: 8px;
|
| 186 |
+
}}
|
| 187 |
|
| 188 |
/* --- BUTTONS --- */
|
| 189 |
button.primary-btn {{
|
|
|
|
| 201 |
transform: scale(1.02);
|
| 202 |
box-shadow: 0 0 25px var(--glow-color);
|
| 203 |
}}
|
|
|
|
| 204 |
button.toggle-btn {{
|
| 205 |
background: transparent !important;
|
| 206 |
border: 1px solid var(--border-color) !important;
|
|
|
|
| 212 |
background: var(--info-bg) !important;
|
| 213 |
}}
|
| 214 |
|
| 215 |
+
/* --- GUIDE BOXES --- */
|
| 216 |
.guide-step {{
|
| 217 |
background-color: var(--info-bg) !important;
|
| 218 |
border-left: 4px solid var(--info-border) !important;
|
|
|
|
| 222 |
font-family: 'Space Mono', monospace;
|
| 223 |
font-size: 13px;
|
| 224 |
line-height: 1.6;
|
| 225 |
+
color: var(--text-primary) !important;
|
| 226 |
}}
|
|
|
|
| 227 |
.step-number {{
|
| 228 |
color: var(--text-accent) !important;
|
| 229 |
font-weight: bold;
|
|
|
|
| 232 |
margin-bottom: 6px;
|
| 233 |
font-size: 12px;
|
| 234 |
}}
|
|
|
|
| 235 |
.path-highlight {{
|
| 236 |
background: rgba(128,128,128,0.2);
|
| 237 |
padding: 3px 8px;
|
|
|
|
| 241 |
border: 1px solid var(--border-color);
|
| 242 |
}}
|
| 243 |
|
| 244 |
+
/* --- DEEP LIGHT MODE FIXES --- */
|
|
|
|
| 245 |
|
| 246 |
+
/* 1. Force Image Containers to be Light/Transparent in Light Mode */
|
| 247 |
+
body.light-mode .gradio-image,
|
| 248 |
+
body.light-mode .image-container,
|
| 249 |
+
body.light-mode .gradio-image > div {{
|
| 250 |
+
background-color: rgba(255, 255, 255, 0.4) !important;
|
| 251 |
+
}}
|
| 252 |
+
/* Fix the upload area button specifically */
|
| 253 |
+
body.light-mode .gradio-image button {{
|
| 254 |
+
background-color: rgba(255, 248, 240, 0.8) !important;
|
| 255 |
border: 2px dashed var(--border-color) !important;
|
| 256 |
color: var(--text-primary) !important;
|
| 257 |
}}
|
| 258 |
|
| 259 |
+
/* 2. Fix Analysis Log (Textbox) Background & Text */
|
| 260 |
.report-box textarea {{
|
| 261 |
+
background-color: var(--input-bg) !important; /* Uses variable now */
|
| 262 |
border: 1px solid var(--border-color) !important;
|
| 263 |
font-family: 'Space Mono', monospace !important;
|
| 264 |
+
color: var(--text-primary) !important;
|
| 265 |
font-size: 14px !important;
|
| 266 |
}}
|
| 267 |
|
| 268 |
+
/* 3. Fix Accordion/JSON in Light Mode */
|
| 269 |
+
body.light-mode .accordion {{
|
| 270 |
+
background-color: rgba(255, 255, 255, 0.5) !important;
|
| 271 |
+
border: 1px solid var(--border-color) !important;
|
| 272 |
+
}}
|
| 273 |
+
body.light-mode .accordion span,
|
| 274 |
+
body.light-mode .accordion label {{
|
| 275 |
+
color: var(--text-primary) !important;
|
| 276 |
+
}}
|
| 277 |
+
|
| 278 |
+
/* 4. Fix General Text Visibility */
|
| 279 |
+
body.light-mode span, .gradio-container.light-mode span,
|
| 280 |
+
body.light-mode p, .gradio-container.light-mode p {{
|
| 281 |
+
color: var(--text-primary) !important;
|
| 282 |
+
}}
|
| 283 |
+
body.light-mode .guide-step code {{
|
| 284 |
+
background-color: rgba(139, 69, 19, 0.1);
|
| 285 |
+
color: var(--text-accent) !important;
|
| 286 |
+
}}
|
| 287 |
+
body.light-mode .tab-nav button {{
|
| 288 |
+
color: var(--text-primary) !important;
|
| 289 |
+
opacity: 0.7;
|
| 290 |
+
}}
|
| 291 |
+
body.light-mode .tab-nav button.selected {{
|
| 292 |
+
color: var(--text-accent) !important;
|
| 293 |
+
opacity: 1;
|
| 294 |
+
}}
|
| 295 |
+
|
| 296 |
+
/* Cleanup */
|
| 297 |
+
.gradio-image, .gradio-json {{ background: transparent !important; border: none !important; }}
|
| 298 |
.block-title {{ color: var(--text-accent) !important; }}
|
|
|
|
| 299 |
"""
|
| 300 |
|
| 301 |
header_html = """
|
|
|
|
| 389 |
<script>
|
| 390 |
document.addEventListener('DOMContentLoaded', () => {
|
| 391 |
document.addEventListener('mousemove', (e) => {
|
| 392 |
+
if (Math.random() > 0.7) return;
|
| 393 |
const dust = document.createElement('div');
|
| 394 |
dust.classList.add('gold-dust');
|
| 395 |
dust.style.left = e.clientX + 'px';
|
|
|
|
| 402 |
"""
|
| 403 |
|
| 404 |
with gr.Blocks(title="Rosetta Decoder") as demo:
|
|
|
|
| 405 |
gr.HTML(f"<style>{custom_css}</style>")
|
| 406 |
gr.HTML(trail_script)
|
| 407 |
|
|
|
|
| 408 |
with gr.Row(elem_classes="header-row"):
|
| 409 |
with gr.Column(scale=4):
|
| 410 |
gr.HTML(header_html)
|
|
|
|
| 413 |
|
| 414 |
gr.HTML(mission_html)
|
| 415 |
|
|
|
|
| 416 |
with gr.Row():
|
| 417 |
with gr.Column(scale=1):
|
| 418 |
gr.HTML('<div class="card"><div class="card-title">INPUT IMAGE</div>')
|
|
|
|
| 437 |
out_json = gr.JSON(label="JSON Data")
|
| 438 |
gr.HTML('</div>')
|
| 439 |
|
|
|
|
| 440 |
gr.HTML(guide_instructions_html)
|
| 441 |
gr.Code(value=claude_json_content, language="json", label="claude_desktop_config.json", interactive=False, lines=15)
|
| 442 |
gr.HTML("</div>")
|
| 443 |
|
| 444 |
+
# JS Toggle Logic
|
|
|
|
| 445 |
btn_toggle.click(None, None, None, js="() => { document.body.classList.toggle('light-mode'); document.querySelector('.gradio-container').classList.toggle('light-mode'); }")
|
| 446 |
|
| 447 |
btn_upload.click(fn=detect_hieroglyphs, inputs=[img_upload, slider_upload], outputs=[out_image, out_json, out_report, btn_download])
|