我想使用tf.data输入我的图像数据。我已经将所有图像折叠成一个np.array,然后我习惯了np.array创建一个tf.data.Dataset对象。但是,我遇到了TypeError。我的代码如下所示。
import os
from scipy.misc import imread
import numpy as np
import glob
import tensorflow as tf
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
image = []
img_dir = 'data/ILSVRC2012_test/*'
images = np.array([np.array(imread(data)) for data in glob.glob(img_dir)])
image_data = tf.data.Dataset.from_tensor_slices(images)
下面的块是错误信息。
TypeError: Expected binary or unicode string, got array([[[184, 210, 225],
[184, 210, 225],
[184, 210, 225],
...,
[160, 185, 205],
[159, 184, 204],
[159, 184, 204]],
[[183, 209, 224],
[184, 210, 225],
[184, 210, 225],
...,
[159, 186, 205],
[159, 186, 205],
[159, 186, 205]],
[[184, 210, 225],
[184, 210, 225],
[185, 211, 226],
...,
[160, 187, 206],
[160, 187, 206],
[160, 187, 206]],
...,
[[ 65, 65, 15],
[ 71, 71, 17],
[ 75, 76, 19],
...,
[ 83, 83, 19],
[ 82, 87, 21],
[ 85, 85, 21]],
[[ 70, 70, 18],
[ 74, 75, 18],
[ 74, 78, 19],
...,
[ 77, 81, 20],
[ 78, 87, 24],
[ 77, 81, 20]],
[[ 71, 71, 17],
[ 73, 74, 17],
[ 77, 78, 20],
...,
[ 85, 86, 20],
[ 85, 85, 21],
[ 75, 74, 20]]], dtype=uint8)
任何帮助将不胜感激!