multimodalart HF Staff commited on
Commit
cb7939a
·
verified ·
1 Parent(s): f754dbe

Widen GPU duration to measured worst case x1.4; label polish

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -248,12 +248,16 @@ def _write_markdown(markdown: str) -> str:
248
 
249
 
250
  def _estimate_duration(*args, **kwargs) -> int:
251
- """A dense page measured 67 s end-to-end; scale mildly with the token cap."""
 
 
 
 
252
  max_new_tokens = 2048
253
  if len(args) > 4:
254
  max_new_tokens = args[4]
255
  max_new_tokens = int(kwargs.get("max_new_tokens", max_new_tokens) or 2048)
256
- return int(min(180, 55 + 0.02 * max_new_tokens))
257
 
258
 
259
  @spaces.GPU(duration=_estimate_duration)
@@ -434,7 +438,7 @@ off flat scans **and** photographed / crumpled pages, and returns Markdown.
434
  with gr.Accordion("Advanced settings", open=False):
435
  drop_paratext = gr.Checkbox(
436
  value=True,
437
- label="Drop headers, footers, page numbers and margin notes",
438
  )
439
  max_new_tokens = gr.Slider(
440
  256, 4096, value=2048, step=128, label="Max new tokens per region"
@@ -449,7 +453,11 @@ off flat scans **and** photographed / crumpled pages, and returns Markdown.
449
  )
450
  with gr.Tab("Markdown source"):
451
  markdown_source = gr.Code(
452
- language="markdown", lines=28, interactive=False, label=None
 
 
 
 
453
  )
454
  with gr.Tab("Layout"):
455
  overlay = gr.Image(label="Predicted regions (reading order)", height=620)
 
248
 
249
 
250
  def _estimate_duration(*args, **kwargs) -> int:
251
+ """Measured on ZeroGPU: single regions 5-13 s, a dense 31-region page 73 s.
252
+
253
+ Runtime is dominated by generated tokens, so scale with the per-region cap
254
+ (105 s at the default 2048, the measured worst case x1.4).
255
+ """
256
  max_new_tokens = 2048
257
  if len(args) > 4:
258
  max_new_tokens = args[4]
259
  max_new_tokens = int(kwargs.get("max_new_tokens", max_new_tokens) or 2048)
260
+ return int(min(180, 60 + 0.022 * max_new_tokens))
261
 
262
 
263
  @spaces.GPU(duration=_estimate_duration)
 
438
  with gr.Accordion("Advanced settings", open=False):
439
  drop_paratext = gr.Checkbox(
440
  value=True,
441
+ label="Full page: drop headers, footers, page numbers, margin notes",
442
  )
443
  max_new_tokens = gr.Slider(
444
  256, 4096, value=2048, step=128, label="Max new tokens per region"
 
453
  )
454
  with gr.Tab("Markdown source"):
455
  markdown_source = gr.Code(
456
+ language="markdown",
457
+ lines=28,
458
+ interactive=False,
459
+ label="Markdown",
460
+ wrap_lines=True,
461
  )
462
  with gr.Tab("Layout"):
463
  overlay = gr.Image(label="Predicted regions (reading order)", height=620)