EasyOCR
EasyOCR copied to clipboard
Error in loading tamil model
Tried to load tamil model but faced this error:
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]).
Please try to provide the solution .Thanks
Using version 1.6.2 can fixed this issues
I have a similar issue even on 1.6.2. Also tried 1.7.1 - same error.
RuntimeError: Error(s) in loading state_dict for DataParallel:
size mismatch for module.Prediction.weight: copying a param with shape torch.Size([103, 256]) from checkpoint, the shape in current model is torch.Size([97, 256]).
size mismatch for module.Prediction.bias: copying a param with shape torch.Size([103]) from checkpoint, the shape in current model is torch.Size([97]).
Try downgrading easyocr version, it helped me
On Mon, 23 Oct 2023, 6:49 am MikeAtom, @.***> wrote:
I have a similar issue even on 1.6.2. Also tried 1.7.1 - same error.
RuntimeError: Error(s) in loading state_dict for DataParallel: size mismatch for module.Prediction.weight: copying a param with shape torch.Size([103, 256]) from checkpoint, the shape in current model is torch.Size([97, 256]). size mismatch for module.Prediction.bias: copying a param with shape torch.Size([103]) from checkpoint, the shape in current model is torch.Size([97]).
— Reply to this email directly, view it on GitHub https://github.com/JaidedAI/EasyOCR/issues/1135#issuecomment-1774278379, or unsubscribe https://github.com/notifications/unsubscribe-auth/BBHVMXYB6HI7NISHQPYORD3YAXAYXAVCNFSM6AAAAAA4MW2B6OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZUGI3TQMZXHE . You are receiving this because you authored the thread.Message ID: @.***>
Hello MikeAtom
I also faced same issue change the yaml file as per opt.txt file and also in ~/dist-packages/easyor/character/your_language_char.txt need to be updated as per opt.txt character list
This error will be resolved
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