Ankur Goyal commited on
Commit
d1e1ea7
1 Parent(s): 194858a

Improve answer preview

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -126,10 +126,13 @@ def process_question(question, document, model=list(CHECKPOINTS.keys())[0]):
126
  if document is None:
127
  return None, None, None
128
 
 
129
  predictions = run_pipeline(model, question, document, 3)
130
  pages = [x.copy().convert("RGB") for x in document.preview]
131
  for i, p in enumerate(ensure_list(predictions)):
132
- if i > 0:
 
 
133
  # Keep the code around to produce multiple boxes, but only show the top
134
  # prediction for now
135
  break
@@ -151,7 +154,7 @@ def process_question(question, document, model=list(CHECKPOINTS.keys())[0]):
151
  gr.update(visible=True, value=predictions),
152
  gr.update(
153
  visible=True,
154
- value=predictions[0]["answer"] if ensure_list(predictions) else None,
155
  ),
156
  )
157
 
126
  if document is None:
127
  return None, None, None
128
 
129
+ text_value = None
130
  predictions = run_pipeline(model, question, document, 3)
131
  pages = [x.copy().convert("RGB") for x in document.preview]
132
  for i, p in enumerate(ensure_list(predictions)):
133
+ if i == 0:
134
+ text_value = p["answer"]
135
+ else:
136
  # Keep the code around to produce multiple boxes, but only show the top
137
  # prediction for now
138
  break
154
  gr.update(visible=True, value=predictions),
155
  gr.update(
156
  visible=True,
157
+ value=text_value,
158
  ),
159
  )
160