linjieccc commited on
Commit
c757801
1 Parent(s): 128bcf9

update app.py

Browse files
Files changed (3) hide show
  1. app.py +24 -26
  2. header.html +3 -7
  3. paddlenlp-preview.jpeg +0 -3
app.py CHANGED
@@ -112,40 +112,40 @@ class PdfReader(object):
112
 
113
  examples = [
114
  [
115
- "invoice.jpg",
116
- "发票号码是多少?",
117
  ],
118
  [
119
- "resume.png",
120
- "五百丁本次想要担任的是什么职位?",
121
  ],
122
  [
123
- "custom_declaration_form.png",
124
- "在哪个口岸进口?"
125
  ],
126
  [
127
- "medical_bill_1.png",
128
- "票据的具体名称是什么?"
129
  ],
130
  [
131
- "budget_form.png",
132
- "What is the total actual and/or obligated expenses of ECG Center?"
133
  ],
134
  [
135
- "website_design_guide.jpeg",
136
- "Which quality component has the icon of a pen in it?"
137
  ],
138
  [
139
- "poster.png",
140
- "Which gift idea needs a printer?"
141
  ],
142
  [
143
- "medical_bill_2.png",
144
- "患者さんは何でお金を払いますか。"
145
  ],
146
  [
147
- "receipt.png",
148
- "เบอร์โทรร้านอะไรคะ"
149
  ],
150
  ]
151
 
@@ -250,10 +250,10 @@ def process_prompt(prompt, document, lang="ch"):
250
  )
251
 
252
 
253
- def load_example_document(img, prompt):
254
  if img is not None:
255
  document = prompt_files[prompt]
256
- preview, answer, answer_text = process_prompt(prompt, document)
257
  return document, prompt, preview, gr.update(visible=True), answer, answer_text
258
  else:
259
  return None, None, None, gr.update(visible=False), None, None
@@ -355,9 +355,8 @@ gradio-app h2, .gradio-app h2 {
355
  with gr.Blocks(css=CSS) as demo:
356
  gr.HTML(read_content("header.html"))
357
  gr.Markdown(
358
- f" ⚡DocPrompt⚡ is a Document Prompt Engine Powered by Baidu Wenxin Document Intelligence. 🚀\n"
359
- f" To use it, simply upload an image or PDF, type the prompt, and click 'submit', or "
360
- f" click one of the examples to load them."
361
  )
362
 
363
  document = gr.Variable()
@@ -463,7 +462,7 @@ with gr.Blocks(css=CSS) as demo:
463
 
464
  prompt.submit(
465
  fn=process_prompt,
466
- inputs=[prompt, document],
467
  outputs=[image, output, output_text],
468
  )
469
 
@@ -481,11 +480,10 @@ with gr.Blocks(css=CSS) as demo:
481
 
482
  example_image.change(
483
  fn=load_example_document,
484
- inputs=[example_image, example_prompt],
485
  outputs=[document, prompt, image, img_clear_button, output, output_text],
486
  )
487
 
488
- gr.Image('./paddlenlp-preview.jpeg')
489
  gr.Markdown("[![Stargazers repo roster for @PaddlePaddle/PaddleNLP](https://reporoster.com/stars/PaddlePaddle/PaddleNLP)](https://github.com/PaddlePaddle/PaddleNLP)")
490
  gr.HTML(read_content("footer.html"))
491
 
 
112
 
113
  examples = [
114
  [
115
+ "budget_form.png",
116
+ "What is the total actual and/or obligated expenses of ECG Center?"
117
  ],
118
  [
119
+ "medical_bill_2.png",
120
+ "患者さんは何でお金を払いますか。"
121
  ],
122
  [
123
+ "receipt.png",
124
+ "เบอร์โทรร้านอะไรคะ"
125
  ],
126
  [
127
+ "poster.png",
128
+ "Which gift idea needs a printer?"
129
  ],
130
  [
131
+ "resume.png",
132
+ "五百丁本次想要担任的是什么职位?",
133
  ],
134
  [
135
+ "custom_declaration_form.png",
136
+ "在哪个口岸进口?"
137
  ],
138
  [
139
+ "invoice.jpg",
140
+ "发票号码是多少?",
141
  ],
142
  [
143
+ "medical_bill_1.png",
144
+ "票据的具体名称是什么?"
145
  ],
146
  [
147
+ "website_design_guide.jpeg",
148
+ "Which quality component has the icon of a pen in it?"
149
  ],
150
  ]
151
 
 
250
  )
251
 
252
 
253
+ def load_example_document(img, prompt, lang="ch"):
254
  if img is not None:
255
  document = prompt_files[prompt]
256
+ preview, answer, answer_text = process_prompt(prompt, document, lang)
257
  return document, prompt, preview, gr.update(visible=True), answer, answer_text
258
  else:
259
  return None, None, None, gr.update(visible=False), None, None
 
355
  with gr.Blocks(css=CSS) as demo:
356
  gr.HTML(read_content("header.html"))
357
  gr.Markdown(
358
+ f" ⚡DocPrompt⚡ is a Document Prompt Engine uses ERNIE-LayoutX as the backbone model.\n"
359
+ f" The engine is powered by Baidu Wenxin Document Intelligence Team 🚀 and is ability for multilingual documents information extraction and question ansering.\n"
 
360
  )
361
 
362
  document = gr.Variable()
 
462
 
463
  prompt.submit(
464
  fn=process_prompt,
465
+ inputs=[prompt, document, ocr_lang],
466
  outputs=[image, output, output_text],
467
  )
468
 
 
480
 
481
  example_image.change(
482
  fn=load_example_document,
483
+ inputs=[example_image, example_prompt, ocr_lang],
484
  outputs=[document, prompt, image, img_clear_button, output, output_text],
485
  )
486
 
 
487
  gr.Markdown("[![Stargazers repo roster for @PaddlePaddle/PaddleNLP](https://reporoster.com/stars/PaddlePaddle/PaddleNLP)](https://github.com/PaddlePaddle/PaddleNLP)")
488
  gr.HTML(read_content("footer.html"))
489
 
header.html CHANGED
@@ -20,11 +20,7 @@
20
  margin-bottom: 10px;
21
  justify-content: center;
22
  ">
23
- <a href="https://github.com/PaddlePaddle/PaddleNLP"><h1 style="font-weight: 900; margin-bottom: 7px;">
24
- DocPrompt 🚀
25
  </h1></a>
26
- </div>
27
- <!-- <p style="margin-bottom: 10px; font-weight: 900; font-size: 100%">
28
- ⚡DocPrompt⚡ is a Document Prompt Engine Powered by <br> Document Intelligence Technology in Baidu Wenxin<br>. 🚀 To use it, simply upload an image or PDF, type the prompt, and click 'submit', or click one of the examples to load them.
29
- </p>
30
- </div> -->
 
20
  margin-bottom: 10px;
21
  justify-content: center;
22
  ">
23
+ <a href="https://github.com/PaddlePaddle/PaddleNLP"><h1 style="font-weight: 900; align-items: center; margin-bottom: 7px;">
24
+ ERNIE-LayoutX DocPrompt Engine
25
  </h1></a>
26
+ </div>
 
 
 
 
paddlenlp-preview.jpeg DELETED

Git LFS Details

  • SHA256: 401f593de925041f45fb4acb63a9dc256770898e79a3b06a2bb3e2df81c092a2
  • Pointer size: 131 Bytes
  • Size of remote file: 118 kB