Issue
I was trying to split my image through 4 patches when I came through the following error:
UnimplementedError: Only support ksizes across space
iterator = tf.compat.v1.data.make_one_shot_iterator(parsed_dataset)
image,label = iterator.get_next()
image_height = image.shape[0]
image_width = image.shape[1]
# Since the expected type is (batch,height,width,channels), i have tryied to expand my image that have
# dimensions: (800,344,3) to (1,800,344,3) but didn't solved the error.
#image = tf.expand_dims(image ,0)
images = list(image)
extracted_patches = tf.image.extract_patches(images=images,
sizes=[1,int(0.25*image_height),int(0.25*image_width),3],
strides=[1,int(0.25*image_height),int(0.25*image_width),3],
rates=[1,1,1,1],
padding="SAME")
Traceback:
---------------------------------------------------------------------------
UnimplementedError Traceback (most recent call last)
<ipython-input-64-23c2aff4c306> in <module>()
17 strides=[1,int(0.25*image_height),int(0.25*image_width),3],
18 rates=[1,1,1,1],
---> 19 padding="SAME")
20
21
/Users/lucianoaraujo/anaconda2/lib/python2.7/site-packages/tensorflow_core/python/ops/array_ops.pyc in extract_image_patches_v2(images, sizes, strides, rates, padding, name)
4657 """
4658 return gen_array_ops.extract_image_patches(images, sizes, strides, rates,
-> 4659 padding, name)
4660
4661
/Users/lucianoaraujo/anaconda2/lib/python2.7/site-packages/tensorflow_core/python/ops/gen_array_ops.pyc in extract_image_patches(images, ksizes, strides, rates, padding, name)
2542 else:
2543 message = e.message
-> 2544 _six.raise_from(_core._status_to_exception(e.code, message), None)
2545 # Add nodes to the TensorFlow graph.
2546 if not isinstance(ksizes, (list, tuple)):
/Users/lucianoaraujo/anaconda2/lib/python2.7/site-packages/six.pyc in raise_from(value, from_value)
735 else:
736 def raise_from(value, from_value):
--> 737 raise value
738
739
UnimplementedError: Only support ksizes across space. [Op:ExtractImagePatches]
Solution
After further research I was able to manage by changing from:
images = list(image)
extracted_patches = tf.image.extract_patches(images=images,
sizes=[1,int(0.25*image_height),int(0.25*image_width),3],
strides=[1,int(0.25*image_height),int(0.25*image_width),3],
rates=[1,1,1,1],
padding="SAME")
To :
image = tf.expand_dims(image ,0)
extracted_patches = tf.image.extract_patches(images=image,
sizes=[1,int(0.25*image_height),int(0.25*image_width),1],
strides=[1,int(0.25*image_height),int(0.25*image_width),1],
rates=[1,1,1,1],
padding="SAME")
And then reshape to obtain 3 channel images:
patches = tf.reshape(extracted_patches,[-1,int(0.25*image_height),int(0.25*image_width),3])
Answered By - Luciano Dourado
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.