Models: inception_resnet_v2 Train Image Classifier

Created on 23 Sep 2016  路  4Comments  路  Source: tensorflow/models

Issue in Resize Images for Inception_Resnet_v2

I am trying to run the inception_resnet_v2 example following the README in tensorflow/models/slim. I downloaded the MNIST dataset and the checkpoint file for the inception resnet v2. However when I get to the part of the example to run:

python train_image_classifier.py --train_dir=${TRAIN_DIR} --dataset_dir=${DATASET_DIR} --dataset_name=mnist --dataset_split_name=train --model_name=inception_resnet_v2 --checkpoint_path=${CHECKPOINT_PATH}

I get an error:

Traceback (most recent call last):
File "train_image_classifier.py", line 585, in
tf.app.run()
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 30, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "train_image_classifier.py", line 448, in main
image = image_preprocessing_fn(image, train_image_size, train_image_size)
File "/Users/foo/workspace/models/slim/preprocessing/preprocessing_factory.py", line 69, in preprocessing_fn
image, output_height, output_width, is_training=is_training, **kwargs)
File "/Users/foo/workspace/models/slim/preprocessing/inception_preprocessing.py", line 302, in preprocess_image
return preprocess_for_train(image, height, width, bbox, fast_mode)
File "/Users/foo/workspace/models/slim/preprocessing/inception_preprocessing.py", line 216, in preprocess_for_train
num_cases=num_resize_cases)
File "/Users/foo/workspace/models/slim/preprocessing/inception_preprocessing.py", line 42, in apply_with_random_selector
for case in range(num_cases)])[0]
File "/Users/foo/workspace/models/slim/preprocessing/inception_preprocessing.py", line 215, in
lambda x, method: tf.image.resize_images(x, height, width, method),
File "/usr/local/lib/python2.7/site-packages/tensorflow/python/ops/image_ops.py", line 787, in resize_images
raise ValueError(''size' must be a 1-D Tensor of 2 elements: '
ValueError: 'size' must be a 1-D Tensor of 2 elements: new_height, new_width

My TF-Slim Dataset Descriptor looks as follows:

import tensorflow as tf
from datasets import mnist

slim = tf.contrib.slim

# Selects the 'validation' dataset.
dataset = mnist.get_split('train', '/tmp/data/mnist')

# Creates a TF-Slim DataProvider which reads the dataset in the background
# during both training and testing.
provider = slim.dataset_data_provider.DatasetDataProvider(dataset)
[image, label] = provider.get(['image', 'label'])
awaiting model gardener

Most helpful comment

I think I fixed the error. In models/slim/preprocessing/inception_preprocessing.py line 215, lambda x, method: tf.image.resize_images(x, height, width, method) requires a tuple of (height, width) so if you wrap it in parentheses as lambda x, method: tf.image.resize_images(x, (height, width), method) it works.

All 4 comments

@sguada Could you take a look at this? Thanks.

I think I fixed the error. In models/slim/preprocessing/inception_preprocessing.py line 215, lambda x, method: tf.image.resize_images(x, height, width, method) requires a tuple of (height, width) so if you wrap it in parentheses as lambda x, method: tf.image.resize_images(x, (height, width), method) it works.

this issue is fixed in commit/253ca4ab8101dc2c2404530680b4a12e7518572d

but they used list instead of tuples

Looks like this has been fixed. Closing. Thanks!

Was this page helpful?
0 / 5 - 0 ratings