tensorflow-image-detection icon indicating copy to clipboard operation
tensorflow-image-detection copied to clipboard

retrain.py finding no validation images

Open noajshu opened this issue 6 years ago • 4 comments

WARNING:tensorflow:From retrain.py:768: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
Instructions for updating:

Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.

See @{tf.nn.softmax_cross_entropy_with_logits_v2}.

2018-08-23 20:00:15.046074: Step 0: Train accuracy = 31.0%
2018-08-23 20:00:15.046173: Step 0: Cross entropy = 1.318139
CRITICAL:tensorflow:Label 2 has no images in the category validation.
Traceback (most recent call last):
  File "retrain.py", line 1105, in <module>
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/Users/noaj/.virtualenvs/pytorch/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 126, in run
    _sys.exit(main(argv))
  File "retrain.py", line 908, in main
    bottleneck_tensor))
  File "retrain.py", line 513, in get_random_cached_bottlenecks
    image_dir, category)
  File "retrain.py", line 225, in get_image_path
    mod_index = index % len(category_list)
ZeroDivisionError: integer division or modulo by zero

noajshu avatar Aug 24 '18 03:08 noajshu

Getting same error please help if you have fixed it.

trbryant97 avatar Oct 10 '18 18:10 trbryant97

Seems to be some issue with the tensorflow API compatibility. May I please know which version are you using?

ArunMichaelDsouza avatar Oct 11 '18 21:10 ArunMichaelDsouza

@ArunMichaelDsouza , same error here. Using Tensorflow latest version with Python 3.7.0.

halixness avatar Dec 19 '18 13:12 halixness

This warning occurs when running the project with a dataset folder that has less than 20 images

The retrain.py randomly splits and assign images into three sets i.e., 'training', 'testing', and 'validation' (like the same old legacy method in scikit learn) which consider count of file validation as 0 (zero) , if you have less than 20 total training images for a particular label. hence ZeroDivisionError: integer division or modulo by zero occurs

Here is the comment in tensorflow/tensorflow/examples/image_retraining/retrain.py that explains what is happening:

# This looks a bit magical, but we need to decide whether this file should # go into the training, testing, or validation sets, and we want to keep # existing files in the same set even if more files are subsequently # added. # To do that, we need a stable way of deciding based on just the file name # itself, so we do a hash of that and then use that to generate a # probability value that we use to assign it.

thread from https://github.com/tensorflow/tensorflow/issues/2072

JacksonJegatheesan avatar Mar 14 '19 13:03 JacksonJegatheesan