tongpi / basicOCR

BasicOCR是一个致力于解决自然场景文字识别算法研究的项目。该项目由长城数字大数据应用技术研究院佟派AI团队发起和维护。
https://tongpi.github.io/basicOCR/
GNU General Public License v3.0
341 stars 127 forks source link

How to train a new model #15

Closed random123user closed 7 years ago

random123user commented 7 years ago

Hi, can anyone please tell me how to train this model for transfer learning. My model is working fine. But when I train it I am getting following error.

Traceback (most recent call last): File "crnn_main.py", line 191, in <module> train_iter = iter(train_loader) File "/usr/local/lib/python2.7/dist-packages/torch/utils/data/dataloader.py", line 303, in __iter__ return DataLoaderIter(self) File "/usr/local/lib/python2.7/dist-packages/torch/utils/data/dataloader.py", line 143, in __init__ self.sample_iter = iter(self.sampler) File "/home/pranay/crnn.pytorch/dataset.py", line 99, in __iter__ random_start = random.randint(0, len(self) - self.batch_size) File "/usr/lib/python2.7/random.py", line 242, in randint return self.randrange(a, b+1) File "/usr/lib/python2.7/random.py", line 218, in randrange raise ValueError, "empty range for randrange() (%d,%d, %d)" % (istart, istop, width) ValueError: empty range for randrange() (0,-33, -33) Exception AttributeError: "'DataLoaderIter' object has no attribute 'shutdown'" in <bound method DataLoaderIter.__del__ of <torch.utils.data.dataloader.DataLoaderIter object at 0x7ff08e6da050>> ignored

I am using the following line on terminal to run the code python crnn_main.py --trainroot="Pranay/train_set/" --valroot="Pranay/validation_set" --alphabet='0123456789abcdefghijklmnopqrstuvwxyz !-%.'"'"',#&$\/[]:()?;'

I just want to test that training is possible before I train the complete model. Hence I have selected validation set with 10 images and train set with 30 images. I know it is not possible to train by using just 30 images. But still, I just want to see my training on CPU working. I think this error has something to do with the small size of training data.

When I try to run for more images (150-200), my computer gets hanged. Hence, I am trying for small subset.

I am training on ICDAR 2015 data. I generated .mdb data by using input images path list as (This is just a sample. I hae more data in both lists)

and label path list as ['Genaxis Theatre', '[06]', '62-03', 'Carpark', ]

I have generated train.mdb and lock.mdb files both in folder train_set and validation_set. I have changed the alphabet to take into account new special characters as --alphabet='0123456789abcdefghijklmnopqrstuvwxyz !-%.'"'"',#&$\/[]:()?;'

Please, can you help me train my model? Any help is really appreciated.

Thanks

random123user commented 7 years ago

No worries solved the problem. It was regarding the batch size argument which is set to default by 256. As my train size was 40, It was not working.