brezende commited on
Commit
c853bd0
1 Parent(s): 32db3ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -24
app.py CHANGED
@@ -21,9 +21,10 @@ 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 = {}
@@ -74,15 +75,15 @@ def normalize_bbox(box, width, height, padding=0.005):
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",
@@ -95,9 +96,9 @@ examples = [
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
 
@@ -288,15 +289,7 @@ 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()
302
  example_question = gr.Textbox(visible=False)
@@ -305,9 +298,9 @@ with gr.Blocks(css=CSS) as demo:
305
  with gr.Row(equal_height=True):
306
  with gr.Column():
307
  with gr.Row():
308
- gr.Markdown("## 1. Select a file", elem_id="select-a-file")
309
  img_clear_button = gr.Button(
310
- "Clear", variant="secondary", elem_id="file-clear", visible=False
311
  )
312
  image = gr.Gallery(visible=False)
313
  with gr.Row(equal_height=True):
@@ -336,10 +329,10 @@ with gr.Blocks(css=CSS) as demo:
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
  )
@@ -352,11 +345,11 @@ with gr.Blocks(css=CSS) as demo:
352
  with gr.Row():
353
  clear_button = gr.Button("Clear", variant="secondary")
354
  submit_button = gr.Button(
355
- "Submit", variant="primary", elem_id="submit-button"
356
  )
357
  with gr.Column():
358
  output_text = gr.Textbox(
359
- label="Top Answer", visible=False, elem_id="answer"
360
  )
361
  output = gr.JSON(label="Output", visible=False)
362
 
 
21
 
22
 
23
  CHECKPOINTS = {
24
+ "CQI Kleber 🤖": "cloudqi/CQI_Visual_Question_Awnser_PT_v0",
25
+ "LayoutLMv1 Padrão": "impira/layoutlm-document-qa",
26
+ "LayoutLMv1 para Faturas 💸": "impira/layoutlm-invoices",
27
+ "Donut": "naver-clova-ix/donut-base-finetuned-docvqa",
28
  }
29
 
30
  PIPELINES = {}
 
75
  examples = [
76
  [
77
  "invoice.png",
78
+ "Qual é o número da fatura?",
79
  ],
80
  [
81
  "contract.jpeg",
82
+ "Qual é o valor da compra?",
83
  ],
84
  [
85
  "statement.png",
86
+ "Quais são as vendas líquidas para 2020?",
87
  ],
88
  # [
89
  # "docquery.png",
 
96
  ]
97
 
98
  question_files = {
99
+ "Quais são as vendas líquidas para 2020?": "statement.pdf",
100
+ "Quantas curtidas tem o espaço?": "https://huggingface.co/spaces/impira/docquery",
101
+ "Qual é o título do post número 5?": "https://news.ycombinator.com",
102
  }
103
 
104
 
 
289
  """
290
 
291
  with gr.Blocks(css=CSS) as demo:
292
+ gr.Markdown("# Mecanismo de Consulta de Documentos")
 
 
 
 
 
 
 
 
293
 
294
  document = gr.Variable()
295
  example_question = gr.Textbox(visible=False)
 
298
  with gr.Row(equal_height=True):
299
  with gr.Column():
300
  with gr.Row():
301
+ gr.Markdown("## 1. Selecione um arquivo", elem_id="select-a-file")
302
  img_clear_button = gr.Button(
303
+ "Limpar", variant="secondary", elem_id="file-clear", visible=False
304
  )
305
  image = gr.Gallery(visible=False)
306
  with gr.Row(equal_height=True):
 
329
  )
330
 
331
  with gr.Column() as col:
332
+ gr.Markdown("## 2. Faça uma pergunta")
333
  question = gr.Textbox(
334
  label="Question",
335
+ placeholder="e.g. Qual é o número da fatura?",
336
  lines=1,
337
  max_lines=1,
338
  )
 
345
  with gr.Row():
346
  clear_button = gr.Button("Clear", variant="secondary")
347
  submit_button = gr.Button(
348
+ "Enviar", variant="primary", elem_id="submit-button"
349
  )
350
  with gr.Column():
351
  output_text = gr.Textbox(
352
+ label="Resposta principal", visible=False, elem_id="answer"
353
  )
354
  output = gr.JSON(label="Output", visible=False)
355