Imageai: ValueError ('Empty training data.')

Created on 23 Jun 2019  路  3Comments  路  Source: OlafenwaMoses/ImageAI

HI,

when i start a custom trainings model, i get the following error message:

ValueError ('Empty training data.')

Full text:

Total params: 23,643,035
Trainable params: 23,589,915
Non-trainable params: 53,120


W0623 16:15:53.030402 140526061152064 callbacks.py:875] period argument is deprecated. Please use save_freq to specify the frequency in number of samples seen.
Using Enhanced Data Generation
Found 14266 images belonging to 27 classes.
Found 0 images belonging to 0 classes.
JSON Mapping for the model classes saved to C:/home/christoph/Dokumente/bot/AI/ImageAI-master/v1training/food/json/model_class.json
Number of experiments (Epochs) : 100
2019-06-23 16:15:54.323644: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3199995000 Hz
2019-06-23 16:15:54.324357: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5a12a90 executing computations on platform Host. Devices:
2019-06-23 16:15:54.324387: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): ,
2019-06-23 16:15:54.892088: W tensorflow/compiler/jit/mark_for_compilation_pass.cc:1412] (One-time warning): Not using XLA:CPU for cluster because envvar TF_XLA_FLAGS=--tf_xla_cpu_global_jit was not set. If you want XLA:CPU, either set that envvar, or use experimental_jit_scope to enable XLA:CPU. To confirm that XLA is active, pass --vmodule=xla_compilation_cache=1 (as a proper command-line flag, not via TF_XLA_FLAGS) or set the envvar XLA_FLAGS=--xla_hlo_profile.
Epoch 1/100
444/445 [============================>.] - ETA: 9s - loss: 2.3643 - acc: 0.3269 Traceback (most recent call last):
File "ModelTraining.py", line 8, in
model_trainer.trainModel(num_objects=27, num_experiments=100, enhance_data=True, batch_size=32, show_network_summary=True)
File "/home/bot/imagai/imagai_venv/lib64/python3.6/site-packages/imageai/Prediction/Custom/__init__.py", line 309, in trainModel
validation_steps=int(num_test / batch_size), callbacks=[checkpoint, lr_scheduler])
File "/home/bot/imagai/imagai_venv/lib64/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 1433, in fit_generator
steps_name='steps_per_epoch')
File "/home/bot/imagai/imagai_venv/lib64/python3.6/site-packages/tensorflow/python/keras/engine/training_generator.py", line 322, in model_iteration
steps_name='validation_steps')
File "/home/bot/imagai/imagai_venv/lib64/python3.6/site-packages/tensorflow/python/keras/engine/training_generator.py", line 300, in model_iteration
aggregator.finalize()
File "/home/bot/imagai/imagai_venv/lib64/python3.6/site-packages/tensorflow/python/keras/engine/training_utils.py", line 111, in finalize
raise ValueError('Empty training data.')
ValueError: Empty training data.

Is this a problem for Keras? My Tensorflow Veriosn is:
Using TensorFlow backend.
2.2.4

I used the custom training script from your docs

`from imageai.Prediction.Custom import ModelTraining

model_trainer = ModelTraining()
model_trainer.setModelTypeAsResNet()
model_trainer.setDataDirectory(r"C:/home/christoph/Dokumente/bot/AI/ImageAI-master/v1training/food")
model_trainer.trainModel(num_objects=27, num_experiments=100, enhance_data=True, batch_size=32, show_network_summary=True)

Thanks for your help.`

Most helpful comment

HI,

when i start a custom trainings model, i get the following error message:

ValueError ('Empty training data.')

Full text:

HI,

when i start a custom trainings model, i get the following error message:

ValueError ('Empty training data.')

Full text:

Total params: 23,591,810
Trainable params: 23,538,690
Non-trainable params: 53,120


W0719 15:24:26.314924 11516 callbacks.py:875] period argument is deprecated. Please use save_freq to specify the frequency in number of samples seen.
Using Enhanced Data Generation
Found 198 images belonging to 2 classes.
Found 23 images belonging to 2 classes.
JSON Mapping for the model classes saved to C:\Users\indprasad\Documents\GitHub\ImageAI\imp-files\products\dataset\json\model_class.json
Number of experiments (Epochs) : 100
Epoch 1/100
5/6 [========================>.....] - ETA: 55s - loss: 4.1674 - acc: 0.4179 Traceback (most recent call last):
File "custom_model_training_new.py", line 9, in
model_trainer.trainModel(num_objects=2, num_experiments=100, enhance_data=True, batch_size=32, show_network_summary=True)
File "D:\ProgramData\anaconda3\lib\site-packages\imageai\Prediction\Custom__init__.py", line 309, in trainModel
validation_steps=int(num_test / batch_size), callbacks=[checkpoint, lr_scheduler])
File "D:\ProgramData\anaconda3\lib\site-packages\tensorflow\python\kerasengine\training.py", line 1433, in fit_generator
steps_name='steps_per_epoch')
File "D:\ProgramData\anaconda3\lib\site-packages\tensorflow\python\kerasengine\training_generator.py", line 322, in model_iteration
steps_name='validation_steps')
File "D:\ProgramData\anaconda3\lib\site-packages\tensorflow\python\kerasengine\training_generator.py", line 300, in model_iteration
aggregator.finalize()
File "D:\ProgramData\anaconda3\lib\site-packages\tensorflow\python\kerasengine\training_utils.py", line 111, in finalize
raise ValueError('Empty training data.')
ValueError: Empty training data.

is this a problem for Keras? My Tensorflow Veriosn is:
Using TensorFlow backend.
2.2.4

I used the custom training script from your docs

"from imageai.Prediction.Custom import ModelTraining
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

model_trainer = ModelTraining()
model_trainer.setModelTypeAsResNet()
model_trainer.setDataDirectory(r"C:\Users\indprasad\Documents\GitHub\ImageAI\imp-files\products\dataset")

model_trainer.trainModel(num_objects=2, num_experiments=100, enhance_data=True, batch_size=32, show_network_summary=True)"

Thanks for your help.`

All 3 comments

Make sure that ".../food/test" folder have 27 folders of each object your training on.
According to these lines I think:
Found 14266 images belonging to 27 classes. Found 0 images belonging to 0 classes.

HI,

when i start a custom trainings model, i get the following error message:

ValueError ('Empty training data.')

Full text:

HI,

when i start a custom trainings model, i get the following error message:

ValueError ('Empty training data.')

Full text:

Total params: 23,591,810
Trainable params: 23,538,690
Non-trainable params: 53,120


W0719 15:24:26.314924 11516 callbacks.py:875] period argument is deprecated. Please use save_freq to specify the frequency in number of samples seen.
Using Enhanced Data Generation
Found 198 images belonging to 2 classes.
Found 23 images belonging to 2 classes.
JSON Mapping for the model classes saved to C:\Users\indprasad\Documents\GitHub\ImageAI\imp-files\products\dataset\json\model_class.json
Number of experiments (Epochs) : 100
Epoch 1/100
5/6 [========================>.....] - ETA: 55s - loss: 4.1674 - acc: 0.4179 Traceback (most recent call last):
File "custom_model_training_new.py", line 9, in
model_trainer.trainModel(num_objects=2, num_experiments=100, enhance_data=True, batch_size=32, show_network_summary=True)
File "D:\ProgramData\anaconda3\lib\site-packages\imageai\Prediction\Custom__init__.py", line 309, in trainModel
validation_steps=int(num_test / batch_size), callbacks=[checkpoint, lr_scheduler])
File "D:\ProgramData\anaconda3\lib\site-packages\tensorflow\python\kerasengine\training.py", line 1433, in fit_generator
steps_name='steps_per_epoch')
File "D:\ProgramData\anaconda3\lib\site-packages\tensorflow\python\kerasengine\training_generator.py", line 322, in model_iteration
steps_name='validation_steps')
File "D:\ProgramData\anaconda3\lib\site-packages\tensorflow\python\kerasengine\training_generator.py", line 300, in model_iteration
aggregator.finalize()
File "D:\ProgramData\anaconda3\lib\site-packages\tensorflow\python\kerasengine\training_utils.py", line 111, in finalize
raise ValueError('Empty training data.')
ValueError: Empty training data.

is this a problem for Keras? My Tensorflow Veriosn is:
Using TensorFlow backend.
2.2.4

I used the custom training script from your docs

"from imageai.Prediction.Custom import ModelTraining
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

model_trainer = ModelTraining()
model_trainer.setModelTypeAsResNet()
model_trainer.setDataDirectory(r"C:\Users\indprasad\Documents\GitHub\ImageAI\imp-files\products\dataset")

model_trainer.trainModel(num_objects=2, num_experiments=100, enhance_data=True, batch_size=32, show_network_summary=True)"

Thanks for your help.`

Same issue here. What is the correct structure of the directory?

According to https://github.com/OlafenwaMoses/IdenProf/releases/ it should be

  • test

    • food

    • cars

    • etc

  • train

    • food

    • cars

    • etc

Is this structure correct?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bjente picture bjente  路  3Comments

palacinka picture palacinka  路  3Comments

letchfordnicholas picture letchfordnicholas  路  6Comments

pytesnim picture pytesnim  路  5Comments

plenari picture plenari  路  3Comments