10000 star! This OCR artifact can easily recognize more than 80 languages!

Time:2021-9-17

[introduction]: easyocr is an OCR library written in Python, which is used to recognize the text in the image and output it as text. It supports more than 80 languages.

brief introduction

Easyocr is a good OCR Library in Python. There are 10.3k stars in GitHub. At present, it supports more than 80 languages, including Chinese, Japanese, Korean and Thai.

10000 star! This OCR artifact can easily recognize more than 80 languages!

Download and install

The easyocr installation method is very simple. You can directly use PIP installation. There are two installation commands:

  • Install stable version
pip install easyocr  
  • Install the latest version
pip install git+git://github.com/jaidedai/easyocr.git  

It should be noted that if you install under windows, you need to install torch and torch vision first (see the official website for the installation method)https://pytorch.org)。 On the pytorch website, be sure to select the correct CUDA version. If you only want to run in CPU mode, select CUDA = none.

10000 star! This OCR artifact can easily recognize more than 80 languages!

In addition, the developer also provides docker files. See the following for details:https://github.com/JaidedAI/E…

Simple use

After installing the environment, use the following command to experience image recognition:

import easyocr  
#   Create a reader object and specify the language as short Chinese  
#   This command only needs to be run once to load the model into memory  
reader = easyocr.Reader(['ch_sim','en'])  
#   Read image  
result = reader.readtext('chinese.jpg')

Where chinese.jpg is

10000 star! This OCR artifact can easily recognize more than 80 languages!

The output is in list format, and each item represents the bounding box, text and confidence level respectively:

[([[189,   75],   [469,   75],   [469,   165],   [189,   165]],  ' Yuyuan Road ',   0.3754989504814148),  
 ([[86,   80],   [134,   80],   [134,   128],   [86,   128]],  ' West ',   0.40452659130096436),  
 ([[517,   81],   [565,   81],   [565,   123],   [517,   123]],  ' East ',   0.9989598989486694),  
 ([[78, 126], [136, 126], [136, 156], [78, 156]], '315', 0.8125889301300049),  
 ([[514, 126], [574, 126], [574, 156], [514, 156]], '309', 0.4971577227115631),  
 ([[226, 170], [414, 170], [414, 220], [226, 220]], 'Yuyuan Rd.', 0.8261902332305908),  
 ([[79, 173], [125, 173], [125, 213], [79, 213]], 'W', 0.9848111271858215),  
 ([[529, 173], [569, 173], [569, 213], [529, 213]], 'E', 0.8405593633651733)]

You can simplify the output by using detail = 0:

reader.readtext('chinese.jpg', detail = 0)  

The output results are as follows:

['Yuyuan Road',  ' West ',  ' East ',  ' 315',  ' 309',  ' Yuyuan   Rd.',  ' W',  ' E']

If there is no GPU or GPU memory is insufficient, you can run in CPU mode by adding GPU = false:

reader = easyocr.Reader(['ch_sim','en'], gpu = False)  

Alternatively, you can use the following command line:

$ easyocr -l ch_sim en -f chinese.jpg --detail=1 --gpu=True  

Quick experience

Friends who do not want to install the environment locally can experience it on the collab address provided by the developer:https://colab.fan/easyocr
Xiaoqiu tried several pictures on collab, and the results are as follows:

  • Identify Thai pictures

10000 star! This OCR artifact can easily recognize more than 80 languages!

Identification results:

[([[142, 232], [500, 232], [500, 361], [142, 361]],  
  'เส้นทางลัด',  
  0.10795291513204575),  
 ([[177, 483], [385, 483], [385, 573], [177, 573]],  
  'เพชรบุรี',  
  0.5405621528625488)]  
  • Identify Japanese pictures

10000 star! This OCR artifact can easily recognize more than 80 languages!

Identification results:

[([[71,   49],   [489,   49],   [489,   159],   [71,   159]],  ' "< forbidden!",   0.6339455246925354),  
 ([[95, 149], [461, 149], [461, 235], [95, 235]],  
  'NOLITTER',  
  0.32494133710861206),  
 ([[80, 232], [475, 232], [475, 288], [80, 288]],  
  'clean the port area',  
  0.9784266948699951),  
 ([[109, 289], [437, 289], [437, 333], [109, 333]],  
  'port   area   MINATO   CITY',  
  0.18789240717887878)]
  • Identify Korean pictures

10000 star! This OCR artifact can easily recognize more than 80 languages!

Identification results

[([[129, 79], [292, 79], [292, 183], [129, 183]], '서울', 0.9718754291534424),  
 ([[368, 101], [531, 101], [531, 201], [368, 201]], '평양', 0.9701955914497375),  
 ([[159, 176], [258, 176], [258, 232], [159, 232]],  
  'Seoul',  
  0.8239477872848511),  
 ([[342, 189], [539, 189], [539, 262], [342, 262]],  
  'Pyeongyang',  
  0.3527982532978058),  
 ([[186, 276], [289, 276], [289, 333], [186, 333]],  
  '56Km',  
  0.6299729943275452),  
 ([[344, 288], [461, 288], [461, 344], [344, 344]],  
  '205Km',  
  0.38107678294181824)]  

epilogue

Easyocr is briefly introduced here. Interested friends can go to the project home page to learn more details.

Open source outpostShare popular, interesting and practical open source projects on a daily basis. Participate in maintaining the open source technology resource library of 100000 + star, including python, Java, C / C + +, go, JS, CSS, node.js, PHP,. Net, etc.

Recommended Today

Seven Python code review tools recommended

althoughPythonLanguage is one of the most flexible development languages at present, but developers often abuse its flexibility and even violate relevant standards. So PythoncodeThe following common quality problems often occur: Some unused modules have been imported Function is missing arguments in various calls The appropriate format indentation is missing Missing appropriate spaces before and after […]