XinyueZhou commited on
Commit
9e32c06
·
verified ·
1 Parent(s): d1abef2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -68
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", "c9e4aaf9634724e215690ba66a66dbdbdf3222a2")
18
 
19
 
20
  CSS = """
21
  :root {
22
- --sand-color: #D7B4F8;
23
  --white: #ffffff;
24
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
25
- --text-color: #F5ECFD;
26
  --black:#000000;
27
- --link-hover: #F5ECFD;
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(--black);
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
- /* 修改1: 优化header容器样式 */
49
- .header-container {
50
  width: 100%;
51
- background-color: var(--text-color) !important;
52
- padding: 20px 0 10px 0; /* 减少底部padding */
53
- margin-bottom: 20px;
54
  border-radius: 8px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
56
 
57
  .logo-container {
58
  width: 100%;
59
- margin-bottom: 15px; /* 减少logo与按钮间距 */
60
- text-align: center;
61
  }
62
 
63
  .logo-img {
@@ -67,61 +85,35 @@ body {
67
  display: block;
68
  }
69
 
70
- /* 修改2: 优化导航按钮布局 */
71
- .nav-buttons {
72
  display: flex;
73
  justify-content: center;
74
- gap: 20px; /* 减少按钮间距 */
75
- margin-top: 10px; /* 减少顶部间距 */
76
- width: 80%; /* 控制按钮区域宽度 */
77
- margin-left: auto;
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
- .upload-section {
 
 
101
  width: 100%;
102
- margin: 0 auto 30px;
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
- footer .gr-panel,
116
- .gr-footer,
117
- .gr-panel:has(a[href*="api"]), /* 针对Use via API */
118
- .gr-panel:has(a[href*="settings"]) /* 针对Settings */ {
119
- background-color: var(--white) !important;
120
- color: var(--black) !important;
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
- # 修改1: 将logo和导航按钮整合到一个容器中
311
- with gr.Column(elem_classes=["header-container"]):
312
- with gr.Column(elem_classes=["logo-container"]):
313
- gr.Image("pp-structurev3_altered.png", elem_classes=["logo-img"], show_label=False)
314
-
315
- # 修改2: 使用按钮代替链接
316
- with gr.Row(elem_classes=["nav-buttons"]):
317
- gr.Button("GitHub", link="https://github.com/PaddlePaddle/PaddleOCR", elem_classes=["nav-button"])
318
- gr.Button("Homepage", link="https://paddleocr.ai", elem_classes=["nav-button"])
 
 
 
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(