This Streamlit web app leverages Google's GenerativeAI service (Gemini Pro Vision) to extract information from invoices based on user prompts and image analysis.
You can try this app on Streamlit:
YouTube Transcriber
- Image Upload: Upload an invoice image for analysis.
- Text Prompt: Provide additional context or specific questions about the invoice (optional).
- Invoice Understanding: Extract key details like items, prices, and totals using Gemini Pro Vision.
- Python 3.x
- Streamlit (
pip install streamlit
) dotenv
library (pip install python-dotenv
)- Google Cloud Project with GenerativeAI API enabled (https://cloud.google.com/ai/generative-ai)
- Pillow library (
pip install Pillow
)
- Create a virtual environment (recommended):
python -m venv venv
- Activate the environment:
source venv/bin/activate
(Windows:venv\Scripts\activate
) - Install dependencies:
pip install streamlit python-dotenv pillow
- Create a
.env
file in the project directory:- Add
GOOGLE_API_KEY=<YOUR_API_KEY>
(replace with your GenerativeAI API key)
- Add
- Open a terminal in the project directory.
- Run the app:
streamlit run app.py
- Access the app in your web browser at http://localhost:8501.
- Upload an invoice image.
- (Optional) Provide a text prompt to specify what information you want to extract from the invoice.
- Click the "Tell me about the image" button.
The app displays the extracted information from the invoice based on Gemini Pro Vision analysis and your input prompt (if provided). The working of this streamlit webapp is shown in the Screen shots below:
- The user uploads the invoice:
-
As shown in the above screen capture, the user asked who is this invoice billed to?
-
When the prompt is passed, the system replies:
As shown in the screen capture above, the app generates the name and address of the person whom this invoice is billed to.
- The user asks, "Payment is due in how many days?"
- The system replies with the number of days.
- This is a basic example using a free-tier API. Invoice extraction accuracy may vary.
- Consider integrating with a reliable invoice parsing library for more structured data extraction.
This application and its output are for informational purposes only and should not be used for financial accounting or legal purposes. Always consult a qualified professional for accurate invoice analysis.