MLX Nougat
MLX Nougat is a CLI tool for OCR using the Nougat model.
Installation
-
Install ImageMagick:
brew install imagemagick
-
Configure environment variables for ImageMagick:
Add the following lines to your shell configuration file (e.g., ~/.bashrc, ~/.zshrc):
export MAGICK_HOME=$(brew --prefix imagemagick) export PATH=$MAGICK_HOME/bin:$PATH export DYLD_LIBRARY_PATH=$MAGICK_HOME/lib:$DYLD_LIBRARY_PATH
After adding these lines, reload your shell configuration or restart your terminal.
-
Install MLX Nougat:
git clone git@github.com:mzbac/mlx-nougat.git cd mlx-nougat pip install .
Usage
After installation, you can use MLX Nougat from the command line:
mlx_nougat --input <path_to_image_or_pdf_or_url> [--output <output_file>] [--model <model_name_or_path>]
Arguments
--input: (Required) Path to the input image or PDF file, or a URL to an image or PDF.--output: (Optional) Path to save the output text file. If not provided, the output will be printed to the console.--model: (Optional) Name or path of the Nougat model to use. Default is "facebook/nougat-small".
Examples
-
Process a local image:
mlx_nougat --input path/to/your/image.png --output results.txt
-
Process a local PDF:
mlx_nougat --input path/to/your/document.pdf --output results.txt
-
Process a remote image:
mlx_nougat --input https://example.com/image.jpg --output results.txt
-
Process a remote PDF:
mlx_nougat --input https://example.com/document.pdf --output results.txt
-
Use a different model:
mlx_nougat --input path/to/your/image.png --model facebook/nougat-base --output results.txt
-
Use a quantized model:
mlx_nougat --input path/to/your/document.pdf --model mzbac/nougat-small-8bit-mlx
TODOs
- Support quantized model to improve the performance.
Acknowledgements
This project is built upon several open-source projects and research works:
- Nougat: The original Nougat model developed by Facebook AI Research.
- faster-nougat: An optimized implementation of Nougat, which inspired this MLX-based version.
- MLX: The machine learning framework developed by Apple, used for efficient model inference in this project.
- Transformers: Hugging Face's state-of-the-art natural language processing library.
Metadata
Release files for mlx-nougat 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mlx_nougat-0.1.2.tar.gz | 14.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mlx_nougat-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.6 kB
Release files / mlx_nougat-0.1.2.tar.gz
| Download URL | mlx_nougat-0.1.2.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4bdb02f05c8569725c2953ff659164a0bfc39685ca66951676d25927441ac33e
|
|
BLAKE2b-256 checksum How to use checksums |
b075ed31c1e8d958dc4e729db3fd4bce80df3af1c9c740318292b678a4eb4f7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / mlx_nougat-0.1.2-py3-none-any.whl
| Download URL | mlx_nougat-0.1.2-py3-none-any.whl |
|---|---|
| Size | 15.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ba15588cc98919ef35ab23945741a9824d870a7a54c76c3696c21ed0952acfb
|
|
BLAKE2b-256 checksum How to use checksums |
5d1c64877ad294120426975f0ad4722271df53db7490b99179df088e5c4e6c1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|