import numpy as np
from keras import backend
from PIL import Image

a = np.array([0,255,255,0,255,0,0,255,0,0])
print(a)
print(a.shape)
b = np.array([0,255,0,0,255,0,0,255,0,0])
c = a.flatten()
d = a.flatten()
print(c.shape)
print(c)

#方法一:
b[b==255]=1  
# print(b)

#方法二:
for i, ele in enumerate(a):
    if ele  == 255:
        a[i] = 1

print(c)
print(a)
print(b)

简单记录一下,在计算MIOU的时候,像素为二值像素,像素值为255的标签为第一类,在混淆矩阵的时候,需要将255像素改成1像素,和预测标签进行计算对角线上的分类正确的像素点

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐