qjadud1994 / CRNN-Keras

CRNN (CNN+RNN) for OCR using Keras / License Plate Recognition
MIT License
521 stars 191 forks source link

StopIteration error when training. #20

Closed Sreerag-ibtl closed 5 years ago

Sreerag-ibtl commented 5 years ago

I have training set of size 26451 and test set of size 1000. I am running the code in colab. But when executing the trainin.py this error is shown.

New weight data
26451 images are being loaded ...
True
26451 images has been loaded.
1000 images are being loaded ...
True
1000 images has been loaded.
Epoch 1/30
  1/207 [..............................] - ETA: 31:57 - loss: 108.4210
---------------------------------------------------------------------------
StopIteration                             Traceback (most recent call last)
<ipython-input-15-cd1b0bd3606a> in <module>()
     90                     validation_steps = ceil( 
     91 
---> 92                         tiger_val.n / val_batch_size ) 
     93 
     94                    )

/usr/local/lib/python3.6/dist-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
     89                 warnings.warn('Update your `' + object_name + '` call to the ' +
     90                               'Keras 2 API: ' + signature, stacklevel=2)
---> 91             return func(*args, **kwargs)
     92         wrapper._original_function = func
     93         return wrapper

/usr/local/lib/python3.6/dist-packages/keras/engine/training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
   1416             use_multiprocessing=use_multiprocessing,
   1417             shuffle=shuffle,
-> 1418             initial_epoch=initial_epoch)
   1419 
   1420     @interfaces.legacy_generator_methods_support

/usr/local/lib/python3.6/dist-packages/keras/engine/training_generator.py in fit_generator(model, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
    179             batch_index = 0
    180             while steps_done < steps_per_epoch:
--> 181                 generator_output = next(output_generator)
    182 
    183                 if not hasattr(generator_output, '__len__'):

StopIteration: 

Does anyone know what could be the problem?

Sreerag-ibtl commented 5 years ago

This error was due to the absence of the infinite loop in my next_batch function. Not an issue with this code.