Ejemplo n.º 1
0
def data_unit(net, file_name):

    n, c, h, w = net.blobs["data"].data.shape

    plt.subplot(131)
    plt.title("Original Image")
    plt.axis("off")
    vu.visualize_one_channel_images(net.blobs["data"].data.reshape(n, h, w))

    plt.subplot(132)
    plt.title("ST Output")
    plt.axis("off")
    vu.visualize_one_channel_images(net.blobs["st_output"].data.reshape(n, h, w))

    plt.subplot(133)
    plt.axis("off")
    plt.title("Correctness")

    acc = np.zeros((n, h, w, 3))

    gt_label = net.blobs["label"].data
    est_label = np.argmax(net.blobs["class"].data, axis=1)
    err = est_label <> gt_label
    ind = np.array(range(n))[err]
    for i in ind:
        acc[i] = np.ones((h, w, 3))

    plt.imshow(vu.vis_grid(acc))
    plt.gca().axis("off")

    plt.savefig(file_name + ".jpg", dpi=1000)
    plt.close()
Ejemplo n.º 2
0
def data_unit(net, file_name):

	n, c, h, w = net.blobs['data'].data.shape

 	f = open(file_name+'.txt', 'w')

	plt.subplot(131)
	vu.visualize_one_channel_images(net.blobs['data'].data.reshape(n, h, w))

	plt.subplot(132)
	vu.visualize_one_channel_images(net.blobs['st_output'].data.reshape(n, h, w))

	plt.subplot(133)
	acc = np.zeros((n, h, w, 3))

	gt_label = net.blobs['label'].data
	est_label = np.argmax(net.blobs['class'].data, axis=1)
	err = (est_label <> gt_label)
	ind = np.array(range(n))[err]
	for i in ind:
		x = i/ceil(sqrt(n))
		y = i%ceil(sqrt(n))
		f.write('Digit at (%d, %d) should be %d, but is classified as %d\n'%(x, y, gt_label[i], est_label[i]))
		acc[i] = np.ones((h, w, 3))

	plt.imshow(vu.vis_grid(acc))
	plt.gca().axis('off')

	plt.savefig(file_name+'.jpg', dpi = 100)
	plt.close()
Ejemplo n.º 3
0
def data_unit(net, file_name):

	n, c, h, w = net.blobs['data'].data.shape

	plt.subplot(131)
        plt.title('Original Image')
        plt.axis('off')
	vu.visualize_one_channel_images(net.blobs['data'].data.reshape(n, h, w))

	plt.subplot(132)
        plt.title('ST Output')
        plt.axis('off')
	vu.visualize_one_channel_images(net.blobs['st_output'].data.reshape(n, h, w))

	plt.subplot(133)
        plt.axis('off')
        plt.title('Correctness')

	acc = np.zeros((n, h, w, 3))

	gt_label = net.blobs['label'].data
	est_label = np.argmax(net.blobs['class'].data, axis=1)
	err = (est_label <> gt_label)
        ind = np.array(range(n))[err]
	for i in ind:
		acc[i] = np.ones((h, w, 3))

	plt.imshow(vu.vis_grid(acc))
	plt.gca().axis('off')

	plt.savefig(file_name+'.jpg', dpi = 1000)
        plt.close()