Esempio n. 1
0
            z = (z[0, 1, :, :] > z[0, 0, :, :]).float()

            for a, b in [(0, 0), (0, 1), (1, 0), (1, 1)]:
                cm[k][a][b] = torch.sum(
                    (z == a).float() * (y == b).float() * D)

            if True:
                nextI = len(os.listdir("build"))
                print(nextI)
                debug = digitanie.torchTOpil(globalresize(x))
                debug = PIL.Image.fromarray(numpy.uint8(debug))
                debug.save("build/" + str(nextI) + "_x.png")
                debug = (2.0 * y - 1) * D * 127 + 127
                debug = debug.cpu().numpy()
                debug = PIL.Image.fromarray(numpy.uint8(debug))
                debug.save("build/" + str(nextI) + "_y.png")
                debug = z.cpu().numpy() * 255
                debug = PIL.Image.fromarray(numpy.uint8(debug))
                debug.save("build/" + str(nextI) + "_z.png")

        print("perf=", digitanie.perf(cm[k]))
        print(cm[k])
        numpy.savetxt("build/tmp.txt", digitanie.perf(cm).cpu().numpy())

print("-------- summary ----------")
for k, city in enumerate(miniworld.cities):
    print(city, digitanie.perf(cm[k]))

cm = torch.sum(cm, dim=0)
print("digitanie", digitanie.perf(cm))
Esempio n. 2
0
            z = largeforward(net, x.unsqueeze(0))
            z = globalresize(z)
            z = (z[0, 1, :, :] > z[0, 0, :, :]).float()

            cm[k] += digitanie.confusion(y, z, size=size)

            if False:
                debug = digitanie.torchTOpil(globalresize(x))
                debug = PIL.Image.fromarray(numpy.uint8(debug))
                debug.save("build/" + city + str(i) + "_x.png")
                debug = y.float()
                debug = debug * 2 * (1 - digitanie.isborder(y, size=size))
                debug = debug + digitanie.isborder(y, size=size)
                debug *= 127
                debug = debug.cpu().numpy()
                debug = PIL.Image.fromarray(numpy.uint8(debug))
                debug.save("build/" + city + str(i) + "_y.png")
                debug = z.cpu().numpy() * 255
                debug = PIL.Image.fromarray(numpy.uint8(debug))
                debug.save("build/" + city + str(i) + "_z.png")

        print("perf=", digitanie.perf(cm[k]))

perfs = digitanie.perf(cm)
print("digitanie", perfs[-1])
print(perfs)
numpy.savetxt(name,
              numpy.int16(perfs.cpu().numpy() * 10),
              fmt="%i",
              delimiter="\t")