ValueError: Attempt to convert a value (<PIL.PngImagePlugin.PngImageFile image mode=RGB size=519x600 at 0x7F95AD916518>) with an unsupported type

十年热恋 提交于 2021-01-04 05:29:48

问题


while i was opening and decoding an image from python with tensorflow i got an error

%tensorflow_version 2.x
import tensorflow as tf
from PIL import Image
import requests
from io import BytesIO
response = requests.get(r'https://upload.wikimedia.org/wikipedia/commons/e/e9/Felis_silvestris_silvestris_small_gradual_decrease_of_quality.png')
img = Image.open(BytesIO(response.content))

tf_image = tf.io.read_file(img)

error is hapenning when i used tf.io.read_file(img) Throws error of


_FallbackException Traceback (most recent call last) /tensorflow-2.1.0/python3.6/tensorflow_core/python/ops/gen_io_ops.py in read_file(filename, name) 548 _ctx._context_handle, tld.device_name, "ReadFile", name, --> 549 tld.op_callbacks, filename) 550 return _result

_FallbackException: This function does not handle the case of the path where all inputs are not already EagerTensors.

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last) 7 frames /tensorflow-2.1.0/python3.6/tensorflow_core/python/framework/constant_op.py in convert_to_eager_tensor(value, ctx, dtype) 94 dtype = dtypes.as_dtype(dtype).as_datatype_enum 95 ctx.ensure_initialized() ---> 96 return ops.EagerTensor(value, ctx.device_name, dtype) 97 98

ValueError: Attempt to convert a value () with an unsupported type () to a Tensor.

来源:https://stackoverflow.com/questions/60044385/valueerror-attempt-to-convert-a-value-pil-pngimageplugin-pngimagefile-image-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!