Tensorflow 图像添加标注框展示出错:《Tensorflow:实战Google深度学习框架》第七章中:
with tf.Session() as sess:
boxes = tf.constant([[[0.05, 0.05, 0.9, 0.7], [0.35, 0.47, 0.5, 0.56]])
batched = tf.expand_dims(tf.image.convert_image_dtype(img_data, tf.float32), 0)
image_with_box = tf.image.draw_bounding_boxes(batched, bbox_for_draw)
plt.imshow(image_with_box.eval())
plt.show()
报如下错误:
TypeError Traceback (most recent call last)
in ()
11
12
---> 13 plt.imshow(image_with_box.eval())
14 plt.show()
15
/home/ginmoo/anaconda2/lib/python2.7/site-packages/matplotlib/pyplot.pyc in imshow(X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, hold, data, **kwargs)
3156 filternorm=filternorm, filterrad=filterrad,
3157 imlim=imlim, resample=resample, url=url, data=data,
-> 3158 **kwargs)
3159 finally:
3160 ax._hold = washold
/home/ginmoo/anaconda2/lib/python2.7/site-packages/matplotlib/__init__.pyc in inner(ax, *args, **kwargs)
1890 warnings.warn(msg % (label_namer, func.__name__),
1891 RuntimeWarning, stacklevel=2)
-> 1892 return func(ax, *args, **kwargs)
1893 pre_doc = inner.__doc__
1894 if pre_doc is None:
/home/ginmoo/anaconda2/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in imshow(self, X, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)
5116 resample=resample, **kwargs)
5117
-> 5118 im.set_data(X)
5119 im.set_alpha(alpha)
5120 if im.get_clip_path() is None:
/home/ginmoo/anaconda2/lib/python2.7/site-packages/matplotlib/image.pyc in set_data(self, A)
547 if (self._A.ndim not in (2, 3) or
548 (self._A.ndim == 3 and self._A.shape[-1] not in (3, 4))):
--> 549 raise TypeError("Invalid dimensions for image data")
550
551 self._imcache = None
TypeError: Invalid dimensions for image data
请路过帮忙指导一下,谢谢