Reputation: 69
I'm trying to combine a set of images into one np.array and convert it to a tf.data.Dataset object like so:
test = np.array([np.array(PIL.Image.open(image), dtype=np.float32) for image in image_list],
dtype=object)
test_set = tf.data.Dataset.from_tensor_slices(test)
But doing so raises the following error:
ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray).
Any idea what I could be doing wrong? Cheers
Upvotes: 1
Views: 4488
Reputation: 69
Figured out the issue was caused by creating one np.array too many. Doing the following fixed it for me:
test = [np.array(PIL.Image.open(image), dtype=np.float32) for image in image_list]
Upvotes: 3