为了账号安全,请及时绑定邮箱和手机立即绑定

尝试从图像中提取补丁并得到“UnimplementedError:只支持跨空间的 ksizes”

尝试从图像中提取补丁并得到“UnimplementedError:只支持跨空间的 ksizes”

当年话下 2023-04-18 15:28:05
当我遇到以下错误时,我试图通过 4 个补丁拆分我的图像:UnimplementedError: Only support ksizes across spaceiterator = 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")追溯:---------------------------------------------------------------------------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 
查看完整描述

1 回答

?
慕码人2483693

TA贡献1860条经验 获得超9个赞

经过进一步的研究,我能够通过改变来管理:


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")

到 :


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")

然后重塑以获得3通道图像:


patches = tf.reshape(extracted_patches,[-1,int(0.25*image_height),int(0.25*image_width),3])



查看完整回答
反对 回复 2023-04-18
  • 1 回答
  • 0 关注
  • 84 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信