我下载了这个 API 并按照他们的建议使用了 TensorFlow 1.15,但无论我做什么,我都会收到这个错误
这是给我错误的代码
model_name = 'ssd_mobilenet_v1_coco_2017_11_17'
detection_model = load_model(model_name)
问题的原因似乎是函数 load_model
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
因此,我确实尝试使用此页面上的解决方案添加参数:Problem with running object_detection_tutorial TypeError: load() missing 2 required positional arguments
当我应用修复程序时(在我的稀疏知识中)这是代码:
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.compat.v1.saved_model.load(str(model_dir),None)**#change i made**
model = model.signatures['serving_default']
return model
新的错误不断出现,例如:
<ipython-input-23-e10c73a22cc9> in <module>
1 model_name = 'ssd_mobilenet_v1_coco_2017_11_17'
----> 2 detection_model = load_model(model_name)
<ipython-input-20-11f71129951a> in load_model(model_name)
9 model_dir = pathlib.Path(model_dir)/"saved_model"
10
---> 11 model = tf.compat.v1.saved_model.load(str(model_dir),None)
12 model = model.signatures['serving_default']
13
D:\Anaconda\envs\work\lib\site-packages\tensorflow_core\python\util\deprecation.py in new_func(*args, **kwargs)
322 'in a future version' if date is None else ('after %s' % date),
323 instructions)
--> 324 return func(*args, **kwargs)
325 return tf_decorator.make_decorator(
326 func, new_func, 'deprecated',
TypeError: load() missing 1 required positional argument: 'export_dir'
任何帮助表示赞赏,非常感谢。