vincentclaes commited on
Commit
f29f56e
1 Parent(s): b20d2a3

return none if document or question is none

Browse files
Files changed (1) hide show
  1. app.py +6 -23
app.py CHANGED
@@ -240,6 +240,8 @@ MODELS = {
240
 
241
 
242
  def process_question(question, document, model=list(MODELS.keys())[0]):
 
 
243
  prediction = MODELS[model](question=question, document=document)
244
  pages = [x.copy().convert("RGB") for x in document.preview]
245
  text_value = prediction["answer"]
@@ -403,32 +405,13 @@ examples = [
403
  [
404
  "bill_of_lading_1.png",
405
  "What is the shipper?",
406
- ],
407
- [
408
- "bill_of_lading_1.png",
409
- "What is the consignee?",
410
- ],
411
- [
412
- "bill_of_lading_1.png",
413
- "What is the consignee id?",
414
- ],
415
- [
416
- "bill_of_lading_1.png",
417
- "What is the carrier id?",
418
- ],
419
- [
420
- "bill_of_lading_1.png",
421
- "What is the description of the products?",
422
- ],
423
- [
424
- "bill_of_lading_1.png",
425
- "What is the quantity of the products?",
426
- ],
427
  ]
428
 
429
  with gr.Blocks(css=CSS) as demo:
430
- gr.Markdown("# Document Query Engine")
431
- gr.Markdown("### Compare performance of different document layout models. If you have any suggestions [contact me](https://www.linkedin.com/in/vincent-claes-0b346337/)")
 
432
 
433
  document = gr.Variable()
434
  example_question = gr.Textbox(visible=False)
 
240
 
241
 
242
  def process_question(question, document, model=list(MODELS.keys())[0]):
243
+ if not question or document is None:
244
+ return None, None, None
245
  prediction = MODELS[model](question=question, document=document)
246
  pages = [x.copy().convert("RGB") for x in document.preview]
247
  text_value = prediction["answer"]
 
405
  [
406
  "bill_of_lading_1.png",
407
  "What is the shipper?",
408
+ ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  ]
410
 
411
  with gr.Blocks(css=CSS) as demo:
412
+ gr.Markdown("# Document Query Engine</center>")
413
+ gr.Markdown("__Compare performance of different document layout models.__")
414
+ gr.Markdown("__If you have any suggestions [contact me](https://www.linkedin.com/in/vincent-claes-0b346337/)__")
415
 
416
  document = gr.Variable()
417
  example_question = gr.Textbox(visible=False)