CRITICAL: tensorflow:Category has no images - validation

Fix:

The issue happens when you have less number of images in any of your sub folders.

I have faced same issue when total number of images under a particular category was less than 30, please try to increase the image count to resolve the issue.

Reason:

For each label (sub folder), tensorflow tries to create 3 categories of images (Train, Test and Validation) and places the images under it based on a probability value (calculated using hash of label name).

An image is placed in the category folder only if the probability value is less than the category (Train, Test or validation) size.

Now if number of images inside a label are less ( say 25) then validation size is calculated as 10 (default) and the probability value is usually greater than 10 and hence no image is placed in the validation set.

Later when all bottlenecks are created and tf is trying to calculate validation accuracy, it first throws an fatal log message:

CRITICAL:tensorflow:Category has no images - validation.

and then continues to execute the code and crashes as it tries to divide by validation list size (which is 0).


I've modified retrain.py to ensure that at least there is an image in validation (line 201*)

if len(validation_images) == 0:
   validation_images.append(base_name)
elif percentage_hash < validation_percentage:

(*) Line number may change in future releases. Look at the comments.


I had the same problem when running the retrain.py and when i set the --model_dir argument incorrectly and the inception directory got created in the flower_photos directory.

Please check if there are any directories in the flower_photos directory without any images.