試試EasyOCR


使用craft

2中安裝方式:
git clone https://github.com/JaidedAI/EasyOCR.git
(base) xuehuiping@192 git % pip install EasyOCR & pip install -e .
或者:
pip install esayocr

測試圖片:

測試代碼:

# -*- encoding: utf-8 -*-
"""
@date: 2021/1/13 9:06 上午
@author: xuehuiping
"""
import easyocr
reader = easyocr.Reader(['ch_sim','en']) # need to run only once to load model into memory
result = reader.readtext('/Users/xuehuiping/Downloads/改進點/WX20201230-100641@2x@2x.png')
print(result)

日志和輸出:

/Users/xuehuiping/anaconda3/bin/python /Users/xuehuiping/git/workspace/x10.py
CUDA not available - defaulting to CPU. Note: This module is much faster with a GPU.
Downloading detection model, please wait. This may take several minutes depending upon your network connection.
Downloading recognition model, please wait. This may take several minutes depending upon your network connection.

[([[168, 16], [232, 16], [232, 46], [168, 46]], '3個月', 0.9807953834533691), ([[298, 16], [362, 16], [362, 46], [298, 46]], '1個月', 0.9961197376251221), ([[32, 48], [112, 48], [112, 80], [32, 80]], '材料費', 0.9226560592651367), ([[180, 50], [224, 50], [224, 74], [180, 74]], '800', 0.5787679553031921), ([[310, 50], [354, 50], [354, 76], [310, 76]], '300', 0.9649673700332642), ([[46, 80], [100, 80], [100, 110], [46, 110]], '學費', 0.9960775971412659), ([[174, 82], [230, 82], [230, 108], [174, 108]], '9840', 0.8053710460662842), ([[304, 82], [360, 82], [360, 108], [304, 108]], '3280', 0.9644178152084351), ([[44, 112], [100, 112], [100, 142], [44, 142]], '餐費', 0.9910867810249329), ([[174, 114], [230, 114], [230, 140], [174, 140]], '1725', 0.8011188507080078), ([[310, 114], [354, 114], [354, 140], [310, 140]], '575', 0.6803759932518005)]

Process finished with exit code 0

只輸出識別結果:
detail=0

result = reader.readtext('/Users/xuehuiping/Downloads/改進點/WX20201230-100641@2x.png', detail=0)

['3個月', '1個月', '材料費', '800', '300', '學費', '9840', '3280', '餐費', '1725', '575']
本機運行所用時間8s,gpu=False

模型文件保存目錄:

        self.model_storage_directory = MODULE_PATH + '/model'
...
MODULE_PATH = os.environ.get("EASYOCR_MODULE_PATH") or \
              os.environ.get("MODULE_PATH") or \
              os.path.expanduser("~/.EasyOCR/")

介紹:https://mp.weixin.qq.com/s/fq1UJcNP2RQ9yq1bFeXEZg
git:https://github.com/JaidedAI/EasyOCR


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM