ricklon Claude Sonnet 4.6 commited on
Commit
ed72469
·
1 Parent(s): 19cbeef

Fix Gradio 6 compatibility: move head to launch(), disable SSR

Browse files

- head= parameter moved from gr.Blocks() to launch() in Gradio 6.0;
keeping it in Blocks() raises a UserWarning and may break routing
- ssr_mode=False: SSR is experimental in Gradio 6 and causes
'Could not get API info' connection errors on HuggingFace Spaces

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -323,7 +323,7 @@ def update_page_selector(file_path):
323
  label=f"Select Page (1-{page_count})")
324
  return gr.update(visible=False)
325
 
326
- with gr.Blocks(title="DeepSeek-OCR-2", head=MATHJAX_HEAD) as demo:
327
  gr.Markdown("""
328
  # 🧮 DeepSeek-OCR-2 — Math Rendering Edition
329
  **Convert documents to markdown, extract text, parse figures, and locate specific content with bounding boxes.**
@@ -427,4 +427,9 @@ if __name__ == "__main__":
427
  # server_name="0.0.0.0" is needed locally (WSL2 → Windows access)
428
  # On HuggingFace Spaces, SPACE_ID is set and Gradio handles binding automatically
429
  local = not os.environ.get("SPACE_ID")
430
- demo.queue(max_size=20).launch(theme=gr.themes.Soft(), server_name="0.0.0.0" if local else None)
 
 
 
 
 
 
323
  label=f"Select Page (1-{page_count})")
324
  return gr.update(visible=False)
325
 
326
+ with gr.Blocks(title="DeepSeek-OCR-2") as demo:
327
  gr.Markdown("""
328
  # 🧮 DeepSeek-OCR-2 — Math Rendering Edition
329
  **Convert documents to markdown, extract text, parse figures, and locate specific content with bounding boxes.**
 
427
  # server_name="0.0.0.0" is needed locally (WSL2 → Windows access)
428
  # On HuggingFace Spaces, SPACE_ID is set and Gradio handles binding automatically
429
  local = not os.environ.get("SPACE_ID")
430
+ demo.queue(max_size=20).launch(
431
+ theme=gr.themes.Soft(),
432
+ server_name="0.0.0.0" if local else None,
433
+ head=MATHJAX_HEAD, # Gradio 6.0: head moved from Blocks() to launch()
434
+ ssr_mode=False, # SSR is experimental in Gradio 6 and breaks HF Spaces routing
435
+ )