Skip to content

Receipt OCR

Overview

OCR (Optical Character Recognition) is a technology that recognizes text within images to obtain structured text information. We will use DataInterpreter for OCR information extraction from various types of receipts.

Example: Shopping Receipt Recognition

Task

Use DataInterpreter to perform OCR recognition on the following receipt, extract and save the total amount.

Code

examples/di/ocr_receipt.py

Note: You need to install Paddle-related dependencies to run this example, execute pip install metagpt[ocr]

bash
python examples/di/ocr_receipt.py
python examples/di/ocr_receipt.py

Execution Results

DataInterpreter will save a csv file containing the total amount under current working directory.

Mechanism Explained

Use DataInterpreter to first generate a plan, then generate tool code based on paddle OCR, execute OCR processing to recognize text information in the image of the catering invoice, extract relevant data, and organize these data into a table file.

Released under the MIT License.