Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

size mismatch for Prediction.bias Error! #1315

Open
Chiyan200 opened this issue Oct 9, 2024 · 1 comment · May be fixed by #1333
Open

size mismatch for Prediction.bias Error! #1315

Chiyan200 opened this issue Oct 9, 2024 · 1 comment · May be fixed by #1333

Comments

@Chiyan200
Copy link

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
Copy link

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

Tamil character is number + symbol + en_char + ta_char

EasyOCR/easyocr/easyocr.py

Lines 194 to 200 in 914b164

elif self.model_lang == 'tamil':
char_file = os.path.join(BASE_PATH, 'character', "ta_char.txt")
with open(char_file, "r", encoding = "utf-8-sig") as input_file:
ta_list = input_file.read().splitlines()
ta_char = ''.join(ta_list)
self.character = number + symbol + en_char + ta_char
model_file = 'tamil.pth'

number = '0123456789'
symbol = '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ '
en_char = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

ி

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

EasyOCR/easyocr/config.py

Lines 127 to 134 in c4f3cd7

'tamil_g1':{
'filename': 'tamil.pth',
'model_script': 'tamil',
'url': 'https://github.com/JaidedAI/EasyOCR/releases/download/v1.1.7/tamil.zip',
'md5sum': '4b93972fdacdcdabe6d57097025d4dc2',
'symbols': "0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
'characters': '0123456789!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZஃஅஆஇஈஉஊஎஏஐஒஓஔகஙசஜஞடணதநனபமயரறலளழ'
},

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

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

@xiaoyao9184 xiaoyao9184 linked a pull request Nov 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants