ArunMichaelDsouza / tensorflow-image-detection

A generic image detection program that uses Google's Machine Learning library, Tensorflow and a pre-trained Deep Learning Convolutional Neural Network model called Inception.
MIT License
328 stars 88 forks source link

retrain.py finding no validation images #6

Open noajshu opened 6 years ago

noajshu commented 6 years ago
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
trbryant97 commented 6 years ago

Getting same error please help if you have fixed it.

ArunMichaelDsouza commented 6 years ago

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

halixness commented 5 years ago

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

JacksonJegatheesan commented 5 years ago

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