您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

无法在Keras中使用VGG19预测单个图像的标签

无法在Keras中使用VGG19预测单个图像的标签

decode_predictions用于根据ImageNet数据集中具有1000个类别的类别标签对模型的预测进行解码。但是,您经过微调的模型只有12个类。因此,decode_predictions在这里使用没有意义。当然,您必须知道这12个类别的标签是什么。因此,只需在预测中取最大分数的索引并找到其标签即可:

# create a list containing the class labels
class_labels = ['class1', 'class2', 'class3', ...., 'class12']

# find the index of the class with maximum score
pred = np.argmax(class_labels, axis=-1)

# print the label of the class with maximum score
print(class_labels[pred[0]])
其他 2022/1/1 18:29:51 有390人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶