A Streamlit-based application that extracts structured information from invoice images or PDFs. It preprocesses uploaded documents by straightening the images and then leverages Google’s Generative AI API to identify and format key details, such as merchant information, item details, taxes, and total amounts, into an organized JSON structure. The app also provides a Q&A feature for querying extracted information conversationally.
- Click here to access API.
- Read about how to use API.
- Straightening & Preprocessing: Automatically corrects image orientation.
- Invoice Data Extraction: Extracts key details such as merchant information, item list, tax details, and total amounts.
- Q&A Interface: Enables users to ask specific questions based on the extracted data, with responses generated conversationally.
For a quick overview of how the application works, check out the video demo. For a quick overview of how the API works, check out the video demo.
git clone <repository-url>
cd <repository-directory>
Ensure you have Conda installed. Then, create and activate a new environment:
conda create -n invoice_extractor_env python=3.10
conda activate invoice_extractor_env
Install all dependencies listed in requirements.txt
:
pip install -r requirements.txt
This project uses Google’s Generative AI API. To use it:
- Get your API key from Google and store it in a
.env
file in the project directory. Create your API key from here. - Add the following line in the
.env
file:GOOGLE_API_KEY=<Your-API-Key>
Start the Streamlit app by running:
streamlit run invoice_app.py
or
streamlit run full_invoice_app.py
- Open the app in your browser (Streamlit will display the link in your terminal).
- Upload an invoice image or PDF.
- The app will straighten the image, extract details, and display the formatted data.
After extraction, enter specific queries in the Q&A interface to get responses based on the extracted information.
- invoice_app.py: Main application code for processing invoices and handling Q&A interactions. Indicates a lightweight, focused application fetching only the required information.
- full_invoice_app.py: Main application code for processing invoices. Indicates a more comprehensive application fetching all available details.
- requirements.txt: List of dependencies for the project.
- The Q&A function only responds to questions relevant to the extracted invoice data.
- Missing values in the invoice are marked as
"null"
.