CRITICAL: tensorflow: Category has no images - validation

I am trying to relearn the Inception v3 model in a tensor stream for my own categories. I downloaded some data and formatted it in directories. When I run, the python script creates bottlenecks for the images, and then when it starts, in the first stage of training (step 0) it has a critical error, where it tries modulo to 0. It appears in the get_image_path function when calculating mod_index, which is the index% len (category_list), so should category_list be 0 correct?

Why is this happening and how can I prevent it?

EDIT: Here is the exact code that I see inside the docker

2016-07-04 01:27:52.005912: Step 0: Train accuracy = 40.0% 2016-07-04 01:27:52.006025: Step 0: Cross entropy = 1.109777 CRITICAL:tensorflow:Category has no images - validation. Traceback (most recent call last): File "tensorflow/examples/image_retraining/retrain.py", line 824, in <module> tf.app.run() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 30, in run sys.exit(main(sys.argv)) File "tensorflow/examples/image_retraining/retrain.py", line 794, in main bottleneck_tensor)) File "tensorflow/examples/image_retraining/retrain.py", line 484, in get_random_cached_bottlenecks bottleneck_tensor) File "tensorflow/examples/image_retraining/retrain.py", line 392, in get_or_create_bottleneck bottleneck_dir, category) File "tensorflow/examples/image_retraining/retrain.py", line 281, in get_bottleneck_path category) + '.txt' File "tensorflow/examples/image_retraining/retrain.py", line 257, in get_image_path mod_index = index % len(category_list) ZeroDivisionError: integer division or modulo by zero 
+7
python machine-learning tensorflow
source share
9 answers

Fix:

The problem occurs when you have fewer images in any of your subfolders.

I faced the same problem when the total number of images under a certain category was less than 30, try increasing the number of images to solve the problem.

Cause:

For each label (subfolder), the tensor stream tries to create 3 categories of images (Train, Test and Validation) and places the images below it based on the probability value (calculated using the hash of the label name).

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

Now, if the number of images inside the label is less (say 25), the verification size is calculated as 10 (by default), and the probability value is usually greater than 10 and, therefore, the image does not fit into the verification set.

Later, when all bottlenecks are created and tf tries to calculate the accuracy of the check, it first issues a fatal log message:

CRITICAL: tensorflow: Category has no images - validation.

and then continues to execute the code and crash as it tries to split the checklist by size (which is 0).

+10
source share

I had the same problem when running retrain.py and when I set the -model_dir argument incorrectly and the created directory started to be created in the flower_photos directory.

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

+5
source share
  • This happens if you have too few images. As Ashwin suggested, there are at least 30 images.

  • The names of your folder are also important. Somehow your folder name cannot have an underscore (_)

eg. These names do not work : dettol_bottle, dettol_soap, dove_soap, lifebuoy_bottle

These names worked : dettolbottle, dettolsoap, dovesoap, lifebuoybottle

+3
source share

I tried to train using my own set of images (photographs of dogs instead of flowers), and ran into this problem.

I determined that the problem for me ultimately was that the names of my folders (category names) were not present in the imagenet_synset_to_human_label_map.txt file, which is loaded into the original data that we are modifying.

Changing the name of my Bichon folder to a poodle, this started to work, since the poodle is on the initial map, but the Bichon is not.

+2
source share

For me, this error is caused by the fact that there are folders in the training directory in which there are no images. I followed the same Poets tutorial and ended up placing directories with subdirectories in the image directory. As soon as I deleted them and placed only the directories with images directly in them (without a subdirectory), the error no longer occurred, and I was able to successfully train my model.

+1
source share

For me it was a “-” in the names of my folders. The moment I fixed it, the error disappeared.

+1
source share

I modified retrain.py to make sure 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: 
+1
source share

I would also like to add my own experience:

They do not have spaces. For me, this worked when all the folder names were contained in z characters, without spaces, without characters, nohin '.

For example, "I am a folder" is wrong. However, "imAFolder" will work.

0
source share

As Ashwin Patti replied, there is a possibility that the split directory for verification does not have images due to the lack of images in the source shortcut directory.

This explanation is supported by a warning when you try to reprogram tags with less than 20 images:

A WARNING. The folder has less than 20 images, which can cause problems.

0
source share

All Articles