我用 Keras 训练了一个模型来执行具有 0 和 1 标签的二元分类任务,并在一系列图像上对其进行了测试。其中一些图像非常相似,并且被预测为 1,所以我想知道有没有办法设置一些阈值或分数来整理出 Keras 中最有可能为 1 的图像?
如果您正在执行语义分割,则执行以下方法
执行
image = model.predict(your_input_image)
_,height,width,_ = image.shape()
image = image.reshape(height,width)
image[image >= threshold_percentage] = 255
image[image < threshold_percentage] = 0
如果正常的二进制
result = model.predict(your_input_image)
if result[0][1] > threshold_percentage:
#belongs to class 1
else:
#belongs to class 2