问题描述
https://keras-ocr.readthedocs.io/en/latest/examples/end_to_end_training.html
你好!我正在遵循此模型来训练Keras_ocr模型,该模型实际上可以从图像中预测文本,数字和特殊符号。 我无法运行此代码,因为我在下面提到的部分代码中遇到问题:
data_dir=r'.'
detector_batch_size = 1
detector_basepath = os.path.join(data_dir,'detector_{datetime.datetime.Now().isoformat()}')
detection_train_generator,detection_val_generator,detection_test_generator = [
detector.get_batch_generator(
image_generator=image_generator,batch_size=detector_batch_size
) for image_generator in image_generators
]
detector.model.fit_generator(
generator=detection_train_generator,steps_per_epoch=math.ceil(len(background_splits[0]) / detector_batch_size),epochs=1000,workers=0,callbacks=[
tf.keras.callbacks.EarlyStopping(restore_best_weights=True,patience=5),tf.keras.callbacks.CSVLogger('f{detector_basepath}.csv'),tf.keras.callbacks.ModelCheckpoint(filepath=f'{detector_basepath}.h5')
],validation_data=detection_val_generator,validation_steps=math.ceil(len(background_splits[1]) / detector_batch_size)
)
Epoch 1/1000
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\keras_ocr\detection.py",line 633,in get_batch_generator
batch = [next(image_generator) for n in range(batch_size)]
File "C:\Anaconda3\lib\site-packages\keras_ocr\detection.py",in <listcomp>
batch = [next(image_generator) for n in range(batch_size)]
stopiteration
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\FYP Proposal\Generate Fonts and Backgrounds\Keras_Ocr_Training.py",line 117,in <module>
validation_steps=math.ceil(len(background_splits[1]) / detector_batch_size)
File "C:\Anaconda3\lib\site-packages\tensorflow_core\python\keras\engine\training.py",line 1297,in fit_generator
steps_name='steps_per_epoch')
File "C:\Anaconda3\lib\site-packages\tensorflow_core\python\keras\engine\training_generator.py",line 221,in model_iteration
batch_data = _get_next_batch(generator)
File "C:\Anaconda3\lib\site-packages\tensorflow_core\python\keras\engine\training_generator.py",line 363,in _get_next_batch
generator_output = next(generator)
RuntimeError: generator raised stopiteration
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)