root commited on
Commit
567955e
·
1 Parent(s): 9142812

add history_list

Browse files
Files changed (1) hide show
  1. app.py +24 -10
app.py CHANGED
@@ -281,7 +281,6 @@ body, .gradio-container { font-family: "Noto Sans SC", "Microsoft YaHei", "PingF
281
  with gr.Blocks(head=GOOGLE_FONTS_URL, css=custom_css, theme=gr.themes.Soft()) as demo:
282
  logo_data_url = image_to_base64_data_url(LOGO_IMAGE_PATH) if os.path.exists(LOGO_IMAGE_PATH) else ""
283
  gr.HTML(f"""<div class="app-header"><img src="{logo_data_url}" alt="App Logo" style="max-height:10%; width: auto; margin: 10px auto; display: block;"></div>""")
284
- gr.HTML("""<div class="notice"><strong>Heads up:</strong> The Hugging Face demo can be slow at times. For a faster experience, please try <a href="https://aistudio.baidu.com/application/detail/98365" target="_blank" rel="noopener noreferrer">Baidu AI Studio</a> or <a href="https://modelscope.cn/studios/PaddlePaddle/PaddleOCR-VL_Online_Demo/summary" target="_blank" rel="noopener noreferrer">ModelScope</a>.</div>""")
285
  gr.HTML("""<div class="quick-links"><a href="https://github.com/PaddlePaddle/PaddleOCR" target="_blank">GitHub</a> | <a href="https://ernie.baidu.com/blog/publication/PaddleOCR-VL_Technical_Report.pdf" target="_blank">Technical Report</a> | <a href="https://huggingface.co/PaddlePaddle/PaddleOCR-VL" target="_blank">Model</a></div>""")
286
 
287
  with gr.Tabs():
@@ -302,11 +301,12 @@ with gr.Blocks(head=GOOGLE_FONTS_URL, css=custom_css, theme=gr.themes.Soft()) as
302
  with gr.Column(scale=3):
303
  with gr.Row(elem_classes=["checkbox-row"]):
304
  chart_parsing_switch = gr.Checkbox(label="Enable chart parsing", value=False, min_width=10)
305
- doc_unwarping_switch = gr.Checkbox(label="Enable document unwarping", value=True, min_width=10)
306
- doc_orientation_switch = gr.Checkbox(label="Enable orientation classification", value=True, min_width=10)
 
307
 
308
  if complex_document_examples:
309
- complex_paths = [e[0] for e in complex_document_examples] # 这里是 List[str]
310
  complex_state = gr.State(complex_paths)
311
 
312
  gallery_complex = gr.Gallery(
@@ -314,28 +314,42 @@ with gr.Blocks(head=GOOGLE_FONTS_URL, css=custom_css, theme=gr.themes.Soft()) as
314
  preview=False, label=None, allow_preview=False
315
  )
316
 
317
- # 2) 回调:用 evt.index 到 paths(State)里取 URL
318
  def on_gallery_select_for_doc(paths, evt: gr.SelectData):
319
- # 某些版本 evt.index 可能是 (row, col) 或 list,做个兜底
320
  idx = evt.index
321
  if isinstance(idx, (list, tuple)):
322
- # 常见是一个 int;如果是 (row, col) 形式,通常线性下标 == row
323
  idx = idx[0]
324
  try:
325
  url = paths[int(idx)]
326
  except Exception:
327
  raise gr.Error(f"Invalid index from gallery: {evt.index}")
328
 
329
- # 更新状态 & 预览
330
  return url, update_preview_visibility(url)
331
 
332
- # 3) 绑定:把 State 作为 inputs 传给回调,outputs 写入 example_url_doc 和预览 HTML
333
  gallery_complex.select(
334
  fn=on_gallery_select_for_doc,
335
  inputs=[complex_state],
336
  outputs=[example_url_doc, preview_doc_html],
337
  )
338
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
 
340
  with gr.Column(scale=7):
341
  with gr.Tabs():
@@ -379,7 +393,7 @@ with gr.Blocks(head=GOOGLE_FONTS_URL, css=custom_css, theme=gr.themes.Soft()) as
379
  example_url_vl = gr.State(value=None)
380
 
381
  if targeted_recognition_examples:
382
- targeted_paths = [e[0] for e in targeted_recognition_examples] # List[str]
383
  targeted_state = gr.State(targeted_paths)
384
 
385
  gallery_targeted = gr.Gallery(
 
281
  with gr.Blocks(head=GOOGLE_FONTS_URL, css=custom_css, theme=gr.themes.Soft()) as demo:
282
  logo_data_url = image_to_base64_data_url(LOGO_IMAGE_PATH) if os.path.exists(LOGO_IMAGE_PATH) else ""
283
  gr.HTML(f"""<div class="app-header"><img src="{logo_data_url}" alt="App Logo" style="max-height:10%; width: auto; margin: 10px auto; display: block;"></div>""")
 
284
  gr.HTML("""<div class="quick-links"><a href="https://github.com/PaddlePaddle/PaddleOCR" target="_blank">GitHub</a> | <a href="https://ernie.baidu.com/blog/publication/PaddleOCR-VL_Technical_Report.pdf" target="_blank">Technical Report</a> | <a href="https://huggingface.co/PaddlePaddle/PaddleOCR-VL" target="_blank">Model</a></div>""")
285
 
286
  with gr.Tabs():
 
301
  with gr.Column(scale=3):
302
  with gr.Row(elem_classes=["checkbox-row"]):
303
  chart_parsing_switch = gr.Checkbox(label="Enable chart parsing", value=False, min_width=10)
304
+ # ############### 修改点在这里 ###############
305
+ doc_unwarping_switch = gr.Checkbox(label="Enable document unwarping", value=False, min_width=10)
306
+ doc_orientation_switch = gr.Checkbox(label="Enable orientation classification", value=False, min_width=10)
307
 
308
  if complex_document_examples:
309
+ complex_paths = [e[0] for e in complex_document_examples]
310
  complex_state = gr.State(complex_paths)
311
 
312
  gallery_complex = gr.Gallery(
 
314
  preview=False, label=None, allow_preview=False
315
  )
316
 
 
317
  def on_gallery_select_for_doc(paths, evt: gr.SelectData):
 
318
  idx = evt.index
319
  if isinstance(idx, (list, tuple)):
 
320
  idx = idx[0]
321
  try:
322
  url = paths[int(idx)]
323
  except Exception:
324
  raise gr.Error(f"Invalid index from gallery: {evt.index}")
325
 
 
326
  return url, update_preview_visibility(url)
327
 
 
328
  gallery_complex.select(
329
  fn=on_gallery_select_for_doc,
330
  inputs=[complex_state],
331
  outputs=[example_url_doc, preview_doc_html],
332
  )
333
 
334
+ # ===================== 更新日志模块 =====================
335
+ gr.Markdown("""
336
+ <div class="notice">
337
+ <h3>History Updates</h3>
338
+ <ul>
339
+ <li>
340
+ <strong>Oct 30, 2025:</strong>
341
+ Added two advanced control options under the "Document Parsing" tab. These features were previously enabled by default (set to true) but are now user-configurable and default to false.
342
+ <ul>
343
+ <li><strong>Enable document unwarping:</strong> Corrects distortions in bent or poorly photographed documents.</li>
344
+ <li><strong>Enable orientation classification:</strong> Automatically corrects the orientation of rotated or upside-down images.</li>
345
+ </ul>
346
+ </li>
347
+ <li>
348
+ <strong>Oct 16, 2025:</strong> Initial release of the demo.
349
+ </li>
350
+ </ul>
351
+ </div>
352
+ """)
353
 
354
  with gr.Column(scale=7):
355
  with gr.Tabs():
 
393
  example_url_vl = gr.State(value=None)
394
 
395
  if targeted_recognition_examples:
396
+ targeted_paths = [e[0] for e in targeted_recognition_examples]
397
  targeted_state = gr.State(targeted_paths)
398
 
399
  gallery_targeted = gr.Gallery(