HwwwH commited on
Commit
61e4e8d
·
verified ·
1 Parent(s): ea53409

Add a short note pointing to the official document-parse demo

Browse files
Files changed (2) hide show
  1. __pycache__/app.cpython-312.pyc +0 -0
  2. app.py +17 -1
__pycache__/app.cpython-312.pyc CHANGED
Binary files a/__pycache__/app.cpython-312.pyc and b/__pycache__/app.cpython-312.pyc differ
 
app.py CHANGED
@@ -72,6 +72,10 @@ COPY = {
72
  "en": {
73
  "language_label": "Language",
74
  "intro": "# Document parsing\nUpload an image.",
 
 
 
 
75
  "image": "Image",
76
  "upload": "Drop an image here\n- or -\nclick to upload",
77
  "upright": "Auto-rotate",
@@ -95,6 +99,10 @@ COPY = {
95
  "zh": {
96
  "language_label": "语言",
97
  "intro": "# 文档解析\n上传一张图片。",
 
 
 
 
98
  "image": "图片",
99
  "upload": "将图片拖到这里\n- 或 -\n点击上传",
100
  "upright": "自适应旋转",
@@ -117,6 +125,8 @@ RESULT_CSS = """
117
  .ocr-columns { align-items: flex-start !important; gap: 16px; }
118
  .ocr-columns > .column { flex: 1 1 0 !important; min-width: 0 !important; width: calc(50% - 8px) !important; }
119
  .ocr-col > .block, .ocr-col > .form { width: 100% !important; }
 
 
120
  .ocr-result table { border-collapse: collapse; width: 100%; margin: 8px 0; }
121
  .ocr-result td, .ocr-result th { border: 1px solid #d1d5db; padding: 4px 8px; vertical-align: top; }
122
  """
@@ -132,6 +142,10 @@ def _copy(language: str) -> dict:
132
  return COPY["zh"] if language == "zh" else COPY["en"]
133
 
134
 
 
 
 
 
135
  def _duration(image, upright, recognize_seal, recognize_chart, language):
136
  del image, upright, recognize_seal, recognize_chart, language
137
  return 90
@@ -352,6 +366,7 @@ if os.environ.get("OCR_SKIP_LAUNCH") != "1":
352
  return (
353
  gr.update(label=text["language_label"]),
354
  gr.update(value=text["intro"]),
 
355
  gr.update(label=text["image"], placeholder=text["upload"]),
356
  gr.update(label=text["upright"], info=text["upright_info"]),
357
  gr.update(label=text["seal"], info=text["seal_info"]),
@@ -370,6 +385,7 @@ if os.environ.get("OCR_SKIP_LAUNCH") != "1":
370
 
371
  with gr.Blocks(title="MiniCPM-OCR") as demo:
372
  intro = gr.Markdown(english["intro"])
 
373
  with gr.Row(elem_classes=["ocr-columns"]):
374
  with gr.Column(elem_classes=["ocr-col"], scale=1, min_width=0):
375
  language = gr.Radio(
@@ -403,7 +419,7 @@ if os.environ.get("OCR_SKIP_LAUNCH") != "1":
403
  language.change(
404
  apply_language,
405
  inputs=[language, view],
406
- outputs=[language, intro, image, upright, recognize_seal, recognize_chart, button, view],
407
  )
408
  view.change(apply_view, inputs=[view], outputs=[markdown, source])
409
  button.click(
 
72
  "en": {
73
  "language_label": "Language",
74
  "intro": "# Document parsing\nUpload an image.",
75
+ "limit_note": (
76
+ 'Because of ZeroGPU limits, this Space can only run Transformers serially on a single image. '
77
+ 'For a smoother, more complete experience, use the <a href="https://platform.modelbest.ai/console/playground/document-parse" target="_blank" rel="noopener noreferrer">official demo.</a>'
78
+ ),
79
  "image": "Image",
80
  "upload": "Drop an image here\n- or -\nclick to upload",
81
  "upright": "Auto-rotate",
 
99
  "zh": {
100
  "language_label": "语言",
101
  "intro": "# 文档解析\n上传一张图片。",
102
+ "limit_note": (
103
+ '由于 ZeroGPU 的限制,这里只能用 Transformers 串行、单图推理。需要更流畅、更全面的体验,'
104
+ '请前往<a href="https://platform.modelbest.ai/console/playground/document-parse" target="_blank" rel="noopener noreferrer">官方 Demo。</a>'
105
+ ),
106
  "image": "图片",
107
  "upload": "将图片拖到这里\n- 或 -\n点击上传",
108
  "upright": "自适应旋转",
 
125
  .ocr-columns { align-items: flex-start !important; gap: 16px; }
126
  .ocr-columns > .column { flex: 1 1 0 !important; min-width: 0 !important; width: calc(50% - 8px) !important; }
127
  .ocr-col > .block, .ocr-col > .form { width: 100% !important; }
128
+ .ocr-note { margin: 0 0 12px; color: #6b7280; font-size: 13px; line-height: 1.5; }
129
+ .ocr-note a { color: #2563eb; }
130
  .ocr-result table { border-collapse: collapse; width: 100%; margin: 8px 0; }
131
  .ocr-result td, .ocr-result th { border: 1px solid #d1d5db; padding: 4px 8px; vertical-align: top; }
132
  """
 
142
  return COPY["zh"] if language == "zh" else COPY["en"]
143
 
144
 
145
+ def _note(language: str) -> str:
146
+ return f'<p class="ocr-note">{_copy(language)["limit_note"]}</p>'
147
+
148
+
149
  def _duration(image, upright, recognize_seal, recognize_chart, language):
150
  del image, upright, recognize_seal, recognize_chart, language
151
  return 90
 
366
  return (
367
  gr.update(label=text["language_label"]),
368
  gr.update(value=text["intro"]),
369
+ gr.update(value=_note(language)),
370
  gr.update(label=text["image"], placeholder=text["upload"]),
371
  gr.update(label=text["upright"], info=text["upright_info"]),
372
  gr.update(label=text["seal"], info=text["seal_info"]),
 
385
 
386
  with gr.Blocks(title="MiniCPM-OCR") as demo:
387
  intro = gr.Markdown(english["intro"])
388
+ note = gr.HTML(_note("en"))
389
  with gr.Row(elem_classes=["ocr-columns"]):
390
  with gr.Column(elem_classes=["ocr-col"], scale=1, min_width=0):
391
  language = gr.Radio(
 
419
  language.change(
420
  apply_language,
421
  inputs=[language, view],
422
+ outputs=[language, intro, note, image, upright, recognize_seal, recognize_chart, button, view],
423
  )
424
  view.change(apply_view, inputs=[view], outputs=[markdown, source])
425
  button.click(