JaidedAI / EasyOCR

Ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic and etc.
https://www.jaided.ai
Apache License 2.0
24.6k stars 3.17k forks source link

size mismatch for Prediction.bias Error! #1315

Open Chiyan200 opened 1 month ago

Chiyan200 commented 1 month ago

This code is used
import easyocr reader = easyocr.Reader(['ta'], gpu=False) # this needs to run only once to load the model into memory result = reader.readtext('tamTxt.png') print("result : ",result)

i got this error i run this code using cpu Traceback (most recent call last): File "C:\python\test\g.py", line 2, in reader = easyocr.Reader(['ta'], gpu=False) # this needs to run only once to load the model into memory ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Python312\Lib\site-packages\easyocr\easyocr.py", line 231, in init self.recognizer, self.converter = get_recognizer(recog_network, network_params,\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Python312\Lib\site-packages\easyocr\recognition.py", line 174, in get_recognizer model.load_state_dict(new_state_dict) File "C:\Python\Python312\Lib\site-packages\torch\nn\modules\module.py", line 2215, 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]).

xiaoyao9184 commented 6 days ago

in https://github.com/JaidedAI/EasyOCR/releases/tag/v1.1.7

Tamil character is number + symbol + en_char + ta_char

https://github.com/JaidedAI/EasyOCR/blob/914b164626959b479b0e5c3ace0c23297b8735d1/easyocr/easyocr.py#L194-L200

https://github.com/JaidedAI/EasyOCR/blob/914b164626959b479b0e5c3ace0c23297b8735d1/easyocr/easyocr.py#L49-L51

https://github.com/JaidedAI/EasyOCR/blob/914b164626959b479b0e5c3ace0c23297b8735d1/easyocr/character/ta_char.txt#L1-L47

The values for characters are as follows, with a total of 144.

0123456789!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZஃஅஆஇஈஉஊஎஏஐஒஓஔகஙசஜஞடணதநனபமயரறலளழவஷஸஹாிீுூெேைொோௌ்

and in https://github.com/JaidedAI/EasyOCR/releases/tag/v1.7.2

https://github.com/JaidedAI/EasyOCR/blob/c4f3cd7225efd4f85451bd8b4a7646ae9a092420/easyocr/config.py#L127-L134

The values for characters are as follows, with a total of 128.

0123456789!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZஃஅஆஇஈஉஊஎஏஐஒஓஔகஙசஜஞடணதநனபமயரறலளழ