小编Dom*_*nik的帖子

运行object_detection_tutorial TypeError的问题:load()缺少2个必需的位置参数

我对tensorflow非常陌生,并且正在尝试运行object_detection_tutorial。我收到TypeErrror,不知道如何解决。

这是load_model函数,它缺少2个参数:

标签:一组字符串标签,用于标识所需的MetaGraphDef。这些应该与使用SavedModel save()API保存变量时使用的标签相对应。

export_dir:SavedModel协议缓冲区和要加载的变量所在的目录。

def load_model(model_name):
  base_url = 'http://download.tensorflow.org/models/object_detection/'
  model_file = model_name + '.tar.gz'
  model_dir = tf.keras.utils.get_file(
    fname=model_name, 
    origin=base_url + model_file,
    untar=True)

  model_dir = pathlib.Path(model_dir)/"saved_model"

  model = tf.saved_model.load(str(model_dir))
  model = model.signatures['serving_default']

  return model
Run Code Online (Sandbox Code Playgroud)
WARNING:tensorflow:From <ipython-input-9-f8a3c92a04a4>:11: load (from tensorflow.python.saved_model.loader_impl) is deprecated and will be removed in a future version.
Instructions for updating:
This function will only be available through the v1 compatibility library as tf.compat.v1.saved_model.loader.load or tf.compat.v1.saved_model.load. There will be a new function for importing SavedModels in Tensorflow 2.0.

--------------------------------------------------------------------------- …
Run Code Online (Sandbox Code Playgroud)

tensorflow

5
推荐指数
1
解决办法
621
查看次数

标签 统计

tensorflow ×1