def test_smart_image_io(plot = False): image = smart_load('https://raw.githubusercontent.com/petered/data/master/images/artemis.jpeg', use_cache=True) smart_save(image[:, ::-1, :], 'output/simetra.png') rev_image = smart_load('output/simetra.png') assert np.array_equal(rev_image, rev_image) if plot: from artemis.plotting.db_plotting import dbplot dbplot(image, 'Artemis') dbplot(rev_image, 'Simetra', hang=True)
def test_smart_image_io(plot=False): image = smart_load( 'https://raw.githubusercontent.com/petered/data/master/images/artemis.jpeg', use_cache=True) smart_save(image[:, ::-1, :], 'output/simetra.png') rev_image = smart_load('output/simetra.png') assert np.array_equal(rev_image, rev_image) if plot: from artemis.plotting.db_plotting import dbplot dbplot(image, 'Artemis') dbplot(rev_image, 'Simetra', hang=True)
def get_imagenet_images(indices): """ Get imagenet images at the given indices :param indices: :return: """ highest_index = np.max(indices) code_url_pairs = get_imagenet_fall11_urls(highest_index+1) files = [get_file('data/imagenet/%s%s' % (code_url_pairs[index][0], os.path.splitext(code_url_pairs[index][1])[1]), code_url_pairs[index][1]) for index in indices] return [smart_load(f) for f in files]
def classify(f, im_path): im = smart_load(im_path) print 'Processing image... "%s"' % (im_path, ) inputs = im2vgginput(im) out = f(inputs) amax = np.argmax(out[0]) label = get_vgg_label_at(amax) print 'Done.' dbplot(np.rollaxis(inputs[0], 0, 3)[..., ::-1], 'Photo', title="{label}: {pct}%".format(label=label, pct=out[0, amax, 0, 0] * 100))