EasyOCR icon indicating copy to clipboard operation
EasyOCR copied to clipboard

Runtime Error(Language Specific)

Open Th3Tr1ckst3r opened this issue 1 year ago • 3 comments

The runtime error can be replicated with the following code, and the Tamil language model:

ta
Using CPU. Note: This module is much faster with a GPU.
Traceback (most recent call last):
  File "/home/th3tr1ckst3r/Desktop/test.py", line 15, in <module>
    reader = easyocr.Reader([lang], gpu=False)
  File "/home/th3tr1ckst3r/.local/lib/python3.9/site-packages/easyocr/easyocr.py", line 231, in __init__
    self.recognizer, self.converter = get_recognizer(recog_network, network_params,\
  File "/home/th3tr1ckst3r/.local/lib/python3.9/site-packages/easyocr/recognition.py", line 174, in get_recognizer
    model.load_state_dict(new_state_dict)
  File "/home/th3tr1ckst3r/.local/lib/python3.9/site-packages/torch/nn/modules/module.py", line 2041, in load_state_dict
    raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for Model:
	size mismatch for Prediction.weight: copying a param with shape torch.Size([143, 512]) from checkpoint, the shape in current model is torch.Size([127, 512]).
	size mismatch for Prediction.bias: copying a param with shape torch.Size([143]) from checkpoint, the shape in current model is torch.Size([127]).

Python3 code used:

import easyocr

img_path = '/home/th3tr1ckst3r/Desktop/test123.jpg'
lang = 'ta'  
print(lang)
reader = easyocr.Reader([lang], gpu=False)
data = reader.readtext(img_path, detail=1)
for res in data:
    text = res[1]
    confidence = res[2]
    print(res[1], res[2], lang)

Th3Tr1ckst3r avatar Aug 22 '23 01:08 Th3Tr1ckst3r

Even I ran into the exact problem , could you please pass me the solution if found any? Thanks.

StaronDsilva avatar Sep 04 '23 10:09 StaronDsilva

no lang, if you recog english, reader = easyocr.Reader('en', gpu=False)

Seoung-wook avatar Sep 19 '23 05:09 Seoung-wook

Please check this repo if you are interested in tamil ocr. It's capable of recognizing both tamil and English. https://github.com/gnana70/tamil_ocr

You can simply install using pip install ocr_tamil

from ocr_tamil.ocr import OCR
image_path = r"test_images\0.jpg" # insert your own path here
ocr = OCR(detect=True)
texts = ocr.predict(image_path)
with open("output.txt","w",encoding="utf-8") as f:
    f.write(texts)

>>>> கொடைக்கானல் Kodaikanal 

gnana70 avatar Jan 30 '24 21:01 gnana70