【问题标题】:Output mismatch with Landmarks Classification Model North America on TensorFlow Hub输出与 TensorFlow Hub 上的北美地标分类模型不匹配
【发布时间】:2021-03-23 20:17:57
【问题描述】:

我正在尝试从 tensorflow hub 加载预训练模型(链接:https://tfhub.dev/google/on_device_vision/classifier/landmarks_classifier_north_america_V1/1)。当我对单个图像进行推理时,我得到长度为 99424 的输出,但相应的标签图的长度为 99676。这对我来说没有任何意义,因为两者的长度应该是相同的长度。由于这个错误,模型无法准确分类。有没有其他人有同样的错误。如果没有,任何指导将不胜感激。

import tensorflow.compat.v2 as tf
import tensorflow_hub as hub

model = hub.KerasLayer(model_url, output_key='predictions:logits')
landmarks = pd.read_csv(landmark_file)
image = load_image(im_path) # (321, 321, 3) scaled between [0,1]
output = model(image)
prediction = landmarks['name'][int(tf.math.argmax(output, 1))]

另外,加载模型时出现此错误:

INFO:tensorflow:Saver not created because there are no variables in the graph to restore

我觉得是 tensorflow hub 的模型有问题,但不完全确定

【问题讨论】:

    标签: tensorflow tensorflow-hub


    【解决方案1】:

    自 2021 年 3 月 18 日起,标签映射中的不一致问题已得到修复。您只需重新下载 labelmap 文件,这些文件可从tfhub.dev 的模型页面中引用。希望对您有所帮助,不便之处敬请见谅!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-09
      • 2019-04-28
      • 2019-10-19
      • 1970-01-01
      • 2021-03-21
      • 2020-04-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多