Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

PDF Screenshot OCR Analysis with Google Gemini Pro

NotificationsYou must be signed in to change notification settings

skitsanos/gemini-ocr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 fromprompt.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 astopP andtemperature.
  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 toresponse.json.
    • The textual content is extracted and saved toresponse.txt.

Key Components:

  • Image Processing: Functions to get MIME type and encode images in Base64.
  • JSON Structuring: Usingjq 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.


[8]ページ先頭

©2009-2025 Movatter.jp