iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🐟

OnnxOCR: High-Speed and High-Accuracy OCR Even Without a GPU on Local Machines

に公開
2025/09/29

In the process of advancing in-house DX, there are quite a few requirements for OCR of analog data, but in strict corporate environments, there are constraints such as a ban on cloud usage or having only low-spec PCs. While searching for a good general-purpose OCR that runs on the edge, I found an excellent library.

Since I couldn't find any articles introducing it in Japanese at all, I'll introduce it like an AI hype-man.

What is OnnxOCR?

https://github.com/jingsongliujing/OnnxOCR

OnnxOCR is a lightweight OCR based on PaddleOCR that can operate without the paddlepaddle deep learning framework and features fast inference speeds.

By converting the same models as PaddleOCR to onnx models, accuracy and performance improve, with inference speeds 5 times faster than using the paddlepaddle framework.

Simply put, it is an overwhelmingly fast and high-performance OCR engine compared to conventional OCR engines.

Additionally, it is licensed under Apache, so commercial use is also possible.

How to Use

Installation is available via PyPI.
By default, it downloads the ONNX model into the library data, so you can start using it immediately.

pip install onnxocr

Usage is also very simple; you can run OCR with a program like the following.

from onnxocr.onnx_paddleocr import ONNXPaddleOcr

def sample():
    ocr = ONNXPaddleOcr(use_gpu=False, lang="japan")
    result = ocr.ocr("sample.png")

    for data in result:
        for box, (text, score) in data:
            print(f"text: {text}, score: {score}")

What is ONNX?

When introducing OnnxOCR, I'll also briefly explain what ONNX is.
ONNX (Open Neural Network Exchange) is an open format for sharing and operating machine learning models across different frameworks.

https://qiita.com/motoJinC25/items/d662be70b6b9b8ebbaea

By following this format, models created in different machine learning frameworks such as PyTorch, TensorFlow, or Scikit-learn can be saved and loaded in a common format.

Hardware vendors can optimize ONNX to provide fast inference environments compatible with multiple frameworks.

Furthermore, the ONNX Runtime ecosystem is extremely powerful, enabling high-speed inference.

In other words, OnnxOCR is a library that accelerates PaddleOCR by leveraging the powerful ONNX ecosystem.

Actually Comparing Speed and Accuracy

Since introducing it with only words won't convey its greatness, I'll actually verify it.

The verification conditions are as follows:

  • Comparison among three: EasyOCR, PaddleOCR, OnnxOCR

  • Models: EasyOCR uses default settings; PaddleOCR and OnnxOCR both use the same lightweight mobile-oriented model

  • CPU inference only (using an Intel 12th generation Core i7)

Tesseract has a slightly different nature from the above three, so I did not compare it this time.

The benchmark program is published on GitHub. Since the usage and processing of each library differ, please refer to it if you want to use these OCR libraries.

https://github.com/harumiWeb/onnxocr_benchmark/blob/0da7796ce066afe518c244bdbf3d08038a4b6e48/main.py

Comparison ① (Signage in a Landscape)

I used the following image.

Image of a sign in a Japanese landscape

Street signage

The recognition results of each OCR engine are as follows.

  • EasyOCR

  • PaddleOCR

  • OnnxOCR

  • Speed Benchmark

Regarding recognition accuracy, all OCR engines were generally accurate.
What's noteworthy is the inference speed.
As you can see from the speed benchmark graph, OnnxOCR's inference speed of 0.62 seconds is the fastest. Considering the balance with recognition accuracy, this is an incredible performance.

Comparison ② (Document with Many Characters)

Next, I passed an image of clean text like a document file. The number of characters is large, but how will it perform?

Image data of a typical offer letter

  • EasyOCR

  • PaddleOCR

  • OnnxOCR

  • Speed Benchmark

For the data with many characters, there was no significant difference in inference speed, but OnnxOCR came out fastest.

It's impressive that EasyOCR, which takes the most time for inference, has the same recognition accuracy.

Comparison ③ (Image with Few Characters but Distorted)

Finally, I verified the following image.

Photo of a bridge sign taken diagonally

  • EasyOCR

  • PaddleOCR

  • OnnxOCR

  • Speed Benchmark

In Comparison ③, OnnxOCR achieved overwhelming results.

Without any additional settings, only OnnxOCR effectively corrected the tilt and achieved high character recognition.

Furthermore, in terms of inference speed, it was 2 times faster than PaddleOCR and 7.5 times faster than EasyOCR.

However, EasyOCR consistently completes in about 3.5 seconds for any image, so it might not be significantly affected by the actual amount of information in the target.

Conclusion

While it largely depends on model performance, it was found that OnnxOCR boasts overwhelming inference speed and character recognition for image data with a small amount of information, despite being lightweight.

It's terrifying that Baidu makes models of this level available as open source.

With this level of performance even with CPU inference, it seems quite practical OCR processing can be executed even in edge environments.

I've become very interested in ONNX, so I'd like to look into it a bit more.

https://github.com/PaddlePaddle/PaddleOCR
https://github.com/JaidedAI/EasyOCR
https://onnx.ai

Discussion