Back to Llama Index

Deplot Reader Demo

docs/examples/data_connectors/deplot/DeplotReader.ipynb

0.14.211.6 KB
Original Source

Deplot Reader Demo

In this notebook we showcase the capabilities of our ImageTabularChartReader, which is powered by the DePlot model https://arxiv.org/abs/2212.10505.

python
%pip install llama-index-readers-file
python
from llama_index.readers.file import ImageTabularChartReader
from llama_index.core import SummaryIndex
from llama_index.core.response.notebook_utils import display_response
from pathlib import Path
python
loader = ImageTabularChartReader(keep_image=True)

Load Protected Waters Chart

This chart shows the percentage of marine territorial waters that are protected for each country.

python
documents = loader.load_data(file=Path("./marine_chart.png"))
python
print(documents[0].text)
python
summary_index = SummaryIndex.from_documents(documents)
response = summary_index.as_query_engine().query(
    "What is the difference between the shares of Greenland and the share of"
    " Mauritania?"
)
python
display_response(response, show_source=True)

Load Pew Research Chart

Here we load in a Pew Research chart showing international views of the US/Biden.

Source: https://www.pewresearch.org/global/2023/06/27/international-views-of-biden-and-u-s-largely-positive/

python
documents = loader.load_data(file=Path("./pew1.png"))
python
print(documents[0].text)
python
summary_index = SummaryIndex.from_documents(documents)
response = summary_index.as_query_engine().query(
    "What percentage says that the US contributes to peace and stability?"
)
python
display_response(response, show_source=True)