フッターコンテンツにスキップ
OCRツール

請求書OCR機械学習(ステップバイステップチュートリアル)

今日の急速に進化するビジネス環境では、タスクを自動化し非構造化データを処理することが、効率向上と手動エラー低減のための重要な戦略となっています。 そのようなタスクの1つが、請求書や購買注文書から情報を抽出するプロセスです。これは伝統的に多大な手作業を要しました。 しかし、機械学習や深層学習モデル、そして光学文字認識(OCR)ソフトウェア技術の進歩のおかげで、企業はIronOCRのようなツールを使用してこの請求書情報抽出プロセスを効率化することができます。 この記事では、機械学習とIronOCRを活用して請求書処理をどのように変革するかを探ります。

請求書OCRツールの理解

OCR技術は以前から存在していますが、請求書処理とデータ抽出への応用は、機械学習の登場により大きなブーストを受けました。 OCRは光学文字認識の略で、スキャンした請求書情報を含む紙文書やPDFファイル、財務書類、デジタルカメラで撮影された画像を、編集可能かつ検索可能なデータに変換する技術です。 これは、事前画像処理を使用して画像のテキストを機械可読テキストに翻訳します。

IronOCRは、機械学習アルゴリズムの上に構築された強力なOCRライブラリで、さまざまなアプリケーションやプログラミング言語に統合可能であり、請求書処理において多用途なツールとなります。 IronOCRを使用することで、企業は請求書番号、日付、ベンダーの詳細、明細などの請求書データ抽出を自動化し、remarkableな精度を実現できます。

請求書OCRにIronOCRを使用する利点

IronOCRを請求書処理に使用することには多くの利点があり、組織の財務運営、特に買掛金処理の効率と精度を大幅に向上させる可能性があります。 これらの利点を詳しく見ていきましょう:

1. 精度とエラー削減

IronOCRは高度な機械学習アルゴリズムを使用して、請求書からテキストを正確に認識し抽出します。 これにより、データ入力の際の人為的エラーの可能性が最小限に抑えられ、重要な財務情報が正しく記録されます。

2. 時間とコストの節約

IronOCRを使用して請求書処理を自動化することで、手動データ入力に必要な時間とリソースを大幅に削減できます。 これにより、スタッフの時間を最適化し、手動労働の必要性を削減することで、実質的なコスト削減につながります。

3. 効率の向上

IronOCRは大量の請求書を迅速かつ効率的に処理できます。 従業員が各請求書からデータを手動で入力する必要がなくなり、より戦略的なタスクに焦点を当てることができます。

4. スケーラビリティ

IronOCRはスケーラブルで、ビジネスが拡大するにつれて増加する請求書の量を処理できます。 ワークロードの増加や請求書文書処理システムを圧倒することを心配する必要はありません。

5. グローバル対応

IronOCRは125以上の言語をサポートしており、世界中のベンダーやクライアントの請求書を処理することができます。 請求書がどの言語で書かれているかに関係なく、IronOCRはデータを正確に抽出できます。

6. マルチフォーマット対応

IronOCRはスキャン画像、画像ベースのPDF、テキストベースのPDFを含むさまざまな形式の請求書を処理できます。 この多様性により、さまざまなソースや形式からの請求書を容易に処理することができます。

7. カスタマイズとデータ抽出

IronOCRをカスタマイズして、請求書番号や日付、ベンダーの詳細、明細情報など、特定のデータフィールドを抽出することができます。 このレベルのカスタマイズにより、特定のビジネスニーズに合わせてソリューションを調整できます。

8. コンプライアンスと監査証跡

IronOCRによる自動化された請求書処理は正確な記録を維持し、監査証跡を提供します。 これは、財務規制の遵守に不可欠であり、監査プロセスを簡素化します。

9. 請求書処理サイクルの短縮

IronOCRの合理化された自動化の性質により、請求書の処理にかかる時間が短縮され、それに伴い請求書処理サイクルが短縮されます。 これにより、ベンダーへの支払いが迅速化され、関係が改善される可能性があります。

10. データ分析の強化

構造化されたデジタル形式で請求書データを持つことで、より深いデータ分析を実行できます。 これにより、トレンドを識別し、支出を最適化し、情報に基づいた財務決定を行うのに役立ちます。

請求書処理におけるIronOCRの実装

請求書処理のためにIronOCRを実装するには、以下の一般的な手順に従います:

ステップ1: 新しいC# プロジェクトを作成する

まず、Visual StudioやVisual Studio Codeなどの好みの開発環境で新しいC#プロジェクトを作成するか、既存のプロジェクトを開きます。 このデモンストレーションには、Visual Studio 2022のIDEとコンソールアプリケーションを使用しています。 ASP.NET Web API、ASP.NET MVC、ASP.NET Webフォーム、または任意の.NET Frameworkなど、同じ実装を他のプロジェクトタイプで使用できます。

請求書OCR機械学習(ステップバイステップチュートリアル):図1 - C#プロジェクト

ステップ2: NuGetパッケージマネージャーを介してIronOCRをインストールする

プロジェクトでIronOCRを使用するには、IronOCR NuGetパッケージをインストールする必要があります。 手順は次のとおりです:

  1. NuGetパッケージマネージャーコンソールを開きます。 Visual Studioでは、"ツール">"NuGetパッケージマネージャー">"パッケージマネージャーコンソール"で見つけることができます。

請求書OCR機械学習(ステップバイステップチュートリアル):図2 - パッケージマネージャーコンソール

  1. 次のコマンドを実行してIronOCRパッケージをインストールします:

    Install-Package IronOcr

    請求書OCR機械学習(ステップバイステップチュートリアル):図3 - IronOCRインストール

  2. パッケージのインストールを待ちます。 完了したら、IronOCRをプロジェクトで使用できます。

ステップ3: C#でOCRを実装する

それでは、IronOCRを使用して請求書でOCRを実行するC#コードを書きましょう。 この例では、以下のサンプル請求書を使用します。

請求書OCR機械学習(ステップバイステップチュートリアル):図4 - サンプル請求書テンプレート

以下のサンプルコードは、請求書画像を入力として受け取り、請求書番号や購買注文などのデータを請求書から抽出します。

// Define the path to the invoice image
string invoicePath = @"D:\Invoices\SampleInvoice.png";

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Add the invoice image to the OCR input
    input.AddImage(invoicePath);

    // Perform OCR on the input image and store result
    OcrResult result = ocr.Read(input);

    // Output the extracted text from the image to the console
    Console.WriteLine(result.Text);
}
// Define the path to the invoice image
string invoicePath = @"D:\Invoices\SampleInvoice.png";

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Add the invoice image to the OCR input
    input.AddImage(invoicePath);

    // Perform OCR on the input image and store result
    OcrResult result = ocr.Read(input);

    // Output the extracted text from the image to the console
    Console.WriteLine(result.Text);
}
' Define the path to the invoice image
Dim invoicePath As String = "D:\Invoices\SampleInvoice.png"

' Create an instance of IronTesseract for OCR processing
Dim ocr As New IronTesseract()

' Use 'using' to ensure proper disposal of OcrInput resources
Using input As New OcrInput()
	' Add the invoice image to the OCR input
	input.AddImage(invoicePath)

	' Perform OCR on the input image and store result
	Dim result As OcrResult = ocr.Read(input)

	' Output the extracted text from the image to the console
	Console.WriteLine(result.Text)
End Using
$vbLabelText   $csharpLabel

上記のコードは、単一の請求書画像(SampleInvoice.png)でOCRを実行し、抽出された請求書データをコンソールに表示する、IronOCRを使用した簡潔なC#の例です。 必ずinvoicePath変数を特定の請求書画像ファイルパスに置き換えてください。

請求書OCR機械学習(ステップバイステップチュートリアル):図5 - 請求書OCR出力

複数の請求書を一度に入力し、そのデータを抽出してみましょう。 以下は入力に使用している請求書ディレクトリです。

請求書OCR機械学習(ステップバイステップチュートリアル):図6 - 請求書ディレクトリ

以下のサンプルコードは、複数の請求書から一度にテキストを抽出します。

// Get all PNG files from the specified directory
string[] fileArray = Directory.GetFiles(@"D:\Invoices\", "*.png");

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Loop through each file and add it to the OCR input
    foreach (string file in fileArray)
    {
        input.AddImage(file);
    }

    // Perform OCR on all the added images and store the result
    OcrResult result = ocr.Read(input);

    // Output the extracted text from all images to the console
    Console.WriteLine(result.Text);
}
// Get all PNG files from the specified directory
string[] fileArray = Directory.GetFiles(@"D:\Invoices\", "*.png");

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Loop through each file and add it to the OCR input
    foreach (string file in fileArray)
    {
        input.AddImage(file);
    }

    // Perform OCR on all the added images and store the result
    OcrResult result = ocr.Read(input);

    // Output the extracted text from all images to the console
    Console.WriteLine(result.Text);
}
' Get all PNG files from the specified directory
Dim fileArray() As String = Directory.GetFiles("D:\Invoices\", "*.png")

' Create an instance of IronTesseract for OCR processing
Dim ocr As New IronTesseract()

' Use 'using' to ensure proper disposal of OcrInput resources
Using input As New OcrInput()
	' Loop through each file and add it to the OCR input
	For Each file As String In fileArray
		input.AddImage(file)
	Next file

	' Perform OCR on all the added images and store the result
	Dim result As OcrResult = ocr.Read(input)

	' Output the extracted text from all images to the console
	Console.WriteLine(result.Text)
End Using
$vbLabelText   $csharpLabel

上記のコードはフォルダからすべてのPNG画像を取得し、データを抽出して、フォルダ内のすべての請求書の抽出データをコンソールに表示します。

請求書OCR機械学習(ステップバイステップチュートリアル):図7 - 抽出データ

抽出データを検索可能なPDF請求書として保存する

以下のコードは、フォルダからすべての画像を読み取り、データを抽出し、単一の検索可能なPDF請求書として保存します。

// Get all PNG files from the specified directory
string[] fileArray = Directory.GetFiles(@"D:\Invoices\", "*.png");

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Loop through each file and add it to the OCR input
    foreach (string file in fileArray)
    {
        input.AddImage(file);
    }

    // Perform OCR on all the added images and store the result
    OcrResult result = ocr.Read(input);

    // Save the result as a searchable PDF
    result.SaveAsSearchablePdf(@"D:\Invoices\Searchable.pdf");
}
// Get all PNG files from the specified directory
string[] fileArray = Directory.GetFiles(@"D:\Invoices\", "*.png");

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Loop through each file and add it to the OCR input
    foreach (string file in fileArray)
    {
        input.AddImage(file);
    }

    // Perform OCR on all the added images and store the result
    OcrResult result = ocr.Read(input);

    // Save the result as a searchable PDF
    result.SaveAsSearchablePdf(@"D:\Invoices\Searchable.pdf");
}
' Get all PNG files from the specified directory
Dim fileArray() As String = Directory.GetFiles("D:\Invoices\", "*.png")

' Create an instance of IronTesseract for OCR processing
Dim ocr As New IronTesseract()

' Use 'using' to ensure proper disposal of OcrInput resources
Using input As New OcrInput()
	' Loop through each file and add it to the OCR input
	For Each file As String In fileArray
		input.AddImage(file)
	Next file

	' Perform OCR on all the added images and store the result
	Dim result As OcrResult = ocr.Read(input)

	' Save the result as a searchable PDF
	result.SaveAsSearchablePdf("D:\Invoices\Searchable.pdf")
End Using
$vbLabelText   $csharpLabel

例のコードはほとんど同じですが、 ただし、異なるユースケースを示すためにわずかに変更しています。 出力PDFは以下に示されています:

請求書OCR機械学習(ステップバイステップチュートリアル):図8 - PDF出力

このように、IronPDFは請求書処理と文書処理の自動化を最も簡単に行う方法を提供します。

PDF請求書から請求書データを抽出する

IronOCRを使用してPDF請求書からデータを抽出するには、前述のコード例と同様のアプローチに従うことができます。 IronOCRは画像ベースおよびテキストベースの両方のPDFを処理することができます。 PDF請求書からデータを抽出する簡単な例を以下に示します:

// Get all PDF files from the specified directory
string[] fileArray = Directory.GetFiles(@"D:\Invoices\", "*.pdf");

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Loop through each file and add it to the OCR input
    foreach (string file in fileArray)
    {
        input.AddPdf(file);
    }

    // Perform OCR on all the added PDFs and store the result
    OcrResult result = ocr.Read(input);

    // Output the extracted text from all PDFs to the console
    Console.WriteLine(result.Text);
}
// Get all PDF files from the specified directory
string[] fileArray = Directory.GetFiles(@"D:\Invoices\", "*.pdf");

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Loop through each file and add it to the OCR input
    foreach (string file in fileArray)
    {
        input.AddPdf(file);
    }

    // Perform OCR on all the added PDFs and store the result
    OcrResult result = ocr.Read(input);

    // Output the extracted text from all PDFs to the console
    Console.WriteLine(result.Text);
}
' Get all PDF files from the specified directory
Dim fileArray() As String = Directory.GetFiles("D:\Invoices\", "*.pdf")

' Create an instance of IronTesseract for OCR processing
Dim ocr As New IronTesseract()

' Use 'using' to ensure proper disposal of OcrInput resources
Using input As New OcrInput()
	' Loop through each file and add it to the OCR input
	For Each file As String In fileArray
		input.AddPdf(file)
	Next file

	' Perform OCR on all the added PDFs and store the result
	Dim result As OcrResult = ocr.Read(input)

	' Output the extracted text from all PDFs to the console
	Console.WriteLine(result.Text)
End Using
$vbLabelText   $csharpLabel

上記のコードは、ディレクトリにある複数のPDF請求書(@"D:\Invoices\")をIronOCRを使用して効率的にバッチ処理します。 ファイルパスを取得し、各PDFをOCR処理に追加し、抽出されたテキストを結合し、結果をコンソールに出力します。 このアプローチは大量の請求書を扱う組織のために請求書データ抽出を効率化し、効率を高め、手作業を削減します。

請求書OCR機械学習(ステップバイステップチュートリアル):図9 - 抽出出力

結論

要約すると、機械学習と最新のOCR技術、IronOCRのようなものの融合が請求書の取り扱いを再構築しています。 この記事では、IronOCRを使用するプロセスを歩き、そのすばらしい利点を示しました。 IronOCRを採用することで、企業は精度を高め、時間とコストを節約し、さまざまな形式と言語の請求書を簡単に扱うことができます。 手動データ入力の排除は効率を高めるだけでなく、財務取引における高価なエラーの可能性も減少させます。 IronOCRは請求書処理のワークフローを簡素化し改善し、今日の競争の激しい環境で財務運営を向上させようとする企業にとって賢明な選択です。 さらに、IronOCRは125以上の言語対応、カスタマイズ可能なデータ抽出、画像ベースおよびテキストベースのPDFとの互換性を含む強力な機能を提供します。

IronOCRの機能セットは印象的ですが、IronOCRの価格モデルは、試用版提供で広範なビジネスニーズに対応するように設計されています。小規模企業から大規模企業向けまで。 いくつかの請求書を処理している場合でも、多数の財務文書を管理している場合でも、IronOCRは信頼できるコスト効果の高いソリューションとして立ちます。

Kannaopat Udonpant
ソフトウェアエンジニア
ソフトウェアエンジニアになる前に、Kannapatは北海道大学で環境資源の博士号を修了しました。博士号を追求する間に、彼はバイオプロダクションエンジニアリング学科の一部である車両ロボティクスラボラトリーのメンバーになりました。2022年には、C#のスキルを活用してIron Softwareのエンジニアリングチームに参加し、IronPDFに注力しています。Kannapatは、IronPDFの多くのコードを執筆している開発者から直接学んでいるため、この仕事を大切にしています。同僚から学びながら、Iron Softwareでの働く社会的側面も楽しんでいます。コードやドキュメントを書いていない時は、KannapatはPS5でゲームをしたり、『The Last of Us』を再視聴したりしていることが多いです。