超级简单的问题。
我正在关注本教程: https://github.com/tensorflow/hub/blob/master/examples/colab/tf2_image_retraining.ipynb
我已按照说明(而非可选部分)训练了模型,并使用tf.saved_model.save
保存了该模型。现在,我要对新图片运行模型。我该怎么做?
我尝试了以下操作:
loaded = tf.saved_model.load("/tmp/saved_flowers_model")
print(list(loaded.signatures.keys())) # ["serving_default"]
infer = loaded.signatures["serving_default"]
print(infer.structured_outputs)
file = .../pic.jpg
output = loaded (file)
返回以下错误:
ValueError: Could not find matching function to call loaded from the SavedModel. Got:
Positional arguments (3 total):
* /Users/dansafdie/Documents/Code Repos/Image Classifier/flower_photos/daisy/19834392829_7d697871f6.jpg
* False
* None
Keyword arguments: {}
Expected these arguments to match one of the following 4 option(s):
Option 1:
Positional arguments (3 total):
* TensorSpec(shape=(None, 224, 224, 3), dtype=tf.float32, name='inputs')
* True
* None
Keyword arguments: {}
Option 2:
Positional arguments (3 total):
* TensorSpec(shape=(None, 224, 224, 3), dtype=tf.float32, name='inputs')
* False
* None
Keyword arguments: {}
Option 3:
Positional arguments (3 total):
* TensorSpec(shape=(None, 224, 224, 3), dtype=tf.float32, name='input_1')
* False
* None
Keyword arguments: {}
Option 4:
Positional arguments (3 total):
* TensorSpec(shape=(None, 224, 224, 3), dtype=tf.float32, name='input_1')
* True
* None
Keyword arguments: {}