【问题标题】:regarding transforming an ndarray(image input via cv2 or skimage) to a tensor关于将 ndarray(通过 cv2 或 skimage 输入的图像)转换为张量
【发布时间】:2017-07-10 05:47:47
【问题描述】:

我使用opencv阅读了如下图片

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

这个读取的图像在被segmentation, np_image, np_logits = sess.run([pred, image, logits])调用时导致错误消息

错误信息为TypeError: Can not convert a ndarray into a Tensor or Operation.

是否有任何机制可以将表示为 ndarray 的图像转换为 Tensorflow 张量。谢谢。

【问题讨论】:

    标签: tensorflow deep-learning theano keras


    【解决方案1】:

    您必须阅读 sess.run 函数。在数组中,作为函数的参数,您可以指定要从运行命令中获取的内容。在您的情况下,您可能只需要您的 pred 和 logits。

    如果你想在网络中添加一些东西,你必须在你的图表中指定一个 tf.placeholder,然后像这样输入你的图像:

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

    希望这会有所帮助!

    【讨论】:

    猜你喜欢
    • 2021-05-27
    • 2019-02-25
    • 1970-01-01
    • 1970-01-01
    • 2018-12-14
    • 2020-06-27
    • 2021-02-24
    • 2020-08-28
    • 2020-11-15
    相关资源
    最近更新 更多