xingjian-f / DeepLearning-OCR

Build an Optical Character Recognition service using deep learning method
Apache License 2.0
54 stars 35 forks source link

IndexError: tuple index out of range #4

Closed BackT0TheFuture closed 7 years ago

BackT0TheFuture commented 7 years ago

hi there, there's an error when running the script train.py, how to sovle this? thx!

Loading data... Traceback (most recent call last): File "train.py", line 106, in main() File "train.py", line 94, in main train_data = load_data(train_data_dir, max_nb_char, img_width, img_height, i mg_channels, char_set, char2idx) File "D:\DeepLearning\DeepLearning-OCR\util.py", line 97, in load_data if y.shape[1] == 1: # keras bug ? IndexError: tuple index out of range

xingjian-f commented 7 years ago

Can you give me more details about your y? Thx!

BackT0TheFuture commented 7 years ago

win8.1 64bit py2.7 keras (theano backend) I just modified a little as follows and using my own images with model vgg_merge

img_width, img_height = 200, 70 img_channels = 3

some details about y ('type of y is :', <type 'numpy.ndarray'>) ('len of y is :', 0) ('shape of y is :', (0L,)) thanks!

xingjian-f commented 7 years ago

As you posted, 'shape of y is :', (0L,), which means the labels are empty, it's not loaded correctly. Please check the code comments in "load_data" function, all labels should be saved in "label.txt" row by row, the file should be encoded in utf-8. The first row correspond to 1.jpg's label, the second row correspond to 2.jpg's label, and so on.

BackT0TheFuture commented 7 years ago

sorry, my bad ! I didn't notice that the file encoding must be utf-8. now it works. thx!