Ankur Goyal commited on
Commit
3441721
1 Parent(s): 47c4130

Basics work

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app.py +73 -67
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🦉
4
  colorFrom: purple
5
  colorTo: purple
6
  sdk: gradio
7
- sdk_version: 3.2
8
  app_file: app.py
9
  pinned: true
10
  ---
 
4
  colorFrom: purple
5
  colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 3.1.7
8
  app_file: app.py
9
  pinned: true
10
  ---
app.py CHANGED
@@ -89,7 +89,14 @@ QUESTION_FILES = {}
89
  FIELDS = {
90
  "Vendor Name": ["Vendor Name - Logo?", "Vendor Name - Address?"],
91
  "Vendor Address": ["Vendor Address?"],
 
 
 
 
 
92
  "Invoice Total": ["Invoice Total?"],
 
 
93
  }
94
 
95
 
@@ -379,74 +386,73 @@ with gr.Blocks(css=CSS) as demo:
379
  submit_button = gr.Button(
380
  "Submit", variant="primary", elem_id="submit-button"
381
  )
382
- with gr.Column():
383
- # with gr.Tab("Table"):
384
- output_table = gr.Dataframe(
385
- headers=["Field", "Value"],
386
- value=[[name, None] for name in FIELDS.keys()],
387
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
 
389
- # with gr.Tab("JSON"):
390
- # XXX RENAME
391
- output = gr.JSON(label="Output", visible=False)
392
-
393
- # for cb in [img_clear_button, clear_button]:
394
- # cb.click(
395
- # lambda _: (
396
- # gr.update(visible=False, value=None),
397
- # None,
398
- # gr.update(visible=False, value=None),
399
- # gr.update(value=None),
400
- # gr.update(visible=False),
401
- # None,
402
- # None,
403
- # None,
404
- # gr.update(visible=False, value=None),
405
- # None,
406
- # ),
407
- # inputs=clear_button,
408
- # outputs=[
409
- # image,
410
- # document,
411
- # output,
412
- # output_table,
413
- # img_clear_button,
414
- # example_image,
415
- # upload,
416
- # url,
417
- # url_error,
418
- # question,
419
- # ],
420
- # )
421
- #
422
- # upload.change(
423
- # fn=process_upload,
424
- # inputs=[upload],
425
- # outputs=[document, image, img_clear_button, output, output_table, url_error],
426
- # )
427
- # submit.click(
428
- # fn=process_path,
429
- # inputs=[url],
430
- # outputs=[document, image, img_clear_button, output, output_table, url_error],
431
- # )
432
- #
433
- # question.submit(
434
- # fn=process_question,
435
- # inputs=[question, document, model],
436
- # outputs=[image, output, output_table],
437
- # )
438
- #
439
- # submit_button.click(
440
- # process_question,
441
- # inputs=[question, document, model],
442
- # outputs=[image, output, output_table],
443
- # )
444
- #
445
- # model.change(
446
- # process_question,
447
- # inputs=[question, document, model],
448
- # outputs=[image, output, output_table],
449
- # )
450
 
451
  example_image.change(
452
  fn=load_example_document,
 
89
  FIELDS = {
90
  "Vendor Name": ["Vendor Name - Logo?", "Vendor Name - Address?"],
91
  "Vendor Address": ["Vendor Address?"],
92
+ "Invoice Number": ["Invoice Number?"],
93
+ "Invoice Date": ["Invoice Date?"],
94
+ "Due Date": ["Due Date?"],
95
+ "Subtotal": ["Subtotal?"],
96
+ "Total Tax": ["Total Tax?"],
97
  "Invoice Total": ["Invoice Total?"],
98
+ "Amount Due": ["Amount Due?"],
99
+ "Payment Terms": ["Payment Terms?"],
100
  }
101
 
102
 
 
386
  submit_button = gr.Button(
387
  "Submit", variant="primary", elem_id="submit-button"
388
  )
389
+ with gr.Tabs():
390
+ with gr.TabItem("Table"):
391
+ output_table = gr.Dataframe(
392
+ headers=["Field", "Value"],
393
+ value=[[name, None] for name in FIELDS.keys()],
394
+ )
395
+
396
+ with gr.TabItem("JSON"):
397
+ output = gr.JSON(label="Output", visible=False)
398
+
399
+ for cb in [img_clear_button, clear_button]:
400
+ cb.click(
401
+ lambda _: (
402
+ gr.update(visible=False, value=None),
403
+ None,
404
+ gr.update(visible=False, value=None),
405
+ gr.update(value=None),
406
+ gr.update(visible=False),
407
+ None,
408
+ None,
409
+ None,
410
+ gr.update(visible=False, value=None),
411
+ None,
412
+ ),
413
+ inputs=clear_button,
414
+ outputs=[
415
+ image,
416
+ document,
417
+ output,
418
+ output_table,
419
+ img_clear_button,
420
+ example_image,
421
+ upload,
422
+ url,
423
+ url_error,
424
+ question,
425
+ ],
426
+ )
427
+
428
+ upload.change(
429
+ fn=process_upload,
430
+ inputs=[upload],
431
+ outputs=[document, image, img_clear_button, output, output_table, url_error],
432
+ )
433
+ submit.click(
434
+ fn=process_path,
435
+ inputs=[url],
436
+ outputs=[document, image, img_clear_button, output, output_table, url_error],
437
+ )
438
 
439
+ question.submit(
440
+ fn=process_question,
441
+ inputs=[question, document, model],
442
+ outputs=[image, output, output_table],
443
+ )
444
+
445
+ submit_button.click(
446
+ process_question,
447
+ inputs=[question, document, model],
448
+ outputs=[image, output, output_table],
449
+ )
450
+
451
+ model.change(
452
+ process_question,
453
+ inputs=[question, document, model],
454
+ outputs=[image, output, output_table],
455
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
456
 
457
  example_image.change(
458
  fn=load_example_document,