root
commited on
Commit
·
87fcc8a
1
Parent(s):
bd209eb
fix css
Browse files- app.py +96 -26
- requirements.txt +3 -1
app.py
CHANGED
|
@@ -222,32 +222,102 @@ def handle_targeted_recognition(file_path: str, prompt_choice: str) -> Tuple[str
|
|
| 222 |
# =========================
|
| 223 |
# CSS & UI (From New Script)
|
| 224 |
# =========================
|
| 225 |
-
custom_css =
|
| 226 |
-
|
| 227 |
-
.
|
| 228 |
-
|
| 229 |
-
.gradio-container .tabs { margin-top: 0px !important; }
|
| 230 |
-
.gradio-container .tabitem { padding-top: 4px !important; }
|
| 231 |
-
.prompt-grid { gap: 8px !important; margin-top: 4px !important; }
|
| 232 |
-
.prompt-grid button { height: 40px !important; min-height: 0 !important; padding: 0 12px !important; border-radius: 8px !important; font-weight: 600 !important; font-size: 13px !important; letter-spacing: .2px; }
|
| 233 |
-
.quick-links { text-align: center; padding: 8px 0; border: 1px solid #e5e7eb; border-radius: 8px; margin: 8px auto !important; max-width: 900px; }
|
| 234 |
-
.quick-links a { margin: 0 15px; font-size: 14px; font-weight: 600; text-decoration: none; color: #3b82f6; }
|
| 235 |
-
.quick-links a:hover { text-decoration: underline; }
|
| 236 |
-
#image_preview_vl, #image_preview_doc { height: 60vh !important; overflow: auto; }
|
| 237 |
-
#vis_image_doc { height: 42vh !important; }
|
| 238 |
-
#image_preview_vl .uploaded-image, #image_preview_doc .uploaded-image { height: 100%; }
|
| 239 |
-
#image_preview_vl img, #image_preview_doc img, #vis_image_doc img { width: 100% !important; height: 100% !important; object-fit: contain !important; }
|
| 240 |
-
#md_preview_vl, #md_preview_doc { max-height: 60vh; overflow: auto; scrollbar-gutter: stable both-edges; }
|
| 241 |
-
#md_preview_doc .prose img,
|
| 242 |
-
#md_preview_vl .prose img {
|
| 243 |
-
display: block !important;
|
| 244 |
-
margin-left: auto !important;
|
| 245 |
-
margin-right: auto !important; /* 块级元素用 margin auto 居中 */
|
| 246 |
-
height: auto; /* 可选:保持比例 */
|
| 247 |
-
max-width: 100%; /* 可选:避免溢出 */
|
| 248 |
}
|
| 249 |
-
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
|
| 252 |
with gr.Blocks(head=GOOGLE_FONTS_URL, css=custom_css, theme=gr.themes.Soft()) as demo:
|
| 253 |
logo_data_url = image_to_base64_data_url(LOGO_IMAGE_PATH) if os.path.exists(LOGO_IMAGE_PATH) else ""
|
|
@@ -333,5 +403,5 @@ with gr.Blocks(head=GOOGLE_FONTS_URL, css=custom_css, theme=gr.themes.Soft()) as
|
|
| 333 |
btn_chart.click(fn=handle_targeted_recognition, inputs=[file_vl, gr.State("Chart Recognition")], outputs=[md_preview_vl, md_raw_vl])
|
| 334 |
|
| 335 |
if __name__ == "__main__":
|
| 336 |
-
port = int(os.getenv("PORT", "
|
| 337 |
demo.queue().launch(server_name="0.0.0.0", server_port=port,share=False)
|
|
|
|
| 222 |
# =========================
|
| 223 |
# CSS & UI (From New Script)
|
| 224 |
# =========================
|
| 225 |
+
custom_css = """
|
| 226 |
+
/* 全局字体 */
|
| 227 |
+
body, .gradio-container, .gradio-container * {
|
| 228 |
+
font-family: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
}
|
| 230 |
+
|
| 231 |
+
/* 头部 */
|
| 232 |
+
.app-header {
|
| 233 |
+
text-align: center;
|
| 234 |
+
max-width: 900px;
|
| 235 |
+
margin: 0 auto 8px !important;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
/* 全局容器与标签页 */
|
| 239 |
+
.gradio-container {
|
| 240 |
+
padding: 4px 0 !important;
|
| 241 |
+
}
|
| 242 |
+
.gradio-container [data-testid="tabs"],
|
| 243 |
+
.gradio-container .tabs {
|
| 244 |
+
margin-top: 0 !important;
|
| 245 |
+
}
|
| 246 |
+
.gradio-container [data-testid="tabitem"],
|
| 247 |
+
.gradio-container .tabitem {
|
| 248 |
+
padding-top: 4px !important;
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
/* 快速链接 */
|
| 252 |
+
.quick-links {
|
| 253 |
+
text-align: center;
|
| 254 |
+
padding: 8px 0;
|
| 255 |
+
border: 1px solid #e5e7eb;
|
| 256 |
+
border-radius: 8px;
|
| 257 |
+
margin: 8px auto;
|
| 258 |
+
max-width: 900px;
|
| 259 |
+
}
|
| 260 |
+
.quick-links a {
|
| 261 |
+
margin: 0 12px;
|
| 262 |
+
font-size: 14px;
|
| 263 |
+
font-weight: 600;
|
| 264 |
+
color: #3b82f6;
|
| 265 |
+
text-decoration: none;
|
| 266 |
+
}
|
| 267 |
+
.quick-links a:hover {
|
| 268 |
+
text-decoration: underline;
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
/* 按钮区域(识别类型选择) */
|
| 272 |
+
.prompt-grid {
|
| 273 |
+
display: flex;
|
| 274 |
+
flex-wrap: wrap;
|
| 275 |
+
gap: 8px;
|
| 276 |
+
margin-top: 6px;
|
| 277 |
+
}
|
| 278 |
+
.prompt-grid button {
|
| 279 |
+
height: 40px !important;
|
| 280 |
+
padding: 0 12px !important;
|
| 281 |
+
border-radius: 8px !important;
|
| 282 |
+
font-weight: 600 !important;
|
| 283 |
+
font-size: 13px !important;
|
| 284 |
+
letter-spacing: 0.2px;
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
/* 图片预览与可视化 (vh -> px) */
|
| 288 |
+
#image_preview_vl, #image_preview_doc {
|
| 289 |
+
height: 400px !important; /* 原为 60vh */
|
| 290 |
+
overflow: auto;
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
#image_preview_vl img,
|
| 294 |
+
#image_preview_doc img,
|
| 295 |
+
#vis_image_doc img {
|
| 296 |
+
width: 100% !important;
|
| 297 |
+
height: auto !important;
|
| 298 |
+
object-fit: contain !important;
|
| 299 |
+
display: block;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
/* Markdown 预览区 (vh -> px) */
|
| 303 |
+
#md_preview_vl, #md_preview_doc {
|
| 304 |
+
max-height: 540px; /* 原为 60vh */
|
| 305 |
+
overflow: auto;
|
| 306 |
+
scrollbar-gutter: stable both-edges;
|
| 307 |
+
}
|
| 308 |
+
#md_preview_vl .prose,
|
| 309 |
+
#md_preview_doc .prose {
|
| 310 |
+
line-height: 1.7 !important;
|
| 311 |
+
}
|
| 312 |
+
#md_preview_vl .prose img,
|
| 313 |
+
#md_preview_doc .prose img {
|
| 314 |
+
display: block;
|
| 315 |
+
margin: 0 auto;
|
| 316 |
+
max-width: 100%;
|
| 317 |
+
height: auto;
|
| 318 |
+
}
|
| 319 |
+
"""
|
| 320 |
+
|
| 321 |
|
| 322 |
with gr.Blocks(head=GOOGLE_FONTS_URL, css=custom_css, theme=gr.themes.Soft()) as demo:
|
| 323 |
logo_data_url = image_to_base64_data_url(LOGO_IMAGE_PATH) if os.path.exists(LOGO_IMAGE_PATH) else ""
|
|
|
|
| 403 |
btn_chart.click(fn=handle_targeted_recognition, inputs=[file_vl, gr.State("Chart Recognition")], outputs=[md_preview_vl, md_raw_vl])
|
| 404 |
|
| 405 |
if __name__ == "__main__":
|
| 406 |
+
port = int(os.getenv("PORT", "8812"))
|
| 407 |
demo.queue().launch(server_name="0.0.0.0", server_port=port,share=False)
|
requirements.txt
CHANGED
|
@@ -2,4 +2,6 @@ gradio==5.42.0
|
|
| 2 |
gradio_client==1.11.1
|
| 3 |
huggingface-hub==0.34.4
|
| 4 |
pillow==11.3.0
|
| 5 |
-
requests==2.32.4
|
|
|
|
|
|
|
|
|
| 2 |
gradio_client==1.11.1
|
| 3 |
huggingface-hub==0.34.4
|
| 4 |
pillow==11.3.0
|
| 5 |
+
requests==2.32.4
|
| 6 |
+
|
| 7 |
+
pip install gradio[oauth,mcp]==5.49.1
|