Skip to main content

A graphical user interface for processing images with the Mistral OCR API.

Project description

Mistral OCR GUI Processor

A user-friendly desktop application, built with Python and Tkinter, to perform Optical Character Recognition (OCR) on images using the powerful Mistral AI API. The tool provides a simple interface to process individual images, entire folders, or nested subfolders, and can combine the extracted text into organized markdown files.

Features

  • Intuitive Graphical User Interface: A clean, tabbed interface for different processing modes.
  • Multiple Processing Modes:
    • Individual Images: Process one or more specific image files.
    • Folder Processing: Process all supported images within a single folder.
    • Subfolder Processing: Process all supported images within the immediate subdirectories of a parent folder.
  • Drag-and-Drop Support: Easily add files or folders by dragging them onto the application window.
  • Markdown Combination: Automatically combine OCR results from multiple images into a single, well-structured markdown file.
  • Flexible Sorting Options: When combining files, sort them by natural filename order or by modification date.
  • Real-time Progress Visualization: A grid of squares visually represents the status of each image (Processing, Completed, Error).
  • Cancellable Operations: Stop a long-running processing job at any time.
  • Concurrent Processing: Uses a thread pool to process multiple images in parallel, speeding up large jobs.

Requirements

  • Python 3.8 or higher.
  • A Mistral AI account and an API key. You can get one from the Mistral AI Platform.

Installation

You can install the package directly from the source code.

  1. Clone the repository:

    git clone https://github.com/Danielnara24/Mistral-OCR.git
    cd Mistral-OCR
    
  2. Install the package using pip: This command will install the application and all its dependencies (mistralai, tkinterdnd2).

    pip install .
    

    (For development, you can use pip install -e . to install in editable mode.)

Configuration: Setting the API Key

The application requires your Mistral API key to be set as an environment variable named MISTRAL_API_KEY.

Windows

Open Command Prompt or PowerShell and run the following command to set the variable permanently. You will need to restart your terminal for the change to take effect.

setx MISTRAL_API_KEY "your_api_key_here"

macOS / Linux

Add the following line to your shell's configuration file (e.g., ~/.bashrc, ~/.zshrc, or ~/.profile):

export MISTRAL_API_KEY="your_api_key_here"

Then, either restart your terminal or run source ~/.bashrc (or the relevant file) to apply the changes.

Verify the Setup

You can verify that the environment variable is set correctly by running:

  • (macOS/Linux): echo $MISTRAL_API_KEY
  • (Windows CMD): echo %MISTRAL_API_KEY%
  • (Windows PowerShell): echo $env:MISTRAL_API_KEY

Usage

Once installed, the application can be launched directly from your terminal. Simply run the following command:

mistral-ocr

The graphical user interface will appear, and you can start processing your images.

How It Works

  1. Select a Tab:

    • Individual Images: Use this for processing a specific set of image files from different locations. Each image will generate a corresponding _OCR.md file in its original directory.
    • Folder: Use this to process all images inside a single folder. You have the option to combine all the results into one markdown file named Combined_OCR_[FolderName].md.
    • Subfolders: Use this to process images located in the immediate subfolders of a parent directory. You can combine results for each subfolder individually and even create a final compilation of all subfolder results.
  2. Add Files/Folders:

    • Click the "Select..." button to open a file/folder dialog.
    • Or, drag and drop your files/folders directly onto the application window.
  3. Configure Settings (if applicable):

    • For Folder and Subfolder modes, check the box to enable combining markdown files.
    • Choose a sorting method for the combined document.
  4. Process:

    • Click the "Process" button to start the OCR job.
    • The progress grid will update in real-time, showing the status of each file.
    • A timer will show the elapsed time.
  5. Output:

    • The generated markdown files (.md) will be saved in the same directory as the source images or in the relevant parent/subfolder directory for combined files.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mistral_ocr_gui-0.2.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mistral_ocr_gui-0.2.1-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file mistral_ocr_gui-0.2.1.tar.gz.

File metadata

  • Download URL: mistral_ocr_gui-0.2.1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for mistral_ocr_gui-0.2.1.tar.gz
Algorithm Hash digest
SHA256 87947ecf3c1d8236ff13134db383320d938c4e22f6d7b6196df7f34e41eb8e71
MD5 813f1990060583d5cd51b9e6d379f4cc
BLAKE2b-256 b9cd6e67e78d68eaf67f0f3b19e20ab66180798cc6db8ed661e86a522f5f8ddb

See more details on using hashes here.

File details

Details for the file mistral_ocr_gui-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mistral_ocr_gui-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 44938ccf9d7e9c3b49edb18af00ae64c5db507ab585d2fb6e2addd59309d8581
MD5 3141faddb6c6e07635ee99dfe03cd7d5
BLAKE2b-256 fd06d68f3407189ff3d75c6bf94d382e149c2a40f1f1af3d30c0f55842cd4ae0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page