depre_predictions用于根据ImageNet数据集中具有1000个类别的类别标签对模型的预测进行解码。但是,您经过微调的模型只有12个类。因此,
depre_predictions在这里使用没有意义。当然,您必须知道这12个类别的标签是什么。因此,只需在预测中取最大分数的索引并找到其标签即可:
# create a list containing the class labelsclass_labels = ['class1', 'class2', 'class3', ...., 'class12']# find the index of the class with maximum scorepred = np.argmax(class_labels, axis=-1)# print the label of the class with maximum scoreprint(class_labels[pred[0]])



