Spaces:
Runtime error
Runtime error
linjieccc
commited on
Commit
•
c757801
1
Parent(s):
128bcf9
update app.py
Browse files- app.py +24 -26
- header.html +3 -7
- paddlenlp-preview.jpeg +0 -3
app.py
CHANGED
@@ -112,40 +112,40 @@ class PdfReader(object):
|
|
112 |
|
113 |
examples = [
|
114 |
[
|
115 |
-
"
|
116 |
-
"
|
117 |
],
|
118 |
[
|
119 |
-
"
|
120 |
-
"
|
121 |
],
|
122 |
[
|
123 |
-
"
|
124 |
-
"
|
125 |
],
|
126 |
[
|
127 |
-
"
|
128 |
-
"
|
129 |
],
|
130 |
[
|
131 |
-
"
|
132 |
-
"
|
133 |
],
|
134 |
[
|
135 |
-
"
|
136 |
-
"
|
137 |
],
|
138 |
[
|
139 |
-
"
|
140 |
-
"
|
141 |
],
|
142 |
[
|
143 |
-
"
|
144 |
-
"
|
145 |
],
|
146 |
[
|
147 |
-
"
|
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
|
359 |
-
f"
|
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
|