brezende commited on
Commit
fe24bbe
1 Parent(s): 95c8e0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -16
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,7 +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
 
293
  document = gr.Variable()
294
  example_question = gr.Textbox(visible=False)
@@ -297,9 +298,9 @@ with gr.Blocks(css=CSS) as demo:
297
  with gr.Row(equal_height=True):
298
  with gr.Column():
299
  with gr.Row():
300
- gr.Markdown("## 1. Select a file", elem_id="select-a-file")
301
  img_clear_button = gr.Button(
302
- "Clear", variant="secondary", elem_id="file-clear", visible=False
303
  )
304
  image = gr.Gallery(visible=False)
305
  with gr.Row(equal_height=True):
@@ -328,10 +329,10 @@ with gr.Blocks(css=CSS) as demo:
328
  )
329
 
330
  with gr.Column() as col:
331
- gr.Markdown("## 2. Ask a question")
332
  question = gr.Textbox(
333
  label="Question",
334
- placeholder="e.g. What is the invoice number?",
335
  lines=1,
336
  max_lines=1,
337
  )
@@ -344,11 +345,11 @@ with gr.Blocks(css=CSS) as demo:
344
  with gr.Row():
345
  clear_button = gr.Button("Clear", variant="secondary")
346
  submit_button = gr.Button(
347
- "Submit", variant="primary", elem_id="submit-button"
348
  )
349
  with gr.Column():
350
  output_text = gr.Textbox(
351
- label="Top Answer", visible=False, elem_id="answer"
352
  )
353
  output = gr.JSON(label="Output", visible=False)
354
 
 
21
 
22
 
23
  CHECKPOINTS = {
24
+ "CQI FLMv1 Base PT": "impira/layoutlm-document-qa",
25
+ "CQI FLMv1 para Faturas 💸": "impira/layoutlm-invoices",
26
+ "CQI FDonut": "naver-clova-ix/donut-base-finetuned-docvqa",
27
+ "CQI Assistant Eyes 🤖": "cloudqi/CQI_Visual_Question_Awnser_PT_v0"
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