问题
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