HilaMarcus commited on
Commit
0789187
1 Parent(s): 601d2e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -25
app.py CHANGED
@@ -72,26 +72,6 @@ def normalize_bbox(box, width, height, padding=0.005):
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 = {
@@ -145,7 +125,7 @@ def process_upload(file):
145
  colors = ["#64A087", "green", "black"]
146
 
147
 
148
- def process_question(question, document, model=list(CHECKPOINTS.keys())[0]):
149
  if not question or document is None:
150
  return None, None, None
151
 
@@ -183,10 +163,7 @@ def process_question(question, document, model=list(CHECKPOINTS.keys())[0]):
183
 
184
  def load_example_document(img, question, model):
185
  if img is not None:
186
- if question in question_files:
187
- document = load_document(question_files[question])
188
- else:
189
- document = ImageDocument(Image.fromarray(img), get_ocr_reader())
190
  preview, answer, answer_text = process_question(question, document, model)
191
  return document, question, preview, gr.update(visible=True), answer, answer_text
192
  else:
 
72
 
73
 
74
  examples = [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  ]
76
 
77
  question_files = {
 
125
  colors = ["#64A087", "green", "black"]
126
 
127
 
128
+ def process_question(question = "What is the purchase amount?", document, model=list(CHECKPOINTS.keys())[0]):
129
  if not question or document is None:
130
  return None, None, None
131
 
 
163
 
164
  def load_example_document(img, question, model):
165
  if img is not None:
166
+ document = ImageDocument(Image.fromarray(img), get_ocr_reader())
 
 
 
167
  preview, answer, answer_text = process_question(question, document, model)
168
  return document, question, preview, gr.update(visible=True), answer, answer_text
169
  else: