我不太懂英语,所以可能写得很笨拙。 我的自定义代码在识别时出错。我试图更改分析方法和文件位置。但没有任何帮助。我不是一个超级程序员,所以我真的不明白代码深处发生了什么。我也不太明白输出图像应该保存在哪里,它将被称为什么。 程序代码:
from imageai.Prediction.Custom import CustomImagePrediction
import os
execution_path = os.getcwd()
prediction = CustomImagePrediction()
prediction.setModelTypeAsSqueezeNet()
prediction.setModelPath(os.path.join(execution_path, "model_ex-065_acc-0.875000.h5"))
prediction.setJsonPath(os.path.join(execution_path, "model_class.json"))
prediction.loadModel(num_objects=4)
predictions, probabilities = prediction.predictImage(os.path.join(execution_path, "ScreenHack.jpg"), result_count=5)
for eachPrediction, eachProbability in zip(predictions, probabilities):
print(eachPrediction , " : " , eachProbability)
错误文本:
ValueError: Shapes (1, 1, 512, 4) and (2, 512, 1, 1) are incompatible
将所有值相乘可获得的实际元素数,第一个值下注2048,第二个值仅下注1024。这就是它无法重塑的原因
相关问题 更多 >
编程相关推荐