Media ocr ai

From damionrashford/media-os · View interactive version

Media ocr ai is an AI agent skill from the GitHub repository damionrashford/media-os. Modern AI OCR with open-source + commercial-safe models: PaddleOCR (Apache 2.0, Baidu, 80+ languages, layout analysis, tables), EasyOCR (Apache 2.0, JaidedAI, 80+ languages, easiest install), Tesseract 5 (Apache 2.0, mature LSTM backend, 100+ languages), TrOCR (MIT, Microsoft transformer, the only o

How to use this skill

Skill file

Media OCR AI

Context: $ARGUMENTS

Modern open-source OCR. Goes far beyond plain Tesseract by giving four models for four different jobs: PaddleOCR for layout + tables, EasyOCR for "just read the text", Tesseract for the widest language set, TrOCR for handwriting.

For the in-ffmpeg ocr= filter (Tesseract inside a filtergraph, good for logo detection / rough live text), use ffmpeg-ocr-logo. This skill is for offline, high-accuracy, structured OCR — document processing, not video frame grabs.

Quick start

When to use

Step 1 — Pick a backend

| Model | License | Strengths | Install difficulty | When to pick |

|---------------|------------|-----------------------------------------------------------------|--------------------|---------------------------------------------------|

| PaddleOCR | Apache 2.0 | Best layout analysis + table extraction, 80+ languages | medium (paddlepaddle) | Structured documents, receipts, invoices, tables |

| EasyOCR | Apache 2.0 | Easiest install, good general quality, 80+ languages | easy | "Just read this image" |

| Tesseract 5 | Apache 2.0 | Widest language support (100+), battle-tested, pure CLI | easiest (system pkg) | Legacy, CPU-only, obscure scripts |

| TrOCR | MIT | Transformer trained on IAM handwriting; best cursive by far | medium (transformers) | Handwritten notes, cursive, stylized fonts |

Pairing advice:

Full per-model strengths, install quirks, and language-matrix in references/languages.md.

Step 2 — Install the backend(s)

PEP 723 header in scripts/ocr.py lists all dependencies. Run via uv run once to populate the ephemeral venv. The one-shot installer:

uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py install paddle
uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py install easy
uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py install tesseract
uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py install trocr

Per-backend notes:

Step 3 — Extract text (any language, any backend)

uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py extract \
  --model easy --in photo.jpg --out-format text > photo.txt

Output formats:

--lang sets the detection / recognition language hint (e.g. --lang en or --lang ja). Without it, backends fall back to their default (usually English).

Step 4 — Layout analysis (PaddleOCR only)

Structured layout — headers, paragraphs, lists, tables, figures — is PaddleOCR's flagship capability via PP-StructureV2:

uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py layout \
  --model paddle --in scanned_page.png --out-json layout.json

Output JSON has regions, each with type in {"title", "text", "list", "table", "figure", "figure_caption", "table_caption", "header", "footer", "reference", "equation"}, plus bbox and either text (text regions) or html (table regions, full cell structure).

For a multi-page scanned PDF, loop per page:

# split pages via ImageMagick (media-imagemagick skill)
magick in.pdf page_%03d.png
for p in page_*.png; do
  uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py layout --model paddle --in "$p" --out-json "${p%.png}.json"
done

Step 5 — Handwriting (TrOCR)

uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py handwriting \
  --model trocr --in handwritten.jpg --out note.txt

TrOCR is a line-level recognizer. If the image has multiple lines, pre-segment with PaddleOCR's detection head and then run TrOCR on each line crop (the script's handwriting subcommand does this automatically when --detect paddle is passed).

Variants:

Select with --variant base-handwritten (or similar).

Step 6 — Multilingual documents

uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py multi-lang \
  --model paddle --langs en,ja,zh --in doc.png --out-json ocr.json

PaddleOCR supports concurrent mixed languages by loading a multilingual recognizer. EasyOCR accepts multiple --languages as a list on init. Tesseract takes -l eng+jpn+chi_sim.

See references/languages.md for the supported-language matrix per backend. Some languages are paddle-only (e.g. Sanskrit, Thai), some are tesseract-only (older scripts, a long tail).

Step 7 — Table extraction as CSV

uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py table \
  --model paddle --in invoice.png --out-csv invoice.csv

Uses PaddleOCR's PP-Structure table engine. Each detected table becomes a <table>-parsed CSV. Multi-table pages produce one CSV per detected table: invoice.csv, invoice_table1.csv, etc.

For complex bordered / borderless tables, PaddleOCR beats the other three backends by a wide margin — only it ships a trained table-structure-recognition model (SLANet).

Available scripts

Reference docs

Gotchas

Examples

Example 1 — Plain text extraction (EasyOCR, easiest path)

uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py extract \
  --model easy --in receipt.jpg --lang en --out-format text > receipt.txt

Example 2 — Structured receipt parsing with layout + table detection

uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py layout \
  --model paddle --in receipt.jpg --out-json receipt.json
# receipt.json has regions with types {"title","text","table","figure"}
# for the table region, html field contains the cell-accurate markup

Example 3 — Transcribe handwritten notes

uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py handwriting \
  --model trocr --variant base-handwritten \
  --detect paddle --in notebook_page.jpg --out notebook.txt

Example 4 — Japanese menu photo

uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py extract \
  --model paddle --lang japan --in menu.jpg --out-format json > menu.json

Example 5 — Invoice table to CSV

uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py table \
  --model paddle --in invoice.png --out-csv invoice.csv

Example 6 — Batch folder with GNU parallel

Hand off to media-batch:

ls scans/*.png | parallel --jobs 4 \
  uv run ${CLAUDE_SKILL_DIR}/scripts/ocr.py extract \
    --model easy --in {} --out-format text > out/{/.}.txt

Troubleshooting

`ImportError: No module named 'paddle'` (or `paddlepaddle`)

Cause: PaddleOCR imported without the backend installed.

Solution: pip install paddlepaddle>=2.6 paddleocr (CPU). For CUDA, pip install paddlepaddle-gpu. Or run via uv run which handles the PEP 723 deps automatically.

EasyOCR hangs on first run

Cause: Downloading the craft detector + recognizer models. Can take minutes over slow links.

Solution: Wait, or pre-warm with uv run ocr.py install easy --lang en. Once cached in ~/.EasyOCR/, subsequent runs are instant.

Tesseract returns gibberish for Chinese / Japanese / Arabic

Cause: Missing .traineddata. Tesseract defaults to English and silently mis-recognizes.

Solution: brew install tesseract-lang (macOS) or apt install tesseract-ocr-jpn tesseract-ocr-chi-sim tesseract-ocr-ara (Debian). Verify: tesseract --list-langs.

TrOCR output is "?????" or random

Cause: Fed a full page to a line-level model, or mismatched variant (printed model on handwriting).

Solution: Run with --detect paddle to auto-segment lines, or use a correct variant (-handwritten vs -printed).

`cv2.error` opening a PDF

Cause: OpenCV doesn't read PDFs directly.

Solution: Rasterize first: magick in.pdf -density 300 page_%03d.png (see media-imagemagick), then OCR each PNG.

RTL (Arabic/Hebrew) output is visually reversed

Cause: Some backends output text in visual order (as it appears left-to-right on screen) rather than logical order.

Solution: pip install python-bidi && python -c "from bidi.algorithm import get_display; print(get_display(open('out.txt').read()))".

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.