mqcm2 commited on
Commit
ec21dfa
·
verified ·
1 Parent(s): 733725d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -42
app.py CHANGED
@@ -21,9 +21,8 @@ def ensure_list(x):
21
 
22
 
23
  CHECKPOINTS = {
24
- "LayoutLMv1 🦉": "impira/layoutlm-document-qa",
25
- "LayoutLMv1 for Invoices 💸": "impira/layoutlm-invoices",
26
- "Donut 🍩": "naver-clova-ix/donut-base-finetuned-docvqa",
27
  }
28
 
29
  PIPELINES = {}
@@ -71,34 +70,6 @@ def normalize_bbox(box, width, height, padding=0.005):
71
  return [min_x * width, min_y * height, max_x * width, max_y * height]
72
 
73
 
74
- examples = [
75
- [
76
- "invoice.png",
77
- "What is the invoice number?",
78
- ],
79
- [
80
- "contract.jpeg",
81
- "What is the purchase amount?",
82
- ],
83
- [
84
- "statement.png",
85
- "What are net sales for 2020?",
86
- ],
87
- # [
88
- # "docquery.png",
89
- # "How many likes does the space have?",
90
- # ],
91
- # [
92
- # "hacker_news.png",
93
- # "What is the title of post number 5?",
94
- # ],
95
- ]
96
-
97
- question_files = {
98
- "What are net sales for 2020?": "statement.pdf",
99
- "How many likes does the space have?": "https://huggingface.co/spaces/impira/docquery",
100
- "What is the title of post number 5?": "https://news.ycombinator.com",
101
- }
102
 
103
 
104
  def process_path(path):
@@ -288,14 +259,11 @@ gradio-app h2, .gradio-app h2 {
288
  """
289
 
290
  with gr.Blocks(css=CSS) as demo:
291
- gr.Markdown("# DocQuery: Document Query Engine")
292
  gr.Markdown(
293
- "DocQuery (created by [Impira](https://impira.com?utm_source=huggingface&utm_medium=referral&utm_campaign=docquery_space))"
294
- " uses LayoutLMv1 fine-tuned on DocVQA, a document visual question"
295
  " answering dataset, as well as SQuAD, which boosts its English-language comprehension."
296
- " To use it, simply upload an image or PDF, type a question, and click 'submit', or "
297
- " click one of the examples to load them."
298
- " DocQuery is MIT-licensed and available on [Github](https://github.com/impira/docquery)."
299
  )
300
 
301
  document = gr.Variable()
@@ -330,16 +298,12 @@ with gr.Blocks(css=CSS) as demo:
330
  )
331
  gr.Markdown("— or —")
332
  upload = gr.File(label=None, interactive=True, elem_id="short-upload-box")
333
- gr.Examples(
334
- examples=examples,
335
- inputs=[example_image, example_question],
336
- )
337
 
338
  with gr.Column() as col:
339
  gr.Markdown("## 2. Ask a question")
340
  question = gr.Textbox(
341
  label="Question",
342
- placeholder="e.g. What is the invoice number?",
343
  lines=1,
344
  max_lines=1,
345
  )
 
21
 
22
 
23
  CHECKPOINTS = {
24
+ "LayoutLMv1": "impira/layoutlm-document-qa",
25
+ "distilbert": "distilbert/distilbert-base-cased-distilled-squad",
 
26
  }
27
 
28
  PIPELINES = {}
 
70
  return [min_x * width, min_y * height, max_x * width, max_y * height]
71
 
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
 
75
  def process_path(path):
 
259
  """
260
 
261
  with gr.Blocks(css=CSS) as demo:
262
+ gr.Markdown("# Document Chatbot")
263
  gr.Markdown(
264
+ "Document Chatbot uses LayoutLMv1 fine-tuned on DocVQA, a document visual question"
 
265
  " answering dataset, as well as SQuAD, which boosts its English-language comprehension."
266
+ " To use it, simply upload an image or PDF, type a question, and click 'submit'."
 
 
267
  )
268
 
269
  document = gr.Variable()
 
298
  )
299
  gr.Markdown("— or —")
300
  upload = gr.File(label=None, interactive=True, elem_id="short-upload-box")
 
 
 
 
301
 
302
  with gr.Column() as col:
303
  gr.Markdown("## 2. Ask a question")
304
  question = gr.Textbox(
305
  label="Question",
306
+ placeholder="e.g. What is the document about?",
307
  lines=1,
308
  max_lines=1,
309
  )