def test_cache(): c = Cache(verbose=True, refetch=False) print '[test_cache]: putting and retrieving an object from cache' obj = np.random.rand(2,2) filename = c.put(obj) assert_array_equal(obj, c.get(filename)) assert_array_equal(obj, c[filename]) # keys print '[test_cache]: download an image and retrieve from cache' imshow(c.get('http://upload.wikimedia.org/wikipedia/commons/3/39/Athene_noctua_(cropped).jpg')) imshow(c.get('http://upload.wikimedia.org/wikipedia/commons/3/39/Athene_noctua_(cropped).jpg')) print '[test_cache]: download archive with item fragment' imshow(c.get('http://l2r.cs.uiuc.edu/~cogcomp/Data/Car/CarData.tar.gz#subpath=CarData/TrainImages/pos-1.pgm')) imshow(c.get('http://l2r.cs.uiuc.edu/~cogcomp/Data/Car/CarData.tar.gz#subpath=CarData/TrainImages/pos-2.pgm')) imshow(c.get('http://l2r.cs.uiuc.edu/~cogcomp/Data/Car/CarData.tar.gz#subpath=CarData/TrainImages/pos-3.pgm')) try: c.get('http://l2r.cs.uiuc.edu/~cogcomp/Data/Car/CarData.tar.gz#subpath=wrong_path') except: print 'incorrect URL fragment raises exception correctly' print '[test_cache]: size of cache in bytes' print c.size()
def main(): dbfile = LabelMe3().export(verbose=True) db = Viset(dbfile, verbose=True) for (im) in db.image: #print 'Image=' + str(annotation['id_img']) + ' Category=' + annotation['category'] if im is not None: imshow(im)
from viset.library.imagedir import ImageDir from viset.dataset import Viset from viset.show import imshow import sys if __name__ == '__main__': """Create imageviset from directory of images. First argument is database name, second argument is image directory""" dbname = sys.argv[1] imdir = sys.argv[2] print '[viset.demo_imagedir]: Creating viset "%s" ' % dbname print '[viset.demo_imagedir]: Reading images from directory = %s' % imdir dbfile = ImageDir().export(dbname, imdir, verbose=True) db = Viset(dbfile, verbose=True) for im in db.image: imshow(im)
def main(): for (im,annotation) in Recognition(caltech256.export()): imshow(im.get(), title=annotation)
def main(): filename = sys.argv[1] for (im,annotation) in Recognition(filename): imshow(im.get(), title=annotation)
def main(): dbfile = PascalVOC2012().export(verbose=True) db = Viset(dbfile, verbose=True) for (im,annotation) in db.annotation.categorization(step=10): print 'Image=' + str(annotation['idx_image']) + ' Category=' + annotation['category'] imshow(im, title=annotation['category'])