Python 根据get_input_详细信息,输入图像的数据类型是什么

Python 根据get_input_详细信息,输入图像的数据类型是什么,python,numpy,tensorflow,machine-learning,Python,Numpy,Tensorflow,Machine Learning,我在将图像输入模型时遇到问题 下面是获取\u输入\u详细信息输出的内容 [{'name': 'module/hub_input/images_uint8', 'index': 170, 'shape': array([ 1, 224, 224, 3], dtype=int32), 'shape_signature': array([ 1, 224, 224, 3], dtype=int32), 'dtype': <class 'numpy.uint8'>, 'quanti

我在将图像输入模型时遇到问题

下面是获取\u输入\u详细信息输出的内容

[{'name': 'module/hub_input/images_uint8', 'index': 170, 'shape': array([  1, 224, 224,   3], dtype=int32), 'shape_signature': array([  1, 224, 224,   3], dtype=int32), 'dtype': <class 'numpy.uint8'>, 'quantization': (0.0078125, 128), 'quantization_parameters': {'scales': array([0.0078125], dtype=float32), 'zero_points': array([128], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}]
之后,我传入图像并得到这个错误

ValueError:无法设置张量:获取了FLOAT32类型的值,但输入170应为UINT8类型,名称:module/hub\u input/images\u UINT8


你知道我哪里出错了吗?

这个错误与你输入的图像大小无关,我相信这是因为图像类型。您确定应该在0和1之间进行规格化吗?该错误似乎表明输入应为uint8类型。如果是这种情况,下面的代码应该可以工作

def process_image(image_path):
    image = Image.open(image_path)
    new_image = image.resize((224,224))
    np_image = asarray(new_image)
    np_image = np_image.astype('uint8')

    return [np_image]

嘿,@dmoloy。我对你的澄清感到沮丧和感激。我完全想得太多了,只是偏离了描述所说的,而不是后退一步,只是尝试它告诉我的。谢谢你的帮助!