Intro
I am using a modified version of the Tensorflow tutorial "Deep MNIST for experts" with the Python API for a medical images classification project using convolutionnal networks.
I want to artificially increase the size of my training set by applying random modifications on the images of my training set.
Problem
When I run the line :
flipped_images = tf.image.random_flip_left_right(images)
I get de following error :
AttributeError: 'numpy.ndarray' object has no attribute 'get_shape'
My Tensor "images" is an ndarray (shape=[batch, im_size, im_size, channels])
of "batch" ndarrays (shape=[im_size, im_size, channels])
.
Just to check if my input data was packed in the right shape and type, I have tried to apply this simple function in the (not modified) tutorial "Tensorflow Mechanics 101" and I get the same error.
Finally, I still get the same error trying to use the following functions :
tf.image.random_flip_up_down()
tf.image.random_brightness()
tf.image.random_contrast()
Questions
As input data is usually carried in Tensorflow as ndarrays, I would like to know :
tf.image.random_flip_left_right
to my training set?This seems like an inconsistency in the TensorFlow API, since almost all other op functions accept NumPy arrays wherever a tf.Tensor
is expected. I've filed an issue to track the fix.
Fortunately, there is a simple workaround, using tf.convert_to_tensor()
. Replace your code with the following:
flipped_images = tf.image.random_flip_left_right(tf.convert_to_tensor(images))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With