Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skitsanos/gemini-ocr
PDF Screenshot OCR Analysis with Google Gemini Pro
https://github.com/skitsanos/gemini-ocr
ai artificial-intelligence gemini gemini-pro llm ocr ocr-reader ocr-recognition ocr-shell parsing rag
Last synced: about 4 hours ago
JSON representation
PDF Screenshot OCR Analysis with Google Gemini Pro
- Host: GitHub
- URL: https://github.com/skitsanos/gemini-ocr
- Owner: skitsanos
- Created: 2024-05-17T09:04:40.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-06-02T23:44:49.000Z (8 months ago)
- Last Synced: 2024-11-15T09:16:15.541Z (2 months ago)
- Topics: ai, artificial-intelligence, gemini, gemini-pro, llm, ocr, ocr-reader, ocr-recognition, ocr-shell, parsing, rag
- Language: Shell
- Homepage: https://www.linkedin.com/pulse/pdf-screenshot-ocr-analysis-google-gemini-pro-evgenios-skitsanos-htapf
- Size: 975 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PDF Screenshot OCR Analysis with Google Gemini Pro
This project involves automating converting PDF document screenshots into text using Google's Gemini Pro model. The goal is to perform Optical Character Recognition (OCR) on images extracted from PDF screenshots to analyze and extract textual content.
#### Workflow Overview:
1. **Screenshot Extraction**: Images are taken from PDF documents and stored in a designated directory (`data/`).
2. **Prompt Preparation**: A text prompt is read from `prompt.txt`, which instructs the model on how to process the images.
3. Image Processing:
- The script determines the MIME type for each image in the data/ directory and encodes it in Base64.
- These encoded images and the initial user prompt are incorporated into a JSON structure.
4. **Generation Configuration**: A generation configuration is created to fine-tune the model's processing parameters, such as `topP` and `temperature`.
5. **Payload Preparation**: The JSON structure, including the images and configuration, is prepared as a payload for the API request.
6. **API Request**: The payload is sent to the Google Gemini Pro model via an API endpoint to perform OCR.
7. Response Handling
- The response, containing the extracted text and metadata, is saved to `response.json`.
- The textual content is extracted and saved to `response.txt`.#### Key Components:
- **Image Processing**: Functions to get MIME type and encode images in Base64.
- **JSON Structuring**: Using `jq` to build and modify JSON payloads.
- **API Integration**: Sending the payload to Google Gemini Pro and handling the response.#### Benefits:
- **Automation**: Streamlines the process of converting PDF screenshots to text.
- **Accuracy**: Leverages Google's advanced OCR capabilities for high-quality text extraction.
- **Flexibility**: Configurable processing parameters to optimize OCR results.This project is ideal for scenarios where automated text extraction from PDF screenshots is needed, such as digitizing documents, extracting data for analysis, or improving accessibility.