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.
- 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.
- Python 3.8 or higher.
- A Mistral AI account and an API key. You can get one from the Mistral AI Platform.
The recommended way to install the application is using pip:
pip install mistral-ocr-guiThis command will download the application and automatically install all required dependencies.
If you want to contribute to the project or install the latest development version, you can install it from the source code:
-
Clone the repository:
git clone https://github.com/Danielnara24/Mistral-OCR.git cd Mistral-OCR -
Install in editable mode: This command will install the application and its dependencies. The
-eflag allows you to make changes to the source code and have them take effect immediately.pip install -e .
The application requires your Mistral API key to be set as an environment variable named MISTRAL_API_KEY.
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"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.
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
Once installed, the application can be launched directly from your terminal. Simply run the following command:
mistral-ocrThe graphical user interface will appear, and you can start processing your images.
-
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.mdfile 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.
- Individual Images: Use this for processing a specific set of image files from different locations. Each image will generate a corresponding
-
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.
-
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.
-
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.
-
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.
- The generated markdown files (
This project is licensed under the MIT License.
