Update app.py
Browse files
app.py
CHANGED
@@ -14,26 +14,25 @@ from PIL import Image
|
|
14 |
import pdf2image
|
15 |
|
16 |
API_URL = "https://t707h6d9q6oftbx3.aistudio-app.com/layout-parsing"
|
17 |
-
TOKEN = os.getenv("API_TOKEN"
|
18 |
|
19 |
|
20 |
CSS = """
|
21 |
:root {
|
22 |
-
--sand-color: #
|
23 |
--white: #ffffff;
|
24 |
--shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
25 |
-
--text-color: #
|
26 |
--black:#000000;
|
27 |
-
--link-hover: #
|
28 |
--content-width: 1200px;
|
29 |
-
--button-color: #cbbdff; /* 新增按钮颜色变量 */
|
30 |
}
|
31 |
|
32 |
body {
|
33 |
display: flex;
|
34 |
justify-content: center;
|
35 |
background-color: var(--sand-color);
|
36 |
-
color: var(--
|
37 |
font-family: Arial, sans-serif;
|
38 |
}
|
39 |
|
@@ -42,22 +41,41 @@ body {
|
|
42 |
width: 100% !important;
|
43 |
margin: 20px auto;
|
44 |
padding: 20px;
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
background-color: var(--white) !important;
|
|
|
46 |
}
|
47 |
|
48 |
-
|
49 |
-
.header-container {
|
50 |
width: 100%;
|
51 |
-
|
52 |
-
padding: 20px
|
53 |
-
|
54 |
border-radius: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
56 |
|
57 |
.logo-container {
|
58 |
width: 100%;
|
59 |
-
margin-bottom:
|
60 |
-
text-align: center;
|
61 |
}
|
62 |
|
63 |
.logo-img {
|
@@ -67,61 +85,35 @@ body {
|
|
67 |
display: block;
|
68 |
}
|
69 |
|
70 |
-
|
71 |
-
.nav-buttons {
|
72 |
display: flex;
|
73 |
justify-content: center;
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
margin-
|
78 |
-
margin-right: auto;
|
79 |
-
}
|
80 |
-
|
81 |
-
.nav-button {
|
82 |
-
background-color: var(--button-color) !important; /* 修改为FAF9F6 */
|
83 |
-
color: var(--black) !important;
|
84 |
-
text-decoration: none;
|
85 |
-
font-weight: bold;
|
86 |
-
font-size: 20px;
|
87 |
-
padding: 6px 20px !important;
|
88 |
-
border-radius: 24px !important;
|
89 |
-
border: none !important;
|
90 |
-
transition: opacity 0.2s;
|
91 |
-
flex: 1;
|
92 |
-
max-width: 200px;
|
93 |
-
text-align: center;
|
94 |
-
}
|
95 |
-
|
96 |
-
.nav-button:hover {
|
97 |
-
opacity: 0.8 !important;
|
98 |
}
|
99 |
|
100 |
-
.
|
|
|
|
|
101 |
width: 100%;
|
102 |
-
|
103 |
-
padding: 20px;
|
104 |
-
background-color: var(--text-color) !important;
|
105 |
-
border-radius: 8px;
|
106 |
-
box-shadow: var(--shadow);
|
107 |
-
}
|
108 |
-
/* 强制底部链接为白色背景 */
|
109 |
-
#component-16, /* Use via API 部分 */
|
110 |
-
#component-17, /* Settings 部分 */
|
111 |
-
#component-18 { /* Built with Gradio 部分 */
|
112 |
-
background-color: var(--white) !important;
|
113 |
}
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
}
|
122 |
|
|
|
|
|
|
|
|
|
123 |
|
124 |
-
/* 其他样式保持不变 */
|
125 |
.result-container {
|
126 |
display: flex;
|
127 |
gap: 20px;
|
@@ -303,19 +295,21 @@ def export_markdown(results):
|
|
303 |
except Exception as e:
|
304 |
raise gr.Error(f"Error exporting markdown: {str(e)}")
|
305 |
|
306 |
-
|
307 |
with gr.Blocks(css=CSS, title="Document Analysis System") as demo:
|
308 |
results_state = gr.State()
|
309 |
|
310 |
-
#
|
311 |
-
with gr.Column(elem_classes=["
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
|
|
|
|
|
|
319 |
|
320 |
with gr.Column(elem_classes=["upload-section"]):
|
321 |
file_type = gr.Radio(
|
|
|
14 |
import pdf2image
|
15 |
|
16 |
API_URL = "https://t707h6d9q6oftbx3.aistudio-app.com/layout-parsing"
|
17 |
+
TOKEN = os.getenv("API_TOKEN")
|
18 |
|
19 |
|
20 |
CSS = """
|
21 |
:root {
|
22 |
+
--sand-color: #FAF9F6;
|
23 |
--white: #ffffff;
|
24 |
--shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
25 |
+
--text-color: #FAF9F6;
|
26 |
--black:#000000;
|
27 |
+
--link-hover: #2b6cb0;
|
28 |
--content-width: 1200px;
|
|
|
29 |
}
|
30 |
|
31 |
body {
|
32 |
display: flex;
|
33 |
justify-content: center;
|
34 |
background-color: var(--sand-color);
|
35 |
+
color: var(--text-color);
|
36 |
font-family: Arial, sans-serif;
|
37 |
}
|
38 |
|
|
|
41 |
width: 100% !important;
|
42 |
margin: 20px auto;
|
43 |
padding: 20px;
|
44 |
+
background-color: var(--white);
|
45 |
+
}
|
46 |
+
|
47 |
+
#component-0,
|
48 |
+
#tabs,
|
49 |
+
#settings {
|
50 |
background-color: var(--white) !important;
|
51 |
+
padding: 15px;
|
52 |
}
|
53 |
|
54 |
+
.upload-section {
|
|
|
55 |
width: 100%;
|
56 |
+
margin: 0 auto 30px;
|
57 |
+
padding: 20px;
|
58 |
+
background-color: var(--sand-color) !important;
|
59 |
border-radius: 8px;
|
60 |
+
box-shadow: var(--shadow);
|
61 |
+
}
|
62 |
+
|
63 |
+
.center-content {
|
64 |
+
display: flex;
|
65 |
+
flex-direction: column;
|
66 |
+
align-items: center;
|
67 |
+
text-align: center;
|
68 |
+
margin-bottom: 20px;
|
69 |
+
}
|
70 |
+
|
71 |
+
.header {
|
72 |
+
margin-bottom: 30px;
|
73 |
+
width: 100%;
|
74 |
}
|
75 |
|
76 |
.logo-container {
|
77 |
width: 100%;
|
78 |
+
margin-bottom: 20px;
|
|
|
79 |
}
|
80 |
|
81 |
.logo-img {
|
|
|
85 |
display: block;
|
86 |
}
|
87 |
|
88 |
+
.nav-bar {
|
|
|
89 |
display: flex;
|
90 |
justify-content: center;
|
91 |
+
background-color: var(--white);
|
92 |
+
padding: 15px 0;
|
93 |
+
box-shadow: var(--shadow);
|
94 |
+
margin-bottom: 20px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
}
|
96 |
|
97 |
+
.nav-links {
|
98 |
+
display: flex;
|
99 |
+
gap: 30px;
|
100 |
width: 100%;
|
101 |
+
justify-content: center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
}
|
103 |
|
104 |
+
.nav-link {
|
105 |
+
color: var(--black);
|
106 |
+
text-decoration: none;
|
107 |
+
font-weight: bold;
|
108 |
+
font-size: 24px;
|
109 |
+
transition: color 0.2s;
|
110 |
}
|
111 |
|
112 |
+
.nav-link:hover {
|
113 |
+
color: var(--link-hover);
|
114 |
+
text-decoration: none;
|
115 |
+
}
|
116 |
|
|
|
117 |
.result-container {
|
118 |
display: flex;
|
119 |
gap: 20px;
|
|
|
295 |
except Exception as e:
|
296 |
raise gr.Error(f"Error exporting markdown: {str(e)}")
|
297 |
|
|
|
298 |
with gr.Blocks(css=CSS, title="Document Analysis System") as demo:
|
299 |
results_state = gr.State()
|
300 |
|
301 |
+
# 添加logo图片
|
302 |
+
with gr.Column(elem_classes=["logo-container"]):
|
303 |
+
gr.Image("英文.png", elem_classes=["logo-img"], show_label=False)
|
304 |
+
|
305 |
+
# 添加导航栏链接
|
306 |
+
with gr.Row(elem_classes=["nav-bar"]):
|
307 |
+
gr.HTML("""
|
308 |
+
<div class="nav-links">
|
309 |
+
<a href="https://github.com/PaddlePaddle/PaddleOCR" class="nav-link" target="_blank">GitHub</a>
|
310 |
+
<a href="https://paddleocr.ai" class="nav-link" target="_blank">Homepage</a>
|
311 |
+
</div>
|
312 |
+
""")
|
313 |
|
314 |
with gr.Column(elem_classes=["upload-section"]):
|
315 |
file_type = gr.Radio(
|