Spaces:
Running on Zero
Running on Zero
fix retry
Browse files
app.py
CHANGED
|
@@ -529,9 +529,9 @@ CSS = """
|
|
| 529 |
|
| 530 |
/* ---- Scrollless, full-viewport layout: the page never scrolls; only the fields column does. ---- */
|
| 531 |
html, body { height: 100%; margin: 0; overflow: hidden; }
|
| 532 |
-
gradio-app { height: 100vh; overflow: hidden; }
|
| 533 |
.gradio-container {
|
| 534 |
-
height: 100vh !important;
|
| 535 |
max-width: 100% !important;
|
| 536 |
padding: 6px 14px 4px !important;
|
| 537 |
overflow: hidden !important;
|
|
@@ -544,7 +544,7 @@ gradio-app { height: 100vh; overflow: hidden; }
|
|
| 544 |
}
|
| 545 |
/* The right-hand editor column is the only thing that scrolls (like the desktop app). */
|
| 546 |
#fields-col {
|
| 547 |
-
max-height: calc(100vh - 118px);
|
| 548 |
overflow-y: auto;
|
| 549 |
overflow-x: hidden;
|
| 550 |
padding-right: 6px;
|
|
@@ -565,7 +565,7 @@ gradio-app { height: 100vh; overflow: hidden; }
|
|
| 565 |
/* ---- Hand-rolled bbox canvas ---- */
|
| 566 |
#bbox-root {
|
| 567 |
width: 100%;
|
| 568 |
-
height: calc(100vh - 120px);
|
| 569 |
display: flex;
|
| 570 |
align-items: center;
|
| 571 |
justify-content: center;
|
|
@@ -574,7 +574,7 @@ gradio-app { height: 100vh; overflow: hidden; }
|
|
| 574 |
}
|
| 575 |
.ib-hint { color: var(--ib-subdued); font-size: 0.9rem; padding: 12px; }
|
| 576 |
.ib-stage { position: relative; display: inline-block; max-width: 100%; max-height: 100%; line-height: 0; }
|
| 577 |
-
.ib-img { display: block; max-width: 100%; max-height: calc(100vh - 120px); width: auto; height: auto; user-select: none; }
|
| 578 |
.ib-box {
|
| 579 |
position: absolute;
|
| 580 |
border: 2px solid #4da460;
|
|
@@ -1505,9 +1505,19 @@ CANVAS_JS = r"""
|
|
| 1505 |
# Inject CSS + the canvas script straight into <head> as literal tags. This bypasses Gradio 6's
|
| 1506 |
# config-js path (which needs `new Function` and may be blocked/uninvoked), so the browser just runs
|
| 1507 |
# the <script> on load. CANVAS_JS is an arrow fn; `(...)()` self-invokes it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1508 |
HEAD = (
|
| 1509 |
"<style>\n" + CSS + "\n</style>\n"
|
| 1510 |
-
"<script>\nconsole.log('[IB] head script running');\n
|
|
|
|
| 1511 |
)
|
| 1512 |
|
| 1513 |
intro = (
|
|
@@ -1536,7 +1546,7 @@ with gr.Blocks(title="Ideogram4 Caption (Gemma4)") as demo:
|
|
| 1536 |
image = gr.Image(
|
| 1537 |
label="Source image",
|
| 1538 |
type="pil",
|
| 1539 |
-
height="calc(100vh - 190px)",
|
| 1540 |
)
|
| 1541 |
with gr.Column(scale=1):
|
| 1542 |
run = gr.Button(
|
|
|
|
| 529 |
|
| 530 |
/* ---- Scrollless, full-viewport layout: the page never scrolls; only the fields column does. ---- */
|
| 531 |
html, body { height: 100%; margin: 0; overflow: hidden; }
|
| 532 |
+
gradio-app { height: var(--app-h, 100vh); overflow: hidden; }
|
| 533 |
.gradio-container {
|
| 534 |
+
height: var(--app-h, 100vh) !important;
|
| 535 |
max-width: 100% !important;
|
| 536 |
padding: 6px 14px 4px !important;
|
| 537 |
overflow: hidden !important;
|
|
|
|
| 544 |
}
|
| 545 |
/* The right-hand editor column is the only thing that scrolls (like the desktop app). */
|
| 546 |
#fields-col {
|
| 547 |
+
max-height: calc(var(--app-h, 100vh) - 118px);
|
| 548 |
overflow-y: auto;
|
| 549 |
overflow-x: hidden;
|
| 550 |
padding-right: 6px;
|
|
|
|
| 565 |
/* ---- Hand-rolled bbox canvas ---- */
|
| 566 |
#bbox-root {
|
| 567 |
width: 100%;
|
| 568 |
+
height: calc(var(--app-h, 100vh) - 120px);
|
| 569 |
display: flex;
|
| 570 |
align-items: center;
|
| 571 |
justify-content: center;
|
|
|
|
| 574 |
}
|
| 575 |
.ib-hint { color: var(--ib-subdued); font-size: 0.9rem; padding: 12px; }
|
| 576 |
.ib-stage { position: relative; display: inline-block; max-width: 100%; max-height: 100%; line-height: 0; }
|
| 577 |
+
.ib-img { display: block; max-width: 100%; max-height: calc(var(--app-h, 100vh) - 120px); width: auto; height: auto; user-select: none; }
|
| 578 |
.ib-box {
|
| 579 |
position: absolute;
|
| 580 |
border: 2px solid #4da460;
|
|
|
|
| 1505 |
# Inject CSS + the canvas script straight into <head> as literal tags. This bypasses Gradio 6's
|
| 1506 |
# config-js path (which needs `new Function` and may be blocked/uninvoked), so the browser just runs
|
| 1507 |
# the <script> on load. CANVAS_JS is an arrow fn; `(...)()` self-invokes it.
|
| 1508 |
+
# --app-h is a *fixed pixel* stand-in for 100vh. On HF Spaces the app runs in a <gradio-app>
|
| 1509 |
+
# iframe that resizes to its content, so `vh` units feed back and grow forever. Pinning a pixel
|
| 1510 |
+
# height from window.innerHeight (updated only on real resize) breaks that loop.
|
| 1511 |
+
HEIGHT_SYNC_JS = (
|
| 1512 |
+
"(function(){function s(){document.documentElement.style.setProperty("
|
| 1513 |
+
"'--app-h', window.innerHeight + 'px');}s();"
|
| 1514 |
+
"window.addEventListener('resize', s);"
|
| 1515 |
+
"window.addEventListener('load', s);})();"
|
| 1516 |
+
)
|
| 1517 |
HEAD = (
|
| 1518 |
"<style>\n" + CSS + "\n</style>\n"
|
| 1519 |
+
"<script>\nconsole.log('[IB] head script running');\n"
|
| 1520 |
+
+ HEIGHT_SYNC_JS + "\n(" + CANVAS_JS + ")();\n</script>\n"
|
| 1521 |
)
|
| 1522 |
|
| 1523 |
intro = (
|
|
|
|
| 1546 |
image = gr.Image(
|
| 1547 |
label="Source image",
|
| 1548 |
type="pil",
|
| 1549 |
+
height="calc(var(--app-h, 100vh) - 190px)",
|
| 1550 |
)
|
| 1551 |
with gr.Column(scale=1):
|
| 1552 |
run = gr.Button(
|