Giter Site home page Giter Site logo

jaidedai / easyocr Goto Github PK

View Code? Open in Web Editor NEW
21.9K 304.0 2.9K 157.85 MB

Ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic and etc.

Home Page: https://www.jaided.ai

License: Apache License 2.0

Python 77.14% Ruby 0.21% Dockerfile 0.11% Jupyter Notebook 1.14% Shell 0.04% C++ 13.72% Cuda 7.09% C 0.55%
ocr deep-learning crnn pytorch lstm machine-learning scene-text scene-text-recognition optical-character-recognition cnn

easyocr's Introduction

EasyOCR

PyPI Status license Open in Colab Tweet Twitter

Ready-to-use OCR with 80+ supported languages and all popular writing scripts including: Latin, Chinese, Arabic, Devanagari, Cyrillic, etc.

Try Demo on our website

Integrated into Huggingface Spaces 🤗 using Gradio. Try out the Web Demo: Hugging Face Spaces

What's new

  • 4 September 2023 - Version 1.7.1

    • Fix several compatibilities
  • 25 May 2023 - Version 1.7.0

  • 15 September 2022 - Version 1.6.2

    • Add CPU support for DBnet
    • DBnet will only be compiled when users initialize DBnet detector.
  • 1 September 2022 - Version 1.6.1

    • Fix DBnet path bug for Windows
    • Add new built-in model cyrillic_g2. This model is a new default for Cyrillic script.
  • 24 August 2022 - Version 1.6.0

    • Restructure code to support alternative text detectors.
    • Add detector DBnet, see paper. It can be used by initializing like this reader = easyocr.Reader(['en'], detect_network = 'dbnet18').
  • 2 June 2022 - Version 1.5.0

    • Add trainer for CRAFT detection model (thanks@gmuffiness, see PR)
  • Read all release notes

What's coming next

  • Handwritten text support

Examples

example

example2

example3

Installation

Install using pip

For the latest stable release:

pip install easyocr

For the latest development release:

pip install git+https://github.com/JaidedAI/EasyOCR.git

Note 1: For Windows, please install torch and torchvision first by following the official instructions here https://pytorch.org. On the pytorch website, be sure to select the right CUDA version you have. If you intend to run on CPU mode only, select CUDA = None.

Note 2: We also provide a Dockerfile here.

Usage

import easyocr
reader = easyocr.Reader(['ch_sim','en']) # this needs to run only once to load the model into memory
result = reader.readtext('chinese.jpg')

The output will be in a list format, each item represents a bounding box, the text detected and confident level, respectively.

[([[189, 75], [469, 75], [469, 165], [189, 165]], '愚园路', 0.3754989504814148),
 ([[86, 80], [134, 80], [134, 128], [86, 128]], '西', 0.40452659130096436),
 ([[517, 81], [565, 81], [565, 123], [517, 123]], '', 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)]

Note 1: ['ch_sim','en'] is the list of languages you want to read. You can pass several languages at once but not all languages can be used together. English is compatible with every language and languages that share common characters are usually compatible with each other.

Note 2: Instead of the filepath chinese.jpg, you can also pass an OpenCV image object (numpy array) or an image file as bytes. A URL to a raw image is also acceptable.

Note 3: The line reader = easyocr.Reader(['ch_sim','en']) is for loading a model into memory. It takes some time but it needs to be run only once.

You can also set detail=0 for simpler output.

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

Result:

['愚园路', '西', '', '315', '309', 'Yuyuan Rd.', 'W', 'E']

Model weights for the chosen language will be automatically downloaded or you can download them manually from the model hub and put them in the '~/.EasyOCR/model' folder

In case you do not have a GPU, or your GPU has low memory, you can run the model in CPU-only mode by adding gpu=False.

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

For more information, read the tutorial and API Documentation.

Run on command line

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

Train/use your own model

For recognition model, Read here.

For detection model (CRAFT), Read here.

Implementation Roadmap

  • Handwritten support
  • Restructure code to support swappable detection and recognition algorithms The api should be as easy as
reader = easyocr.Reader(['en'], detection='DB', recognition = 'Transformer')

The idea is to be able to plug in any state-of-the-art model into EasyOCR. There are a lot of geniuses trying to make better detection/recognition models, but we are not trying to be geniuses here. We just want to make their works quickly accessible to the public ... for free. (well, we believe most geniuses want their work to create a positive impact as fast/big as possible) The pipeline should be something like the below diagram. Grey slots are placeholders for changeable light blue modules.

plan

Acknowledgement and References

This project is based on research and code from several papers and open-source repositories.

All deep learning execution is based on Pytorch. ❤️

Detection execution uses the CRAFT algorithm from this official repository and their paper (Thanks @YoungminBaek from @clovaai). We also use their pretrained model. Training script is provided by @gmuffiness.

The recognition model is a CRNN (paper). It is composed of 3 main components: feature extraction (we are currently using Resnet) and VGG, sequence labeling (LSTM) and decoding (CTC). The training pipeline for recognition execution is a modified version of the deep-text-recognition-benchmark framework. (Thanks @ku21fan from @clovaai) This repository is a gem that deserves more recognition.

Beam search code is based on this repository and his blog. (Thanks @githubharald)

Data synthesis is based on TextRecognitionDataGenerator. (Thanks @Belval)

And a good read about CTC from distill.pub here.

Want To Contribute?

Let's advance humanity together by making AI available to everyone!

3 ways to contribute:

Coder: Please send a PR for small bugs/improvements. For bigger ones, discuss with us by opening an issue first. There is a list of possible bug/improvement issues tagged with 'PR WELCOME'.

User: Tell us how EasyOCR benefits you/your organization to encourage further development. Also post failure cases in Issue Section to help improve future models.

Tech leader/Guru: If you found this library useful, please spread the word! (See Yann Lecun's post about EasyOCR)

Guideline for new language request

To request a new language, we need you to send a PR with the 2 following files:

  1. In folder easyocr/character, we need 'yourlanguagecode_char.txt' that contains list of all characters. Please see format examples from other files in that folder.
  2. In folder easyocr/dict, we need 'yourlanguagecode.txt' that contains list of words in your language. On average, we have ~30000 words per language with more than 50000 words for more popular ones. More is better in this file.

If your language has unique elements (such as 1. Arabic: characters change form when attached to each other + write from right to left 2. Thai: Some characters need to be above the line and some below), please educate us to the best of your ability and/or give useful links. It is important to take care of the detail to achieve a system that really works.

Lastly, please understand that our priority will have to go to popular languages or sets of languages that share large portions of their characters with each other (also tell us if this is the case for your language). It takes us at least a week to develop a new model, so you may have to wait a while for the new model to be released.

See List of languages in development

Github Issues

Due to limited resources, an issue older than 6 months will be automatically closed. Please open an issue again if it is critical.

Business Inquiries

For Enterprise Support, Jaided AI offers full service for custom OCR/AI systems from implementation, training/finetuning and deployment. Click here to contact us.

easyocr's People

Contributors

a2va avatar abde0103 avatar abdusalamstd avatar achook avatar amitbcp avatar arkya-art avatar dakotahorstman avatar danielinux7 avatar dependabot[bot] avatar gmuffiness avatar hitbee-dev avatar imvladikon avatar jaidedteam avatar jpotter avatar korakot avatar loayamin avatar mejans avatar mijoo308 avatar ninam31 avatar rkcosmos avatar ronaldaug avatar samsamhuns avatar sardasumit avatar srdg avatar thammegowda avatar timgates42 avatar timurlenk07 avatar van1us avatar vijayabhaskar96 avatar visutida avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easyocr's Issues

Link refiner from CRAFT

First of all, thanks for making this tool! It's a great combination of powerful methods for text detection/recognition tasks.

I was wondering if the link-refiner model from CRAFT is intentionally omitted from the code. Otherwise, I'd be happy to make a PR for adding it.

dataset problems

Hi, this project is so amazing,thank you for your sharing.

I wanna know if you can share the training dataset for the chinese and english char.

Thank u again.

How to train my recognition model?

Can you share the code for training the recognition model? The default Chinese recognition model cannot recognize some Chinese characters. I want to train the recognition model myself, thank you.

BrokenPipeError: [Errno 32] Broken pipe

OS version:
Windows 10

Environment:
Python version:3.6.8
Pytorch version:stable(1.5.1) cpu only

Description:
To Reproduce:

import easyocr
reader = easyocr.Reader(['ja'])
print(reader.readtext('test.jpg'))

Log:

CUDA not available - defaulting to CPU. Note: This module is much faster with a GPU.
Downloading detection model, please wait
Download complete
Downloading recognition model, please wait
Download complete
CUDA not available - defaulting to CPU. Note: This module is much faster with a GPU.
Traceback (most recent call last):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "d:\projects\python\OCRTest\octTest.py", line 3, in <module>
    reader.readtext('test.jpg')
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\spawn.py", line 105, in spawn_main
  File "D:\Anaconda3\envs\MachineLearning\lib\site-packages\easyocr\easyocr.py", line 191, in readtext
    exitcode = _main(fd)
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\spawn.py", line 114, in _main
    workers, self.device)
    prepare(preparation_data)
  File "D:\Anaconda3\envs\MachineLearning\lib\site-packages\easyocr\recognition.py", 
line 186, in get_text
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\spawn.py", line 225, in prepare
    ignore_idx, char_group_idx, decoder, beamWidth, device = device)
    _fixup_main_from_path(data['init_main_from_path'])
  File "D:\Anaconda3\envs\MachineLearning\lib\site-packages\easyocr\recognition.py", 
line 104, in recognizer_predict
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
    for image_tensors in test_loader:
  File "D:\Anaconda3\envs\MachineLearning\lib\site-packages\torch\utils\data\dataloader.py", line 279, in __iter__
    run_name="__mp_main__")
  File "D:\Anaconda3\envs\MachineLearning\lib\runpy.py", line 263, in run_path       
    return _MultiProcessingDataLoaderIter(self)
    pkg_name=pkg_name, script_name=fname)
  File "D:\Anaconda3\envs\MachineLearning\lib\runpy.py", line 96, in _run_module_code
  File "D:\Anaconda3\envs\MachineLearning\lib\site-packages\torch\utils\data\dataloader.py", line 719, in __init__
    mod_name, mod_spec, pkg_name, script_name)
  File "D:\Anaconda3\envs\MachineLearning\lib\runpy.py", line 85, in _run_code       
    w.start()
    exec(code, run_globals)
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\process.py", line 105, 
in start
  File "d:\projects\python\OCRTest\octTest.py", line 3, in <module>
    reader.readtext('test.jpg')
  File "D:\Anaconda3\envs\MachineLearning\lib\site-packages\easyocr\easyocr.py", line 191, in readtext
    workers, self.device)
  File "D:\Anaconda3\envs\MachineLearning\lib\site-packages\easyocr\recognition.py", 
line 186, in get_text
    ignore_idx, char_group_idx, decoder, beamWidth, device = device)
  File "D:\Anaconda3\envs\MachineLearning\lib\site-packages\easyocr\recognition.py", 
line 104, in recognizer_predict
    for image_tensors in test_loader:
  File "D:\Anaconda3\envs\MachineLearning\lib\site-packages\torch\utils\data\dataloader.py", line 279, in __iter__
    return _MultiProcessingDataLoaderIter(self)
  File "D:\Anaconda3\envs\MachineLearning\lib\site-packages\torch\utils\data\dataloader.py", line 719, in __init__
    w.start()
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\process.py", line 105, 
in start
    self._popen = self._Popen(self)
    self._popen = self._Popen(self)
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\context.py", line 223, 
in _Popen
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\context.py", line 223, 
in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\context.py", line 322, 
in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\context.py", line 322, 
in _Popen
    return Popen(process_obj)
    return Popen(process_obj)
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\popen_spawn_win32.py", 
line 33, in __init__
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\popen_spawn_win32.py", 
line 65, in __init__
    reduction.dump(process_obj, to_child)
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\reduction.py", line 60, in dump
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\spawn.py", line 143, in get_preparation_data
    _check_not_importing_main()
  File "D:\Anaconda3\envs\MachineLearning\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main
    is not going to be frozen to produce an executable.''')
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
    ForkingPickler(file, protocol).dump(obj)
BrokenPipeError: [Errno 32] Broken pipe

After I referenced this article, I made the following changes to the easyocr\recognition.py and then the program wouldn't crash again.
At line 180:

test_loader = torch.utils.data.DataLoader(
        test_data, batch_size=batch_size, shuffle=False,
        num_workers=0, collate_fn=AlignCollate_normal, pin_memory=True)  # before: num_workers=int(workers)

I tried to run it and ran into some problems

Warning error
Traceback (most recent call last): File "C:/Users/amp/PycharmProjects/untitled3/test.py", line 2, in <module> reader = jaidedread.Reader(['th','en']) File "C:\Users\amp\PycharmProjects\untitled3\venv\lib\site-packages\jaidedread\jaidedread.py", line 87, in __init__ char_list = input_file.read().splitlines() UnicodeDecodeError: 'gbk' codec can't decode byte 0x81 in position 2: illegal multibyte sequence
I don't know what to do about it

GPU support issue

RuntimeError: module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them on device: cpu
what is the cuda version support please?
cudatoolkit: 10.1
Python: 3.7.7
EasyOCR: 1.1

PDF support

Sorry if this is an obvious question, but does it support PDFs ? If not, how one would use EasyOCR to extract text from PDFs?

Use without language

Can it be used just to detect characters on screen without language context. Like usernames, random (latin) characters?
Would it also be possible to whitelist characters?

ImportError: cannot import name '_validate_lengths' from 'numpy.lib.arraypad'

E:\WPy-3710\python-3.7.1.amd64>.\python.exe
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import easyocr
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:\WPy-3710\python-3.7.1.amd64\lib\site-packages\easyocr\__init__.py", line 1, in <module>
    from .easyocr import Reader
  File "E:\WPy-3710\python-3.7.1.amd64\lib\site-packages\easyocr\easyocr.py", line 1, in <module>
    from .detection import get_detector, get_textbox
  File "E:\WPy-3710\python-3.7.1.amd64\lib\site-packages\easyocr\detection.py", line 10, in <module>
    from .imgproc import resize_aspect_ratio, normalizeMeanVariance
  File "E:\WPy-3710\python-3.7.1.amd64\lib\site-packages\easyocr\imgproc.py", line 8, in <module>
    from skimage import io
  File "E:\WPy-3710\python-3.7.1.amd64\lib\site-packages\skimage\__init__.py", line 167, in <module>
    from .util.dtype import (img_as_float32,
  File "E:\WPy-3710\python-3.7.1.amd64\lib\site-packages\skimage\util\__init__.py", line 8, in <module>
    from .arraycrop import crop
  File "E:\WPy-3710\python-3.7.1.amd64\lib\site-packages\skimage\util\arraycrop.py", line 8, in <module>
    from numpy.lib.arraypad import _validate_lengths
ImportError: cannot import name '_validate_lengths' from 'numpy.lib.arraypad' (E:\WPy-3710\python-3.7.1.amd64\lib\site-packages\numpy\lib\arraypad.py)

Can't import easyocr on WinPython 3.71 on Windows 10. Installed without errors though

Arabic Language

I would like to help with the addition of the Arabic Language ... what is needed to be done ?

web demo

I can help web demo for better experience.

CUDA out of memory

Hi! I run into an out of memory error right from the start.

Build is the current pip install and the current developer build.
Testprogram is your simple example:
import easyocr
reader = easyocr.Reader(['de'])
reader.readtext('test.png')

Cuda version 10.1
torch 1.5.1
torchvision 0.6.1

After start (and a clean reboot of my machine) I get:
RuntimeError: CUDA out of memory. Tried to allocate 856.00 MiB (GPU 0; 4.00 GiB total capacity; 1.69 GiB already allocated; 310.80 MiB free; 2.65 GiB reserved in total by PyTorch)

Is it even possible to use easyOCR with 4GB GPU memory?

Thank you!

Finding leading punctuation

Hello,

Thanks for doing this! It looks very good.

I ran this on some text that I'd like to covert, which has lines like this, which includes embedded markdown:

===== Header
----- Section
     example text
     ~~~ js
            x = foo(y, z)
     ~~~

The problem is that the leading punctuation, such as the "=====" in the first line, are just ignored entirely. Later punctuation seems to be found with no problem.

Is there a way to have the algorithm find these as well?

Exception has occurred: RuntimeError

OS:win 10
python:3.8
torch:1.5.1
I am very happy that the author has open sourced this project.I try to debug it,but i got an exception .
my code

import easyocr
reader = easyocr.Reader(['ch_sim','en'],gpu=False)
reader.readtext('1.jpg')
print(reader)

my exception

Exception has occurred: RuntimeError

        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
  File "D:\WorkSpace\Python\easy_orc_test\test.py", line 3, in <module>
    reader.readtext('1.jpg')
  File "<string>", line 1, in <module>

Error when reader.readtext can't detect text

When you run reader.readtext on an image that has no text you get the following error:

File "C:\Users\blub\Envs\jaidedread\lib\site-packages\jaidedread\utils.py", line 443, in group_text_box
    x_min = min(mbox, key=lambda x: x[0])[0]
ValueError: min() arg is an empty sequence

Would be nice to have no error and empty return values instead.

Tensorflowjs model

I can't seem to find much online about converting pytorch models over to tensorflowjs. I'm looking for a good scene text detection model primarily for use on screenshots--so the text will be very clear.

I'd even be willing to donate a little if the accuracy was sufficiently high.

The "freeze_support()" line can be omitted if the program is not going to be frozen to produce an executable.

Since I failed to execute quickstart with poetry package on #52 , I switched package manager to pip. But it fails with other message.

Development Environment

  • Mac OS Catalina 10.15.5
  • pyenv virtual environment
  • Python 3.8.3
  • pip as package manager

How to replicate the error

Set up Virtual Environment and Dependencies

# zsh shell
pyenv virtualenv 3.8.3 OCR
pyenv activate OCR

Install easyocr via pip

pip install easyocr

Run Python File

# detect.py
import easyocr

reader = easyocr.Reader(["en", "ko"], gpu=False)
reader.readtext("./images/fc850139e7d6f37f4af7624e3cdbbcef.jpg")

Image Source is this jpg picture

# zsh shell
python detect.py
# zsh shell error message
Using CPU. Note: This module is much faster with a GPU.
Using CPU. Note: This module is much faster with a GPU.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/multiprocessing/spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/multiprocessing/spawn.py", line 125, in _main
    prepare(preparation_data)
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/multiprocessing/spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/multiprocessing/spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/runpy.py", line 265, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/noopy/OCR_KR/detect.py", line 4, in <module>
    reader.readtext("./images/fc850139e7d6f37f4af7624e3cdbbcef.jpg")
  File "/Users/noopy/.pyenv/versions/ocr/lib/python3.8/site-packages/easyocr/easyocr.py", line 189, in readtext
    result = get_text(self.character, imgH, max_width, self.recognizer, self.converter, image_list,\
  File "/Users/noopy/.pyenv/versions/ocr/lib/python3.8/site-packages/easyocr/recognition.py", line 185, in get_text
    result1 = recognizer_predict(recognizer, converter, test_loader,batch_max_length,\
  File "/Users/noopy/.pyenv/versions/ocr/lib/python3.8/site-packages/easyocr/recognition.py", line 104, in recognizer_predict
    for image_tensors in test_loader:
  File "/Users/noopy/.pyenv/versions/ocr/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 279, in __iter__
    return _MultiProcessingDataLoaderIter(self)
  File "/Users/noopy/.pyenv/versions/ocr/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 719, in __init__
    w.start()
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/multiprocessing/context.py", line 283, in _Popen
    return Popen(process_obj)
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/multiprocessing/spawn.py", line 154, in get_preparation_data
    _check_not_importing_main()
  File "/Users/noopy/.pyenv/versions/3.8.3/lib/python3.8/multiprocessing/spawn.py", line 134, in _check_not_importing_main
    raise RuntimeError('''
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

Model file not found

Trying to run the example and I get this error:

>>> import easyocr
>>> reader = easyocr.Reader(['en'])
CUDA not available - defaulting to CPU. Note: This module is much faster with a GPU.
Downloading detection model, please wait
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/myuser/.local/lib/python3.8/site-packages/easyocr/easyocr.py", line 168, in __init__
    urllib.request.urlretrieve(model_url['detector'][0] , DETECTOR_PATH)
  File "/usr/lib/python3.8/urllib/request.py", line 257, in urlretrieve
    tfp = open(filename, 'wb')
FileNotFoundError: [Errno 2] No such file or directory: '/home/myuser/.EasyOCR/model/craft_mlt_25k.pth'

Cannot run sample code - TypeError: 'bool' object is not callable

Code

import easyocr
reader = easyocr.Reader(['th','en'])
text = reader.readtext('abc.jpg')
print(text)

Console Output

% python3 mytest.py
Traceback (most recent call last):
  File "mytest.py", line 2, in <module>
    reader = easyocr.Reader(['th','en'])
  File "/usr/local/lib/python3.7/site-packages/easyocr/easyocr.py", line 166, in __init__
    self.detector = get_detector(DETECTOR_PATH, self.device)
  File "/usr/local/lib/python3.7/site-packages/easyocr/detection.py", line 61, in get_detector
    net.load_state_dict(copyStateDict(torch.load(trained_model, map_location=device)))
  File "/usr/local/lib/python3.7/site-packages/torch/serialization.py", line 593, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/usr/local/lib/python3.7/site-packages/torch/serialization.py", line 773, in _legacy_load
    result = unpickler.load()
  File "/usr/local/lib/python3.7/site-packages/torch/serialization.py", line 729, in persistent_load
    deserialized_objects[root_key] = restore_location(obj, location)
  File "/usr/local/lib/python3.7/site-packages/torch/serialization.py", line 814, in restore_location
    result = map_location(storage, location)
TypeError: 'bool' object is not callable

RuntimeError: unexpected EOF, expected 2304602 more bytes. The file might be corrupted.

Development Environment

  • Mac OS Catalina 10.15.5
  • pyenv virtual environment
  • Python 3.8.3
  • poetry as package manager

How to replicate the error

Set up Virtual Environment and Dependencies

# zsh shell
pyenv virtualenv 3.8.3 OCR
pyenv activate OCR

Install easyocr via poetry

pip install poetry
poetry init
poetry add easyocr

Run Python File

# detect.py
import easyocr
reader = easyocr.Reader(["en"], gpu=False)
reader.readtext("./images/7c9bfd59ce7b1768d42566c0e9ec606a.jpg")

Image source

# zsh shell
python detect.py
# zsh shell
Using CPU. Note: This module is much faster with a GPU.
Traceback (most recent call last):
  File "detect.py", line 3, in <module>
    reader = easyocr.Reader(["en"], gpu=False)
  File "/Users/noopy/.pyenv/versions/ocr/lib/python3.8/site-packages/easyocr/easyocr.py", line 171, in __init__
    self.detector = get_detector(DETECTOR_PATH, self.device)
  File "/Users/noopy/.pyenv/versions/ocr/lib/python3.8/site-packages/easyocr/detection.py", line 59, in get_detector
    net.load_state_dict(copyStateDict(torch.load(trained_model, map_location=device)))
  File "/Users/noopy/.pyenv/versions/ocr/lib/python3.8/site-packages/torch/serialization.py", line 593, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/Users/noopy/.pyenv/versions/ocr/lib/python3.8/site-packages/torch/serialization.py", line 780, in _legacy_load
    deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)
RuntimeError: unexpected EOF, expected 2304602 more bytes. The file might be corrupted.

I've ran with Korean language, and switched images also.
Any candidates for the cause of EOF error?

Uyghur Language

I would like to help with the addition of the Uyghur Language ... what is needed to be done ?

GPU is not working.

Hello.
I finally find good project for me.
but I have 1 issue using GPU, CPU version is fine.

when I load program like this.

    read = easyocr.Reader(['en'])
    text = read.readtext('D:/workspace/EasyOCR-master/examples/4.jpg')
    print(text)

I got this message :
RuntimeError: module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them on device: cpu

cannot import name 'isStringType'

Getting the following error while importing easyocr

Using python 3.6.10

`ImportError Traceback (most recent call last)
in
----> 1 import easyocr
2 reader = easyocr.Reader(['en'])
3 reader.readtext('F:/IT Mines/Images/shabbirPan.jpg')

~\anaconda3\envs\OCR\lib\site-packages\easyocr_init_.py in
----> 1 from .easyocr import Reader
2
3 version = '1.0.0'

~\anaconda3\envs\OCR\lib\site-packages\easyocr\easyocr.py in
----> 1 from .detection import get_detector, get_textbox
2 from .imgproc import loadImage
3 from .recognition import get_recognizer, get_text
4 from .utils import group_text_box, get_image_list, calculate_md5
5 import numpy as np

~\anaconda3\envs\OCR\lib\site-packages\easyocr\detection.py in
9 from .craft_utils import getDetBoxes, adjustResultCoordinates
10 from .imgproc import resize_aspect_ratio, normalizeMeanVariance
---> 11 from .craft import CRAFT
12
13 def copyStateDict(state_dict):

~\anaconda3\envs\OCR\lib\site-packages\easyocr\craft.py in
9 import torch.nn.functional as F
10
---> 11 from .modules import vgg16_bn, init_weights
12
13 class double_conv(nn.Module):

~\anaconda3\envs\OCR\lib\site-packages\easyocr\modules.py in
3 import torch.nn.functional as F
4 import torch.nn.init as init
----> 5 from torchvision import models
6 from torchvision.models.vgg import model_urls
7 from collections import namedtuple

~\anaconda3\envs\OCR\lib\site-packages\torchvision_init_.py in
2
3 from torchvision import models
----> 4 from torchvision import datasets
5 from torchvision import ops
6 from torchvision import transforms

~\anaconda3\envs\OCR\lib\site-packages\torchvision\datasets_init_.py in
7 from .svhn import SVHN
8 from .phototour import PhotoTour
----> 9 from .fakedata import FakeData
10 from .semeion import SEMEION
11 from .omniglot import Omniglot

~\anaconda3\envs\OCR\lib\site-packages\torchvision\datasets\fakedata.py in
1 import torch
2 from .vision import VisionDataset
----> 3 from .. import transforms
4
5

~\anaconda3\envs\OCR\lib\site-packages\torchvision\transforms_init_.py in
----> 1 from .transforms import *

~\anaconda3\envs\OCR\lib\site-packages\torchvision\transforms\transforms.py in
13 import warnings
14
---> 15 from . import functional as F
16
17

~\anaconda3\envs\OCR\lib\site-packages\torchvision\transforms\functional.py in
1 import torch
2 import math
----> 3 from PIL import Image, ImageOps, ImageEnhance, version as PILLOW_VERSION
4 try:
5 import accimage

~\anaconda3\envs\OCR\lib\site-packages\PIL\ImageOps.py in
22
23 from . import Image
---> 24 from ._util import isStringType
25
26 #

ImportError: cannot import name 'isStringType'`

Conda-forge recipe

This is an enhancement request - I was wondering if anyone had started on a conda-forge recipe or a conda recipe for any other channel? I'm happy to try and contribute that if not.

Vertical Japanese support?

Hello, I tried the model on vertical Japanese writing and the output was not great. Am I doing something wrong, and if not, are there plans to support it?

ModuleNotFoundError: No module named '_lzma'

Hi,
I'm on Ubuntu 20.04, python 3.6.9 using pyenv
I've installed the following:

sudo apt install liblzma-dev

On import easyocr, I get the following error.

(trial_env) ➜  bht-utils python
Python 3.6.9 (default, Jun 15 2020, 10:01:55) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import easyocr
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rajiv/Documents/dev/bht/bht-utils/trial_env/lib/python3.6/site-packages/easyocr/__init__.py", line 1, in <module>
    from .easyocr import Reader
  File "/home/rajiv/Documents/dev/bht/bht-utils/trial_env/lib/python3.6/site-packages/easyocr/easyocr.py", line 1, in <module>
    from .detection import get_detector, get_textbox
  File "/home/rajiv/Documents/dev/bht/bht-utils/trial_env/lib/python3.6/site-packages/easyocr/detection.py", line 10, in <module>
    from .imgproc import resize_aspect_ratio, normalizeMeanVariance
  File "/home/rajiv/Documents/dev/bht/bht-utils/trial_env/lib/python3.6/site-packages/easyocr/imgproc.py", line 8, in <module>
    from skimage import io
  File "/home/rajiv/Documents/dev/bht/bht-utils/trial_env/lib/python3.6/site-packages/skimage/io/__init__.py", line 7, in <module>
    from .manage_plugins import *
  File "/home/rajiv/Documents/dev/bht/bht-utils/trial_env/lib/python3.6/site-packages/skimage/io/manage_plugins.py", line 23, in <module>
    from .collection import imread_collection_wrapper
  File "/home/rajiv/Documents/dev/bht/bht-utils/trial_env/lib/python3.6/site-packages/skimage/io/collection.py", line 13, in <module>
    from tifffile import TiffFile
  File "/home/rajiv/Documents/dev/bht/bht-utils/trial_env/lib/python3.6/site-packages/tifffile/__init__.py", line 3, in <module>
    from .tifffile import __doc__, __all__, __version__, main
  File "/home/rajiv/Documents/dev/bht/bht-utils/trial_env/lib/python3.6/site-packages/tifffile/tifffile.py", line 11315, in <module>
    import lzma
  File "/home/rajiv/.pyenv/versions/3.6.9/lib/python3.6/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'

Persian Language (Farsi)

Hi , i read you'r description about adding new language here #25
I would like to add Farsi Language (Fa) with adding ~20000 words.
is this okay to start and train model or should i add more words and then create a PR ?

Problem while compiling

Hi there!

So I get the error while compiling code "reader = easyocr.Reader(['en'])".
This is the error:
File "/Users/yakalmar/anaconda3/lib/python3.6/site-packages/torch/serialization.py", line 814, in restore_location
result = map_location(storage, location)
TypeError: 'bool' object is not callable

Don't you know how I can fix it?
Thank you in advance

How to detect blank

Judging from the results, your recognition model can detect blank, can you tell you how to do it?

Word Spacing

Hi!

Is good performance about word spacing ?
I think that word spacing will be better if use coordinates of word and line detection bounding box of CRAFT!
I wonder what you think!

thanks!

ModuleNotFoundError: No module named 'tools.nnwrap'

I tried to run this under Windows (Python 3.7 64 bit) Made a clean virtualenvironment and tried to install with pip install jaidedread Then I got the following error:

...
Building wheels for collected packages: jaidedread, torch
  Building wheel for jaidedread (setup.py) ... done
  Created wheel for jaidedread: filename=jaidedread-0.9-py3-none-any.whl size=8504505 sha256=c59571047a4d43b39b9b6985e52c4c9c52be571d668fd1f25b3cfc87a29f90bd
  Stored in directory: c:\users\retrohelix\appdata\local\pip\cache\wheels\0b\d9\e4\10491a2ff91898c9763c6ffdf0121d55b66bee8d2b7ab57317
  Building wheel for torch (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\retrohelix\envs\jaidedread\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\RETROH~1\\AppData\\Local\\Temp\\pip-install-2y6jbmgx\\torch\\setup.py'"'"'; __file__='"'"'C:\\Users\\RETROH~1\\AppData\\Local\\Temp\\pip-install-2y6jbmgx\\torch\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\RETROH~1\AppData\Local\Temp\pip-wheel-b6i4i0x5'
       cwd: C:\Users\RETROH~1\AppData\Local\Temp\pip-install-2y6jbmgx\torch\
  Complete output (30 lines):
  running bdist_wheel
  running build
  running build_deps
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\RETROH~1\AppData\Local\Temp\pip-install-2y6jbmgx\torch\setup.py", line 265, in <module>
      description="Tensors and Dynamic neural networks in Python with strong GPU acceleration",
    File "c:\users\retrohelix\envs\jaidedread\lib\site-packages\setuptools\__init__.py", line 144, in setup
      return distutils.core.setup(**attrs)
    File "c:\users\retrohelix\appdata\local\programs\python\python37\Lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "c:\users\retrohelix\appdata\local\programs\python\python37\Lib\distutils\dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "c:\users\retrohelix\appdata\local\programs\python\python37\Lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "c:\users\retrohelix\envs\jaidedread\lib\site-packages\wheel\bdist_wheel.py", line 223, in run
      self.run_command('build')
    File "c:\users\retrohelix\appdata\local\programs\python\python37\Lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "c:\users\retrohelix\appdata\local\programs\python\python37\Lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "c:\users\retrohelix\appdata\local\programs\python\python37\Lib\distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "c:\users\retrohelix\appdata\local\programs\python\python37\Lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "c:\users\retrohelix\appdata\local\programs\python\python37\Lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\RETROH~1\AppData\Local\Temp\pip-install-2y6jbmgx\torch\setup.py", line 51, in run
      from tools.nnwrap import generate_wrappers as generate_nn_wrappers
  ModuleNotFoundError: No module named 'tools.nnwrap'
  ----------------------------------------
  ERROR: Failed building wheel for torch
  Running setup.py clean for torch
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\retrohelix\envs\jaidedread\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\RETROH~1\\AppData\\Local\\Temp\\pip-install-2y6jbmgx\\torch\\setup.py'"'"'; __file__='"'"'C:\\Users\\RETROH~1\\AppData\\Local\\Temp\\pip-install-2y6jbmgx\\torch\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' clean --all
       cwd: C:\Users\RETROH~1\AppData\Local\Temp\pip-install-2y6jbmgx\torch
  Complete output (2 lines):
  running clean
  error: [Errno 2] No such file or directory: '.gitignore'
  ----------------------------------------
  ERROR: Failed cleaning build dir for torch
Successfully built jaidedread
Failed to build torch
ERROR: torchvision 0.5.0 has requirement torch==1.4.0, but you'll have torch 0.1.2.post2 which is incompatible.
Installing collected packages: pyyaml, torch, Pillow, numpy, six, torchvision, opencv-python, scipy, jaidedread
    Running setup.py install for torch ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\retrohelix\envs\jaidedread\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\RETROH~1\\AppData\\Local\\Temp\\pip-install-2y6jbmgx\\torch\\setup.py'"'"'; __file__='"'"'C:\\Users\\RETROH~1\\AppData\\Local\\Temp\\pip-install-2y6jbmgx\\torch\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\RETROH~1\AppData\Local\Temp\pip-record-mp2uu87x\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\retrohelix\envs\jaidedread\include\site\python3.7\torch'
         cwd: C:\Users\RETROH~1\AppData\Local\Temp\pip-install-2y6jbmgx\torch\
    Complete output (23 lines):
    running install
    running build_deps
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\RETROH~1\AppData\Local\Temp\pip-install-2y6jbmgx\torch\setup.py", line 265, in <module>
        description="Tensors and Dynamic neural networks in Python with strong GPU acceleration",
      File "c:\users\retrohelix\envs\jaidedread\lib\site-packages\setuptools\__init__.py", line 144, in setup
        return distutils.core.setup(**attrs)
      File "c:\users\retrohelix\appdata\local\programs\python\python37\Lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "c:\users\retrohelix\appdata\local\programs\python\python37\Lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "c:\users\retrohelix\appdata\local\programs\python\python37\Lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\RETROH~1\AppData\Local\Temp\pip-install-2y6jbmgx\torch\setup.py", line 99, in run
        self.run_command('build_deps')
      File "c:\users\retrohelix\appdata\local\programs\python\python37\Lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\retrohelix\appdata\local\programs\python\python37\Lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\RETROH~1\AppData\Local\Temp\pip-install-2y6jbmgx\torch\setup.py", line 51, in run
        from tools.nnwrap import generate_wrappers as generate_nn_wrappers
    ModuleNotFoundError: No module named 'tools.nnwrap'
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\retrohelix\envs\jaidedread\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\RETROH~1\\AppData\\Local\\Temp\\pip-install-2y6jbmgx\\torch\\setup.py'"'"'; __file__='"'"'C:\\Users\\RETROH~1\\AppData\\Local\\Temp\\pip-install-2y6jbmgx\\torch\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\RETROH~1\AppData\Local\Temp\pip-record-mp2uu87x\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\retrohelix\envs\jaidedread\include\site\python3.7\torch' Check the logs for full command output.

Any ideas?

PDF support for embed words

Is it possible we do ocr on a pdf book and embed the words in the pdf file? It could be much useful if this can be implemented.

No result output

Hello.
I installed pytorch by this command "pip install torch==1.5.1+cpu torchvision==0.6.1+cpu -f https://download.pytorch.org/whl/torch_stable.html"
and used basic code for test OCR

import easyocr
reader = easyocr.Reader(['en'])
reader.readtext('example.jpg')

example.jpg was token from "https://github.com/JaidedAI/EasyOCR/raw/master/examples/example.png" and converted to jpg

I have no result output. I use windows 10 and pytorch in CPU only mode. I tried both stable and development releases.

stdout:
CUDA not available - defaulting to CPU. Note: This module is much faster with a GPU.
Downloading recognition model, please wait
Download complete

Add a way to choose witch GPU to use

I'm have a PC with 2 GPU, the first is pretty bad and has very little memory and isn't very powerful, but the second one doesn't have that problem.
But when i use EasyOCR, it will always use GPU0 (the first one), and i couldn't find a way to change that
Currently i can't even run easyOCR since my first gpu doesn't have enough memory
RuntimeError: CUDA out of memory. Tried to allocate 736.00 MiB (GPU 0; 2.00 GiB total capacity; 1.04 GiB already allocated; 206.91 MiB free; 1.07 GiB reserved in total by PyTorch)
So would it please be possible to add a way to change witch GPU gets used?

Error to load pretrained weight

Observed the Easy_OCR engine throwing error during the loading process of the pre-trained model. Please find the below error logs,

Traceback (most recent call last):
  File "/home/ironman/Workshop/GitDrawer/Easy_OCR/ocr_test.py", line 3, in <module>
    reader = easy_ocr.Reader(['ja'])
  File "/home/ironman/Workshop/GitDrawer/Easy_OCR/easy_ocr/easy_ocr.py", line 145, in __init__
    dict_list, MODEL_PATH, device = self.device)
  File "/home/ironman/Workshop/GitDrawer/Easy_OCR/easy_ocr/recognition.py", line 161, in get_recognizer
    model.load_state_dict(torch.load(model_path, map_location=device))
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 839, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for DataParallel:
	size mismatch for module.Prediction.weight: copying a param with shape torch.Size([5381, 512]) from checkpoint, the shape in current model is torch.Size([3111, 512]).
	size mismatch for module.Prediction.bias: copying a param with shape torch.Size([5381]) from checkpoint, the shape in current model is torch.Size([3111]).

Process finished with exit code 1

Could you please help me to solve this error? Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.