regarding transforming an ndarray(image input via

2019-09-14 05:50发布

I have read an image as follows using opencv

image = cv2.imread('/data/TestImages/cat.jpg',cv2.IMREAD_UNCHANGED)

This read image cause the error message when it was called by segmentation, np_image, np_logits = sess.run([pred, image, logits])

The error message is as TypeError: Can not convert a ndarray into a Tensor or Operation.

Are there any mechanisms that can transform an image represented as ndarray to a Tensorflow tensor. Thanks.

1条回答
放我归山
2楼-- · 2019-09-14 06:28

You have to read up on the sess.run function. In the array you have as argument of your function you specify what you want to get OUT of your run command. In your case, you probably only want your pred and logits.

If you want to put something IN the network you have to specify a tf.placeholder in your graph, and feed your image like this:

np_pred,np_logits = sess.run([pred, logits],feed_dict={image_placeholder: image})

Hope this helps!

查看更多
登录 后发表回答