Spaces:
Running on Zero
Running on Zero
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -148,6 +148,7 @@ button.sm {
|
|
| 148 |
#header h1 {
|
| 149 |
margin: 0; font-size: 2.7rem; font-weight: 750;
|
| 150 |
color: var(--pg-ink); letter-spacing: -.025em;
|
|
|
|
| 151 |
}
|
| 152 |
#header .tagline {
|
| 153 |
margin: 8px 0 0; font-size: 1.02rem; color: var(--pg-muted); font-weight: 400;
|
|
@@ -314,53 +315,68 @@ def _selected_label(pid: int | None, info: dict | None) -> str:
|
|
| 314 |
return f"### Opening phrase: #{pid} ({info['mode'].capitalize()})"
|
| 315 |
|
| 316 |
|
| 317 |
-
# ββ Easter eggs π±
|
| 318 |
-
#
|
| 319 |
-
#
|
| 320 |
-
|
| 321 |
-
()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
if (window.__catEggs) return; window.__catEggs = true;
|
| 323 |
|
| 324 |
-
// 1. Console cat
|
| 325 |
console.log(
|
| 326 |
"%c /\\_/\\ ProGress\n( o.o ) cat-powered graph diffusion =^.^=\n > ^ < ",
|
| 327 |
"color:#2563eb;font-weight:bold;"
|
| 328 |
);
|
| 329 |
|
| 330 |
-
//
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
// 3. Konami code β cat rain
|
| 341 |
-
const seq = [38,38,40,40,37,39,37,39,66,65]; let i = 0;
|
| 342 |
-
document.addEventListener('keydown', (e) => {
|
| 343 |
-
i = (e.keyCode === seq[i]) ? i + 1 : (e.keyCode === seq[0] ? 1 : 0);
|
| 344 |
-
if (i === seq.length) {
|
| 345 |
-
i = 0;
|
| 346 |
-
for (let k = 0; k < 24; k++) {
|
| 347 |
-
const c = document.createElement('div');
|
| 348 |
-
c.textContent = ['π±','π','πΊ','π»','πΎ'][k % 5];
|
| 349 |
-
c.style.cssText =
|
| 350 |
-
'position:fixed;top:-48px;left:' + (Math.random()*100) + 'vw;' +
|
| 351 |
-
'font-size:' + (20 + Math.random()*28) + 'px;z-index:99999;' +
|
| 352 |
-
'pointer-events:none;transition:transform 3s linear,opacity 3s;';
|
| 353 |
-
document.body.appendChild(c);
|
| 354 |
-
requestAnimationFrame(() => {
|
| 355 |
-
c.style.transform = 'translateY(' + (window.innerHeight + 96) +
|
| 356 |
-
'px) rotate(' + (Math.random()*360) + 'deg)';
|
| 357 |
-
c.style.opacity = '0';
|
| 358 |
-
});
|
| 359 |
-
setTimeout(() => c.remove(), 3200);
|
| 360 |
-
}
|
| 361 |
}
|
|
|
|
|
|
|
| 362 |
});
|
| 363 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 364 |
"""
|
| 365 |
|
| 366 |
|
|
@@ -384,7 +400,7 @@ def create_app() -> gr.Blocks:
|
|
| 384 |
'and hierarchical music analysis</p>'
|
| 385 |
f'<p class="device-badge">Compute: {backend.device_info()}</p>'
|
| 386 |
'</div>',
|
| 387 |
-
head=backend.MIDI_PLAYER_HEAD + backend.OSMD_HEAD,
|
| 388 |
)
|
| 389 |
|
| 390 |
with gr.Tabs() as tabs:
|
|
@@ -844,9 +860,6 @@ def create_app() -> gr.Blocks:
|
|
| 844 |
outputs=stitch_outputs,
|
| 845 |
)
|
| 846 |
|
| 847 |
-
# Hidden cats π± (see CAT_EGGS_JS) β runs once on page load.
|
| 848 |
-
demo.load(js=CAT_EGGS_JS)
|
| 849 |
-
|
| 850 |
return demo
|
| 851 |
|
| 852 |
|
|
|
|
| 148 |
#header h1 {
|
| 149 |
margin: 0; font-size: 2.7rem; font-weight: 750;
|
| 150 |
color: var(--pg-ink); letter-spacing: -.025em;
|
| 151 |
+
cursor: pointer; user-select: none; -webkit-user-select: none;
|
| 152 |
}
|
| 153 |
#header .tagline {
|
| 154 |
margin: 8px 0 0; font-size: 1.02rem; color: var(--pg-muted); font-weight: 400;
|
|
|
|
| 315 |
return f"### Opening phrase: #{pid} ({info['mode'].capitalize()})"
|
| 316 |
|
| 317 |
|
| 318 |
+
# ββ Easter eggs π± ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 319 |
+
# Injected via the header gr.HTML's head= (the same mechanism that loads the MIDI
|
| 320 |
+
# / OSMD scripts), because gradio 6's .load(js=) didn't run reliably here. The
|
| 321 |
+
# listeners are document-delegated, so they work the moment the page exists:
|
| 322 |
+
# (1) console greeting, (2) logo 5 quick clicks β "PurrGress",
|
| 323 |
+
# (3) Konami code (ββββββββ B A) β a shower of cats.
|
| 324 |
+
CAT_EGGS_HEAD = r"""
|
| 325 |
+
<script>
|
| 326 |
+
(function () {
|
| 327 |
if (window.__catEggs) return; window.__catEggs = true;
|
| 328 |
|
|
|
|
| 329 |
console.log(
|
| 330 |
"%c /\\_/\\ ProGress\n( o.o ) cat-powered graph diffusion =^.^=\n > ^ < ",
|
| 331 |
"color:#2563eb;font-weight:bold;"
|
| 332 |
);
|
| 333 |
|
| 334 |
+
// Logo: five quick clicks -> PurrGress (delegated on document)
|
| 335 |
+
var logoN = 0, logoTimer = null;
|
| 336 |
+
document.addEventListener('click', function (e) {
|
| 337 |
+
var h1 = e.target.closest ? e.target.closest('#header h1') : null;
|
| 338 |
+
if (!h1) return;
|
| 339 |
+
if (h1.dataset.orig == null) h1.dataset.orig = h1.textContent;
|
| 340 |
+
if (++logoN >= 5) {
|
| 341 |
+
logoN = 0;
|
| 342 |
+
h1.textContent = 'PurrGress π±';
|
| 343 |
+
setTimeout(function () { h1.textContent = h1.dataset.orig; }, 1600);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
}
|
| 345 |
+
clearTimeout(logoTimer);
|
| 346 |
+
logoTimer = setTimeout(function () { logoN = 0; }, 1500);
|
| 347 |
});
|
| 348 |
+
|
| 349 |
+
// Konami code -> cat rain (e.key based)
|
| 350 |
+
var seq = ['arrowup','arrowup','arrowdown','arrowdown',
|
| 351 |
+
'arrowleft','arrowright','arrowleft','arrowright','b','a'];
|
| 352 |
+
var i = 0;
|
| 353 |
+
document.addEventListener('keydown', function (e) {
|
| 354 |
+
var key = (e.key || '').toLowerCase();
|
| 355 |
+
i = (key === seq[i]) ? i + 1 : (key === seq[0] ? 1 : 0);
|
| 356 |
+
if (i !== seq.length) return;
|
| 357 |
+
i = 0;
|
| 358 |
+
var GLYPHS = ['π±','π','πΊ','π»','πΎ','π΅','πΆ','πΌ','π΅','πΆ'];
|
| 359 |
+
function dropCat() {
|
| 360 |
+
var c = document.createElement('div');
|
| 361 |
+
c.textContent = GLYPHS[Math.floor(Math.random()*GLYPHS.length)];
|
| 362 |
+
var dur = 2.6 + Math.random()*2.2; // each glyph falls at its own speed
|
| 363 |
+
c.style.cssText =
|
| 364 |
+
'position:fixed;top:-48px;left:' + (Math.random()*100) + 'vw;' +
|
| 365 |
+
'font-size:' + (20 + Math.random()*26) + 'px;z-index:99999;' +
|
| 366 |
+
'pointer-events:none;transition:transform ' + dur + 's linear,opacity ' + dur + 's;';
|
| 367 |
+
document.body.appendChild(c);
|
| 368 |
+
requestAnimationFrame(function () {
|
| 369 |
+
c.style.transform = 'translateY(' + (window.innerHeight + 96) +
|
| 370 |
+
'px) rotate(' + ((Math.random()-0.5)*420) + 'deg)';
|
| 371 |
+
c.style.opacity = '0';
|
| 372 |
+
});
|
| 373 |
+
setTimeout(function () { c.remove(); }, dur*1000 + 200);
|
| 374 |
+
}
|
| 375 |
+
// ~30 cats sprinkled over ~2.5s so it rains rather than dropping in one line
|
| 376 |
+
for (var n = 0; n < 30; n++) setTimeout(dropCat, Math.random()*2500);
|
| 377 |
+
});
|
| 378 |
+
})();
|
| 379 |
+
</script>
|
| 380 |
"""
|
| 381 |
|
| 382 |
|
|
|
|
| 400 |
'and hierarchical music analysis</p>'
|
| 401 |
f'<p class="device-badge">Compute: {backend.device_info()}</p>'
|
| 402 |
'</div>',
|
| 403 |
+
head=backend.MIDI_PLAYER_HEAD + backend.OSMD_HEAD + CAT_EGGS_HEAD,
|
| 404 |
)
|
| 405 |
|
| 406 |
with gr.Tabs() as tabs:
|
|
|
|
| 860 |
outputs=stitch_outputs,
|
| 861 |
)
|
| 862 |
|
|
|
|
|
|
|
|
|
|
| 863 |
return demo
|
| 864 |
|
| 865 |
|