regarding transforming an ndarray(image input via cv2 or skimage) to a tensor

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. Благодарю.

1 ответ

Решение

Вы должны прочитать о функции sess.run. В массиве, который вы используете в качестве аргумента своей функции, вы указываете, что вы хотите получить OUT вашей команды run. В вашем случае вы, вероятно, хотите только свой пред и логиты.

Если вы хотите поместить что-то в сеть, вы должны указать на графике tf.placeholder и подать свое изображение следующим образом:

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

Надеюсь это поможет!

Другие вопросы по тегам