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.26k stars 3.15k forks source link

EasyOCR PyTorch issue - MacBook Pro 14'' with M2 Pro Chip #1096

Open taadith opened 1 year ago

taadith commented 1 year ago

I am having trouble generating the model for a Tamil and English OCR in Visual Studio Code. I used the website version to analyze the file and it worked, so I'm unsure what I'm doing wrong.

This is my code: import easyocr reader = easyocr.Reader(['ta','en']) result = reader.readtext("tamil-text.jpeg")

Here is the following file I am trying to analyze (tamil-text.jpeg): tamil-text

This is the error message I received: /Users/aaditht/Library/Python/3.9/lib/python/site-packages/urllib3/init.py:34: NotOpenSSLWarning: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020 warnings.warn( Traceback (most recent call last): File "/Users/aaditht/Projects/tamil-translator/exploring-python-ocr/easyocr-example.py", line 2, in reader = easyocr.Reader(['ta','en']) File "/Users/aaditht/Library/Python/3.9/lib/python/site-packages/easyocr/easyocr.py", line 231, in init self.recognizer, self.converter = get_recognizer(recog_network, network_params,\ File "/Users/aaditht/Library/Python/3.9/lib/python/site-packages/easyocr/recognition.py", line 182, in get_recognizer model.load_state_dict(torch.load(model_path, map_location=device)) File "/Users/aaditht/Library/Python/3.9/lib/python/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 DataParallel: size mismatch for module.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 module.Prediction.bias: copying a param with shape torch.Size([143]) from checkpoint, the shape in current model is torch.Size([127]).

I apologize for the way this is formatted. This is the first issue I have ever submitted and will look at how other issues are crafted so I do a better job next time.

passerbya commented 1 year ago

Using version 1.6.2 can fixed this issues