Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OCR To TXT (Ollama + GLM OCR)

Simple verbose shell pipeline to OCR images sequentially by image time.

What it does

  • Finds images in input_images (heic, webp, png, jpg, jpeg)
  • Sorts by time priority: DateTimeOriginal -> CreateDate -> FileModifyDate
  • Converts each image to jpg at 1280x720 (720p)
  • Sends each image to local Ollama model (default: glm-ocr:latest)
  • Saves per-image OCR text and combined OCR text

Files

  • ocr_to_txt.sh: main OCR script
  • create_synthetic_test_data.sh: creates 2 synthetic test images

Requirements

  • ollama running locally at http://127.0.0.1:11434
  • commands: curl, jq, exiftool, base64, convert (ImageMagick) or magick

Quick start

./create_synthetic_test_data.sh ./input_images
./ocr_to_txt.sh ./input_images ./work_jpg_720 ./ocr_output glm-ocr:latest

Output

  • Per image text: ./ocr_output/txt/*.txt
  • Combined text: ./ocr_output/all_ocr.txt

Environment options

  • OLLAMA_URL (default http://127.0.0.1:11434)
  • OCR_TIMEOUT (default 45; use 0 for no timeout)
  • OCR_NUM_PREDICT (default 128)
  • OCR_NUM_CTX (default 2048)
  • CONVERT_TIMEOUT (default 120)
  • OCR_PROMPT (custom OCR prompt)

About

Shell pipeline that OCRs folders of images via local Ollama (GLM-OCR). Time-sorted, 720p-normalized, per-image and combined output.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages