The problem
How it works
He pulled gemma4:e4b through Ollama and called it from a Python script on an M1 MacBook Pro with 16GB RAM to extract three fields from photographed and scanned contractor invoices, some handwritten. He compared the results with his cloud OCR service on 50 real invoice photos and added an OpenCV contrast-enhancement step.
Results and limitations
He reports 91% exact-match field accuracy locally against 94% for the cloud API, rising to 95% with preprocessing, at about 2.3 seconds per image versus 4.2 seconds in the cloud, removing a bill he puts at roughly $50 a month.
Before you try it
Small test set and thinly described scoring; the cloud service stayed ahead on difficult handwriting, and blurry or dark images can yield invented values. The post discloses AI help with its prose, and this is a scripted model call rather than an autonomous agent. No year is shown on the post date.
Tools and repositories
- Tools
- Ollama · Gemma 4 E4B · Python · OpenCV
- Prerequisites
- Needs a machine with roughly 16GB RAM and ideally GPU or Apple Silicon acceleration.
Try it yourself: Benchmark local invoice extraction before switching
Fill the fields to adapt the prompt. Empty fields stay as visible [placeholders].
Help me test whether a local model can replace my paid OCR service. Using [Local vision model] through Ollama on this machine, write a script that reads images from [Sample image folder] and extracts [Fields to extract] into JSON with a fixed schema, returning null when a field is unreadable instead of guessing. Compare the output with [Hand-labeled answers] and report exact-match accuracy per field, average seconds per image, and the ten worst errors. Then try one image preprocessing step and report the difference. Work on copies only, never move or rename the originals, and do not send any image to an external service.Hand-label a representative sample first and keep a human check on amounts before anything reaches your books.
Related videos
About ollama/ollama
Learn Ollama in 15 Minutes - Run LLM Models Locally for FREE (opens in a new tab)
The description links the GitHub repository.
Watch on YouTube (opens in a new tab)Independent creators. Listing a video implies no endorsement, sponsorship or partnership.
Sources
- I Replaced a $50/Month OCR API with Gemma 4's Native Vision (And You Can Too) (opens in a new tab)
First-person account · dev.to · Undated · Source checked 9 Nov 2026, 22:24 UTC
What this source supports
- gemma4:e4b run through Ollama from Python on an M1 MacBook Pro
- 50 real contractor invoice photos tested
- 91% local vs 94% cloud field accuracy; 95% with CLAHE preprocessing
- About 2.3 s per image locally vs 4.2 s cloud; roughly $50/month saved
