Fangyu Liu commited on
Commit
4a35755
1 Parent(s): 8e61810

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -155,12 +155,12 @@ processor_deplot = Pix2StructProcessor.from_pretrained("google/deplot")
155
  def process_document(image, question):
156
  # image = Image.open(image)
157
  inputs = processor_deplot(images=image, text="Generate the underlying data table for the figure below:", return_tensors="pt")
158
- predictions = model_deplot.generate(**inputs)
159
  table = processor_deplot.decode(predictions[0], skip_special_tokens=True)
160
 
161
  # send prompt+table to LLM
162
  res = evaluate(table.replace("<0x0A>", "\n"), question)
163
- return res
164
 
165
  description = "Demo for deplot+llm for QA or summarisation. To use it, simply upload your image and type a question and click 'submit', or click one of the examples to load them. Read more at the links below."
166
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2212.10505' target='_blank'>DePlot: One-shot visual language reasoning by plot-to-table translation</a></p>"
 
155
  def process_document(image, question):
156
  # image = Image.open(image)
157
  inputs = processor_deplot(images=image, text="Generate the underlying data table for the figure below:", return_tensors="pt")
158
+ predictions = model_deplot.generate(**inputs, max_new_tokens=512)
159
  table = processor_deplot.decode(predictions[0], skip_special_tokens=True)
160
 
161
  # send prompt+table to LLM
162
  res = evaluate(table.replace("<0x0A>", "\n"), question)
163
+ return res + "\n\n" + res.split("A:")[-1]
164
 
165
  description = "Demo for deplot+llm for QA or summarisation. To use it, simply upload your image and type a question and click 'submit', or click one of the examples to load them. Read more at the links below."
166
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2212.10505' target='_blank'>DePlot: One-shot visual language reasoning by plot-to-table translation</a></p>"