最強のローカルOCR?Ollama + GLM-OCRで爆速・高精度な文字認識を試す

GLM-OCR

GLM-OCRは、強力なマルチモーダル基盤モデル(ChatGLMシリーズなど)をベースに開発された、画像内のテキスト認識と構造化に特化したモデルです。

従来のOCRとは異なり、高度な言語理解能力を併せ持っているため、手書き文字や複雑なレイアウトの解析、さらには読み取った内容の要約やデータ抽出までをシームレスに実行できるのが最大の特徴です。

Ollama

Ollamaは、Llama 3やMistral、Gemmaなどの強力なオープンソースの大規模言語モデル(LLM)を、ローカル環境で手軽に実行・管理できるツールです。

複雑な環境構築を必要とせず、コマンド一つでモデルのダウンロードから推論サーバーの起動まで完結するため、セキュリティやプライバシーを保ちつつAIを自前で活用したいエンジニアに広く支持されています。

2026年2月6日にGLM-OCRに対応しました。そのため、簡単にOCRを実行できるようになりました。

Ollamaインストール

Ollamaのインストール方法については下記を参照してください

モデルのダウンロード

モデルのダウンロードは以下のコマンドで実行できます

ollama run glm-ocr

実行結果

実行方法

下記のコマンドで「画像ファイル名」のところにOCRしたい画像ファイルを指定します。

ollama run glm-ocr Text Recognition: 画像ファイル名

実行例

サンプルで以下の画像をOCRにかけます

以下のコマンドで実行します

ollama run glm-ocr Text Recognition: ./000025364_page137.png

実行結果

以下は実行結果です。ほぼほぼ完璧ではないでしょうか。かなりの精度で文字起こしができていると思います

$ ollama run glm-ocr Text Recognition: ./000025364_page137.png
Added image './000025364_page137.png'
付録B—略語

『侵入検知および侵入防止システム(IDPS)に関するガイド』で使用している略語について、その一部の定義を以下に示す。

AP Access Point(アクセスポイント)
ARP Address Resolution Protocol(アドレス解決プロトコル)

CAIDA Cooperative Association for Internet Data Analysis(インターネットデータ解析協会)
CIAC Computer Incident Advisory Capability(コンピュータインシデント情報勧告機関)
CLI Command-Line Interface(コマンドラインインタフェース)
CMVP Cryptographic Module Validation Program(暗号化モジュール有効性確認プログラム)
COM Component Object Model(コンポーネントオブジェクトモデル)
CPU Central Processing Unit(中央処理装置)
CSIRT Computer Security Incident Response Team(コンピュータセキュリティインデント対応チーム)
CSRC Computer Security Resource Center(コンピュータセキュリティリソースセンター)
CSV Comma Separated Values(カンマ区切りデータ形式)
CVE Common Vulnerabilities and Exposures(一般的な脆弱性と暴露性)

DDoS Distributed Denial of Service(分散型サービス妨害)
DHCP Dynamic Host Configuration Protocol(動的ホスト設定プロトコル)
DLL Dynamic Link Library(ダイナミックリンクライブラリ)
DMZ Demilitarized Zone(非武装地带)
DNS Domain Name System(ドメインネームシステム)
DoS Denial of Service(サービス妨害)
DS Distribution System(ディストリビューションシステム)
DShield Distributed Intrusion Detection System(分散化侵入検知システム)

EICAR European Institute for Computer Antivirus Research(欧州コンピュータウイルス対策研究所)
ESP Encapsulating Security Payload(暗号ペイロード)

FIPS Federal Information Processing Standards(連邦情報処理規格)
FISMA Federal Information Security Management Act(連邦情報セキュリティマネジメント法)
FTP File Transfer Protocol(ファイル転送プロトコル)

GHz Gigahertz(ギガヘルツ)
GUI Graphical User Interface(グラフィカルユーザインタフェース)

HTTP Hypertext Transfer Protocol(ハイパーテキスト転送プロトコル)
HTTPS Hypertext Transfer Protocol over SSL(SSL経由のハイパーテキスト転送プロトコル)

ICMP Internet Control Message Protocol(インターネット制御通知プロトコル)
IDPS Intrusion Detection and Prevention System(侵入検知および侵入防止システム)
IDS Intrusion Detection System(侵入検知システム)

実行結果②

以下のような表形式の画像も確認してみます

正しく表形式のデータもテキスト化されており、URLも正しく表現されています。

資料名 URL
ホストベースの IDPSに関するリソース
Host-Based IDS vs Network-Based IDS http://www.windowsecurity.com/articles/Hids_vs_Nids_Part1.html
Host-Based IDSs Add to Security Policy http://www.networkworld.com/news/tech/2003/0915techupdate.html
Host-Based Intrusion Detection System Definition 
http://en.wikipedia.org/wiki/Host-based_intrusion_detection_system
Host-Based Intrusion Detection Systems http://staff.science.uva.nl/~delaat/snb-2004-2005/p19/report.pdf
What Is Host-Based Intrusion Detection? http://www.sans.org/resources/idfaq/host_based.php

メーリングリストと通知サービス
メーリングリスト/通知サービス名 URL
Incidents 

securityfocus.com
Forsale Lander
Security Focus http://www.securityfocus.com/ids SecurityTracker.com http://securitytracker.com/ その他の技術資料文書 資料名 URL IETF, RFC 2267, Network Ingress Filtering: Defeating Denial of Service Attacks Which Employ IP Source Address Spoofing http://www.ietf.org/rfc/rfc2267.txt NIST, SP 500-267, A Profile for IPv6 in the U.S. Government, Version 1.0 (DRAFT) http://www.antd.nist.gov/ NIST, SP 800-31, Intrusion Detection Systems http://csrc.nist.gov/publications/nistpubs/ NIST, SP 800-42, Guideline on Network Security Testing http://csrc.nist.gov/publications/nistpubs/ NIST, SP 800-51, Use of the Common Vulnerabilities and Exposures (CVE) Vulnerability Naming Scheme
Search | CSRC
NIST, SP 800-53, Recommended Security Controls for Federal Information Systems
Search | CSRC
NIST, SP 800-61, Computer Security Incident Handling Guide http://csrc.nist.gov/publications/nistpubs/ NIST, SP 800-70, Security Configuration Checklists Program for IT Products http://csrc.nist.gov/checklists/ NIST, SP 800-83, Guide to Malware Incident Prevention and Handling http://csrc.nist.gov/publications/nistpubs/ NIST, SP 800-86, Guide to Integrating Forensic Techniques into Incident Response
Search | CSRC
NIST, SP 800-88, Guidelines for Media Sanitization http://csrc.nist.gov/publications/nistpubs/ NIST, SP 800-92, Guide to Computer Security Log Management http://csrc.nist.gov/publications/nistpubs/ NIST, SP 800-97, Establishing Wireless Robust Security Networks: A Guide to IEEE 802.11i
Search | CSRC

PDFから画像に変換

PDFファイルは直接読み込めないため画像に変換する必要があります

画像に変換する場合以下のサイトが便利です

PDFファイルをドラッグ&ドロップすると自動的に画像に変換してくれます

PDF を PNG(画像) 変換 | 無料オンラインツール - 完全プライバシー保護
PDFファイルを高品質なPNG画像に無料で変換。サーバーへのアップロード不要、ブラウザ上で完全処理。機密文書も安心して変換できます。

コメント

タイトルとURLをコピーしました