Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python hub.get\预期的\图像\大小生成错误_Python_Tensorflow_Tensorflow Hub - Fatal编程技术网

Python hub.get\预期的\图像\大小生成错误

Python hub.get\预期的\图像\大小生成错误,python,tensorflow,tensorflow-hub,Python,Tensorflow,Tensorflow Hub,我试图通过tensorflow分类器模型确定预期的图像大小。从 这是通过 image_module = hub.Module('https://tfhub.dev/google/imagenet/mobilenet_v2_035_128/feature_vector/2') image_size = hub.get_expected_image_size(image_module) 我正在尝试一个本地定位的模型imagenet/inception/resnet/v2/classi

我试图通过tensorflow分类器模型确定预期的图像大小。从

这是通过

   image_module = hub.Module('https://tfhub.dev/google/imagenet/mobilenet_v2_035_128/feature_vector/2')
   image_size = hub.get_expected_image_size(image_module)
我正在尝试一个本地定位的模型imagenet/inception/resnet/v2/classification/4。我的代码是

    export_path = "/home/adi/Desktop/oni/tensor_flow/tf_model_clas/imagenet_inception_resnet_v2_classification_4/"
    module_spec = hub.load_module_spec(export_path)
    height, width = hub.get_expected_image_size(model_spec)
    print(height,width)
使用此代码,我得到以下错误

Traceback (most recent call last):
  File "./evaluate_models_class.py", line 203, in <module>
    height, width = hub.get_expected_image_size(classifier_model)
  File "/home/adi/.local/lib/python3.7/site-packages/tensorflow_hub/image_util.py", line 77, in get_expected_image_size
    image_module_info = get_image_module_info(module_or_spec)
  File "/home/adi/.local/lib/python3.7/site-packages/tensorflow_hub/image_util.py", line 54, in get_image_module_info
    return module_or_spec.get_attached_message(
AttributeError: '_UserObject' object has no attribute 'get_attached_message'

我做错了什么?

hub.get\u expected\u image\u size仅适用于以某种方式导出的hub.Module格式的某些模型,此函数不适用于TF2 SavedModels

    classifier_model = keras.models.load_model(export_path)
    classifier = tf.keras.Sequential([hub.KerasLayer(classifier_model)])