OCR

OCR x gemma3

GemmaOllamaを活用して OCR(文字認識)を行う。画像からテキストを抽出する方法。OCRを使う気はなかったが、使用例の記事を見つけたので、トライ。

OCRだけでなく、画像に写っている内容を説明させることもできる、できた。

精度については、画像の内容や記述内容に依存して、安定した結果が得られるとは言い難い。

例:OCR

  1. 画像を、ss.pngとして保存。
ollama run gemma3 "answer only. extract text from this picture ./ss.png"

ss.png

from https://en.wikipedia.org/wiki/Mac_(computer)

output

$ ollama run gemma3 "answer only. extract text from this picture ./ss.png"
Added image './ss.png'
Mac is a brand of personal computers designed and
marketed by Apple since 1984. The name is short for
Macintosh (its official name until 1999), a reference to
the McIntosh apple. The current product lineup includes
the MacBook Air and MacBook Pro laptops, and the iMac,
Mac Mini, Mac Studio, and Mac Pro desktops. Macs are
currently sold with Apple’s UNIX-based macOS operating
system, which is not licensed to other manufacturers and
exclusively bundled with Mac computers. This operating
system replaced Apple’s original Macintosh operating
system, which has variously been named System, Mac OS,
and Classic Mac OS.

$

Reference

|