(env) G:\tensorflow-hub>make_image_classifier --image_dir=g://tensorflow-hub/dataset --tfhub_module https://tfhub.dev/google/tf2-preview/mobilenet_v2/feature_vector/4 --saved_model_dir my_dir/new_model --labels_output_file class_labels.txt --tflite_output_file new_mobile_model.tflite
I1012 16:31:42.019777 12188 resolver.py:79] Using C:\Users\codevjs\AppData\Local\Temp\tfhub_modules to cache modules.
2019-10-12 16:31:42.535549: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Using module https://tfhub.dev/google/tf2-preview/mobilenet_v2/feature_vector/4 with image size (224, 224)
Found 14 images belonging to 7 classes.
Found 56 images belonging to 7 classes.
Found 7 classes: cabe bercak, cabe cacar, cabe kuning, cabe normal, kakao hama, kakao normal, kakao penyakit
Model: "sequential"
keras_layer (KerasLayer) multiple 2257984
dropout (Dropout) multiple 0
Total params: 2,266,951
Trainable params: 8,967
Non-trainable params: 2,257,984
None
Epoch 1/5
2019-10-12 16:31:55.413796: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 115605504 exceeds 10% of system memory.
2019-10-12 16:31:55.479006: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 115605504 exceeds 10% of system memory.
2019-10-12 16:32:02.761047: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 115605504 exceeds 10% of system memory.
2019-10-12 16:32:07.184031: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 115605504 exceeds 10% of system memory.
2019-10-12 16:32:07.418295: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 115605504 exceeds 10% of system memory.
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1473.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.1473.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "G:\env\Scripts\make_image_classifier.exe__main__.py", line 9, in
File "g:\env\lib\site-packages\tensorflow_hub\tools\make_image_classifier\make_image_classifier.py", line 212, in run_main
app.run(main)
File "g:\env\lib\site-packages\absl\app.py", line 299, in run
_run_main(main, args)
File "g:\env\lib\site-packages\absl\app.py", line 250, in _run_main
sys.exit(main(argv))
File "g:\env\lib\site-packages\tensorflow_hub\tools\make_image_classifier\make_image_classifier.py", line 163, in main
FLAGS.tfhub_module, image_dir, hparams, FLAGS.image_size)
File "g:\env\lib\site-packages\tensorflow_hub\tools\make_image_classifier\make_image_classifier_lib.py", line 237, in make_image_classifier
train_data_and_size, valid_data_and_size)
File "g:\env\lib\site-packages\tensorflow_hub\tools\make_image_classifier\make_image_classifier_lib.py", line 210, in _train_model
validation_steps=validation_steps)
File "g:\env\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 1297, in fit_generator
steps_name='steps_per_epoch')
File "g:\env\lib\site-packages\tensorflow_core\python\keras\engine\training_generator.py", line 323, in model_iteration
steps_name='validation_steps')
File "g:\env\lib\site-packages\tensorflow_core\python\keras\engine\training_generator.py", line 301, in model_iteration
aggregator.finalize()
File "g:\env\lib\site-packages\tensorflow_core\python\keras\engine\training_utils.py", line 140, in finalize
raise ValueError('Empty training data.')
ValueError: Empty training data.
Getting the same issue trying to retrain using make_image_classifier
$ make_image_classifier --image_dir cover_images --tfhub_module https://tfhub.dev/google/tf2-preview/mobilenet_v2/feature_vector/4 --image_size 224 --saved_model_dir new_model --labels_output_file class_labels.txt --tflite_output_file new_mobile_model.tflite
Result -->
Using module https://tfhub.dev/google/tf2-preview/mobilenet_v2/feature_vector/4 with image size (224, 224)
Found 3 images belonging to 3 classes.
Found 18 images belonging to 3 classes.
Found 3 classes: press start volume 1, press start volume 2, press start volume 3
Labels written to class_labels.txt
Model: "sequential"
keras_layer (KerasLayer) multiple 2257984
dropout (Dropout) multiple 0
Total params: 2,261,827
Trainable params: 3,843
Non-trainable params: 2,257,984
None
Epoch 1/5
Traceback (most recent call last):
File "/env_tf/bin/make_image_classifier", line 11, in
sys.exit(run_main())
File "/env_tf/lib/python3.6/site-packages/tensorflow_hub/tools/make_image_classifier/make_image_classifier.py", line 364, in run_main
app.run(main)
File "/env_tf/lib/python3.6/site-packages/absl/app.py", line 299, in run
_run_main(main, args)
File "/env_tf/lib/python3.6/site-packages/absl/app.py", line 250, in _run_main
sys.exit(main(argv))
File "/env_tf/lib/python3.6/site-packages/tensorflow_hub/tools/make_image_classifier/make_image_classifier.py", line 319, in main
train_data_and_size, valid_data_and_size, FLAGS.batch_size)
File "/env_tf/lib/python3.6/site-packages/tensorflow_hub/tools/make_image_classifier/make_image_classifier.py", line 276, in _train_model
validation_data=valid_data, validation_steps=validation_steps)
File "/env_tf/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training.py", line 1297, in fit_generator
steps_name='steps_per_epoch')
File "/env_tf/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_generator.py", line 301, in model_iteration
aggregator.finalize()
File "/env_tf/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_utils.py", line 140, in finalize
raise ValueError('Empty training data.')
ValueError: Empty training data.
If you are less images in your train and test folders compared to the batch size, then that will lead to this error.
You can refer to the following comment and also go through the entire issue to get a better context of the problem.
@gowthamkpr increasing the number of images in the image_dir for each class worked. Retraining ran successfully.
If you are less images in your train and test folders compared to the batch size, then that will lead to this error.
You can refer to the following comment and also go through the entire issue to get a better context of the problem.
i see, thank u
Most helpful comment
If you are less images in your train and test folders compared to the batch size, then that will lead to this error.
You can refer to the following comment and also go through the entire issue to get a better context of the problem.