Beispiel #1
0
def data_unit(net, file_name):

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

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

    plt.subplot(121)
    plt.title('Original Image')
    plt.axis('off')
    vu.vis_square(net.blobs['downsampled_data'].data.transpose(0, 2, 3, 1))

    plt.subplot(122)
    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['final/res'].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('Bird 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=1000)
    plt.close()
Beispiel #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(121)
        plt.title('Original Image')
        plt.axis('off')
	vu.vis_square(net.blobs['downsampled_data'].data.transpose(0, 2, 3, 1))

	plt.subplot(122)
        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['final/res'].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('Bird 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 = 1000)
	plt.close()
Beispiel #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.vis_square(net.blobs['data'].data.transpose(0, 2, 3, 1))

	plt.subplot(132)
        plt.title('Mask_output')
        plt.axis('off')
	vu.vis_square(net.blobs['mask_output'].data.transpose(0, 2, 3, 1))

	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['loss3/classifier'].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()
Beispiel #4
0
def draw(data_inc1, data_inc2, file_name):
    plt.subplot(1, 2, 1)
    plt.title('data_inc1')
    vu.vis_square(data_inc1.transpose(0, 2, 3, 1))
    plt.subplot(1, 2, 2)
    plt.title('data_inc2')
    vu.vis_square(data_inc2.transpose(0, 2, 3, 1))
    plt.savefig(file_name)
    plt.close()
Beispiel #5
0
def data_unit(net, file_name):

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

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

    plt.subplot(221)
    plt.title("Original Image")
    plt.axis("off")
    vu.vis_square(net.blobs["downsampled_data"].data.transpose(0, 2, 3, 1))

    plt.subplot(223)
    plt.title("Inc1/data")
    plt.axis("off")
    print net.blobs["st/theta_1"].data
    vu.vis_square(net.blobs["inc1/data"].data.transpose(0, 2, 3, 1))

    plt.subplot(224)
    plt.title("Inc2/data")
    plt.axis("off")
    print net.blobs["st/theta_2"].data
    vu.vis_square(net.blobs["inc2/data"].data.transpose(0, 2, 3, 1))

    plt.subplot(222)
    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["final/res"].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("Bird 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=1000)
    plt.close()
Beispiel #6
0
def data_unit(net, file_name):

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

	plt.subplot(221)
        plt.title('Original Image')
        plt.axis('off')
	vu.vis_square(net.blobs['data'].data.transpose(0, 2, 3, 1))

	plt.subplot(223)
        plt.title('Inc1/data')
        plt.axis('off')
	vu.vis_square(net.blobs['inc1/data'].data.transpose(0, 2, 3, 1))

	plt.subplot(224)
        plt.title('Inc2/data')
        plt.axis('off')
	vu.vis_square(net.blobs['inc2/data'].data.transpose(0, 2, 3, 1))

	plt.subplot(222)
        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['final/res'].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')
        plt.close()