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
23.81k stars 3.12k forks source link

EasyOCR Finetuning Error in dataloder #1002

Open nadhirhasan opened 1 year ago

nadhirhasan commented 1 year ago

Hello,

I have been trying to train a custom model using the trainer folder in this particular repository. However, I have encountered several errors due to version updates. After much debugging, I have encountered a strange error related to the use of a data loader. Specifically, I am receiving the error message: AttributeError: '_MultiProcessingDataLoaderIter' object has no attribute 'next'.

I have tried using both data_loader_iter.next() and next(data_loader_iter) to load the data, but the error persists. I am hoping someone can provide me with some assistance in resolving this issue. Thank you.

s-shakir commented 1 year ago

I faced this similar issue, trying to train custom model. I made the following changes and it works fine for me now:

data_loader_iter= iter(data_loader_iter) data_loader_iter= next(data_loader_iter)

its because of the difference in the pytorch versions

nadhirhasan commented 1 year ago

I faced this similar issue, trying to train custom model. I made the following changes and it works fine for me now:

data_loader_iter= iter(data_loader_iter) data_loader_iter= next(data_loader_iter)

its because of the difference in the pytorch versions

thanks mam, it's working

Srini138 commented 1 year ago

I faced this similar issue, trying to train custom model. I made the following changes and it works fine for me now: data_loader_iter= iter(data_loader_iter) data_loader_iter= next(data_loader_iter) its because of the difference in the pytorch versions

thanks mam, it's working

@nadhirhasan Hi, could you please tell where to change these lines in dataset.py

masoudMZB commented 1 year ago

@Srini138 inside dataset.py -> def get_batch(self) there is a for loop, and inside for there is a try except. put it there

nadhirhasan commented 1 year ago

where

I faced this similar issue, trying to train custom model. I made the following changes and it works fine for me now: data_loader_iter= iter(data_loader_iter) data_loader_iter= next(data_loader_iter) its because of the difference in the pytorch versions

thanks mam, it's working

@nadhirhasan Hi, could you please tell where to change these lines in dataset.py

yeah, @masoudMZB pointing the correct place. you can found within the get_batch function of the Batch_Balanced_Dataset class.

harivinod3 commented 1 year ago

Hello,

I too got the same error and I tried to place the given code in the dataset.py. But its not working. Can you please send that function code where you changed it. Thank you

nadhirhasan commented 1 year ago

hi @harivinod3,

Perhaps your code is correct, but there might be issues with the data format and file structure. I've recently created a notebook on finetuning EasyOCR, which I believe can provide you with a better understanding if you take a look.

EasyOCR finetuning: https://www.kaggle.com/code/nadhirhasan/let-s-finetune-easyocr-boom/notebook Inference Notebook: https://www.kaggle.com/code/nadhirhasan/check-the-performance-of-our-finetuned-ocr-model