Skip to main content

Nougat OCR CLI

CI PyPI version Python 3.11 License: MIT

A command-line tool for OCR processing using Meta's Nougat model. Extract text from PDFs with GPU acceleration (CUDA and Apple Metal).

Installation

Requires Python 3.11 and a GPU (recommended).

pip install nougat-ocr-cli

Or from source:

git clone https://github.com/r-uben/nougat-ocr-cli.git
cd nougat-ocr-cli
uv sync

Quick start

# Process a single file
nougat-ocr paper.pdf

# Process a directory
nougat-ocr ./papers/ -o ./results/

# Preview what would be processed (no model loading)
nougat-ocr ./papers/ --dry-run

# Process specific pages (zero-indexed)
nougat-ocr paper.pdf --pages 0-5

# Use CPU instead of GPU
nougat-ocr paper.pdf --device cpu

Options

Usage: nougat-ocr [OPTIONS] INPUT_PATH

Options:
  -o, --output-dir PATH           Output directory (default: <input_dir>/nougat_ocr_output/)
  --model TEXT                    Nougat model tag (default: 0.1.0-base)
  --batch-size N                  Batch size for inference (auto-detected if not set)
  --full-precision                Use FP32 instead of BF16 (slower but more accurate)
  --pages TEXT                    Page range (e.g., '0-5' or '1,3,5')
  --device [auto|cuda|mps|cpu]    Device for inference (default: auto)

  --reprocess                     Reprocess already-processed files
  --dry-run                       List files without loading the model
  -q, --quiet                     Suppress all output except errors
  -v, --verbose                   Enable verbose/debug output
  --info                          Show device and system info
  --version                       Show version
  --help                          Show this message

Output structure

nougat_ocr_output/
├── document_name/
│   └── document_name.md        # OCR markdown (clean text only)
├── another_document/
│   └── ...
└── metadata.json               # processing stats, checksums, file list

Device selection

Nougat auto-detects the best available device:

  1. CUDA — NVIDIA GPUs (fastest)
  2. MPS — Apple Metal on M-series Macs
  3. CPU — fallback (slow, not recommended for large documents)

Override with --device cuda|mps|cpu.

Development

# Install dev dependencies
uv sync --extra dev

# Run tests
uv run pytest

# Lint
uv run ruff check .

# Format
uv run ruff format .

# Type check
uv run mypy nougat_ocr/ --ignore-missing-imports

Limitations

  • Python 3.11 only (nougat-ocr dependency constraint)
  • Model weights: ~1.3 GB (auto-downloaded on first run)
  • GPU strongly recommended for reasonable performance
  • Supported formats: PDF, JPG, JPEG, PNG, WEBP, BMP, TIFF

License

MIT License - see LICENSE for details.

Metadata

Release files for nougat-ocr-cli 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nougat-ocr-cli 0.3.0
File Size Uploaded Provenance
nougat_ocr_cli-0.3.0.tar.gz 114.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for nougat-ocr-cli 0.3.0
File Interpreter ABI Platform
nougat_ocr_cli-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 128.5 kB

Release files / nougat_ocr_cli-0.3.0.tar.gz

Download URL nougat_ocr_cli-0.3.0.tar.gz
Size 114.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b305d2d5fdb8c69a04a2eee1597e4d1d27f87afb48b58880aa3ff89444376f1b
BLAKE2b-256 checksum
How to use checksums
9d17b010e07b16f78e9be5399154b3c2635f72dad335de32636745c08327cf18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / nougat_ocr_cli-0.3.0-py3-none-any.whl

Download URL nougat_ocr_cli-0.3.0-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd5ea678af7bb44b5af8a70ea9cc6c5d1a108606794a67b6a80578bf2eecab22
BLAKE2b-256 checksum
How to use checksums
7421d450a2d093073ba4bdb4222bcaba94bf6d6c9561f7b5dd8ed3c0aaee9ee8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for nougat-ocr-cli 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page