root
commited on
Commit
·
bf68423
1
Parent(s):
09cbe60
fix link
Browse files
app.py
CHANGED
|
@@ -105,7 +105,7 @@ def _call_api(api_url: str, file_path: str, use_layout_detection: bool,
|
|
| 105 |
|
| 106 |
try:
|
| 107 |
# 关键改动:带上 headers
|
| 108 |
-
resp = requests.post(api_url, json=payload, headers=JSON_HEADERS, timeout=
|
| 109 |
resp.raise_for_status()
|
| 110 |
data = resp.json()
|
| 111 |
except requests.exceptions.RequestException as e:
|
|
@@ -124,7 +124,7 @@ def _call_api(api_url: str, file_path: str, use_layout_detection: bool,
|
|
| 124 |
def url_to_base64_data_url(url: str) -> str:
|
| 125 |
"""Downloads an image from a URL and formats it as a Base64 Data URL for Markdown."""
|
| 126 |
try:
|
| 127 |
-
response = requests.get(url, timeout=
|
| 128 |
response.raise_for_status()
|
| 129 |
mime_type = response.headers.get('Content-Type', 'image/jpeg')
|
| 130 |
if not mime_type.startswith('image/'):
|
|
@@ -157,7 +157,7 @@ def url_to_pil_image(url: str) -> Optional[Image.Image]:
|
|
| 157 |
print(f"Warning: Invalid URL provided for visualization image: {url}")
|
| 158 |
return None
|
| 159 |
try:
|
| 160 |
-
response = requests.get(url, timeout=
|
| 161 |
response.raise_for_status()
|
| 162 |
image_bytes = response.content
|
| 163 |
pil_image = Image.open(io.BytesIO(image_bytes)).convert("RGB")
|
|
@@ -311,6 +311,7 @@ body, .gradio-container, .gradio-container * {
|
|
| 311 |
/* Markdown 预览区 (vh -> px) */
|
| 312 |
#md_preview_vl, #md_preview_doc {
|
| 313 |
max-height: 540px; /* 原为 60vh */
|
|
|
|
| 314 |
overflow: auto;
|
| 315 |
scrollbar-gutter: stable both-edges;
|
| 316 |
}
|
|
@@ -325,6 +326,21 @@ body, .gradio-container, .gradio-container * {
|
|
| 325 |
max-width: 100%;
|
| 326 |
height: auto;
|
| 327 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
"""
|
| 329 |
|
| 330 |
|
|
@@ -335,6 +351,15 @@ with gr.Blocks(head=GOOGLE_FONTS_URL, css=custom_css, theme=gr.themes.Soft()) as
|
|
| 335 |
<img src="{logo_data_url}" alt="App Logo" style="max-height:10%; width: auto; margin: 10px auto; display: block;">
|
| 336 |
</div>
|
| 337 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
gr.HTML("""
|
| 339 |
<div class="quick-links">
|
| 340 |
<a href="https://github.com/PaddlePaddle/PaddleOCR" target="_blank">GitHub</a> |
|
|
@@ -342,7 +367,6 @@ with gr.Blocks(head=GOOGLE_FONTS_URL, css=custom_css, theme=gr.themes.Soft()) as
|
|
| 342 |
<a href="https://huggingface.co/spaces/PaddlePaddle/PaddleOCR-VL_Online_Demo" target="_blank">Model</a>
|
| 343 |
</div>
|
| 344 |
""")
|
| 345 |
-
|
| 346 |
with gr.Tabs():
|
| 347 |
with gr.Tab("Document Parsing"):
|
| 348 |
with gr.Row():
|
|
|
|
| 105 |
|
| 106 |
try:
|
| 107 |
# 关键改动:带上 headers
|
| 108 |
+
resp = requests.post(api_url, json=payload, headers=JSON_HEADERS, timeout=600)
|
| 109 |
resp.raise_for_status()
|
| 110 |
data = resp.json()
|
| 111 |
except requests.exceptions.RequestException as e:
|
|
|
|
| 124 |
def url_to_base64_data_url(url: str) -> str:
|
| 125 |
"""Downloads an image from a URL and formats it as a Base64 Data URL for Markdown."""
|
| 126 |
try:
|
| 127 |
+
response = requests.get(url, timeout=600)
|
| 128 |
response.raise_for_status()
|
| 129 |
mime_type = response.headers.get('Content-Type', 'image/jpeg')
|
| 130 |
if not mime_type.startswith('image/'):
|
|
|
|
| 157 |
print(f"Warning: Invalid URL provided for visualization image: {url}")
|
| 158 |
return None
|
| 159 |
try:
|
| 160 |
+
response = requests.get(url, timeout=600)
|
| 161 |
response.raise_for_status()
|
| 162 |
image_bytes = response.content
|
| 163 |
pil_image = Image.open(io.BytesIO(image_bytes)).convert("RGB")
|
|
|
|
| 311 |
/* Markdown 预览区 (vh -> px) */
|
| 312 |
#md_preview_vl, #md_preview_doc {
|
| 313 |
max-height: 540px; /* 原为 60vh */
|
| 314 |
+
min-height: 180px;
|
| 315 |
overflow: auto;
|
| 316 |
scrollbar-gutter: stable both-edges;
|
| 317 |
}
|
|
|
|
| 326 |
max-width: 100%;
|
| 327 |
height: auto;
|
| 328 |
}
|
| 329 |
+
/* Notice banner */
|
| 330 |
+
.notice {
|
| 331 |
+
margin: 8px auto 0;
|
| 332 |
+
max-width: 900px;
|
| 333 |
+
padding: 10px 12px;
|
| 334 |
+
border: 1px solid #e5e7eb;
|
| 335 |
+
border-radius: 8px;
|
| 336 |
+
background: #f8fafc;
|
| 337 |
+
font-size: 14px;
|
| 338 |
+
line-height: 1.6;
|
| 339 |
+
}
|
| 340 |
+
.notice strong { font-weight: 700; }
|
| 341 |
+
.notice a { color: #3b82f6; text-decoration: none; }
|
| 342 |
+
.notice a:hover { text-decoration: underline; }
|
| 343 |
+
|
| 344 |
"""
|
| 345 |
|
| 346 |
|
|
|
|
| 351 |
<img src="{logo_data_url}" alt="App Logo" style="max-height:10%; width: auto; margin: 10px auto; display: block;">
|
| 352 |
</div>
|
| 353 |
""")
|
| 354 |
+
gr.HTML("""
|
| 355 |
+
<div class="notice">
|
| 356 |
+
<strong>Heads up:</strong> The Hugging Face demo can be slow at times.
|
| 357 |
+
For a faster experience, please try
|
| 358 |
+
<a href="https://modelscope.cn/studios/PaddlePaddle/PaddleOCR-VL_Online_Demo/summary" target="_blank" rel="noopener noreferrer">ModelScope</a>
|
| 359 |
+
or
|
| 360 |
+
<a href="https://aistudio.baidu.com/application/detail/98365" target="_blank" rel="noopener noreferrer">Baidu AI Studio</a>.
|
| 361 |
+
</div>
|
| 362 |
+
""")
|
| 363 |
gr.HTML("""
|
| 364 |
<div class="quick-links">
|
| 365 |
<a href="https://github.com/PaddlePaddle/PaddleOCR" target="_blank">GitHub</a> |
|
|
|
|
| 367 |
<a href="https://huggingface.co/spaces/PaddlePaddle/PaddleOCR-VL_Online_Demo" target="_blank">Model</a>
|
| 368 |
</div>
|
| 369 |
""")
|
|
|
|
| 370 |
with gr.Tabs():
|
| 371 |
with gr.Tab("Document Parsing"):
|
| 372 |
with gr.Row():
|
examples/{targeted/e5829e2de95961b2cf97e1c86b21d880.png → complex/7a9050172ce7d3be4abcd2bca9bd6dcc.png}
RENAMED
|
File without changes
|
examples/targeted/54c7101449aff77e6d9ab8270b3d2c38.png
ADDED
|
Git LFS Details
|