Exemplo n.º 1
0
def index():
    """
    Index images
    """
    logging.info(
        "Starting with images present in {} storing index in {}".format(
            DATA_PATH, INDEX_PATH))
    try:
        os.mkdir(INDEX_PATH)
    except:
        print "Could not created {}, if its on /mnt/ have you set correct permissions?".format(
            INDEX_PATH)
        raise ValueError
    inception.load_network()
    count = 0
    start = time.time()
    with inception.tf.Session() as sess:
        for image_data in inception.get_batch(DATA_PATH):
            logging.info("Batch with {} images loaded in {} seconds".format(
                len(image_data),
                time.time() - start))
            start = time.time()
            count += 1
            features, files = inception.extract_features(image_data, sess)
            logging.info("Batch with {} images processed in {} seconds".format(
                len(features),
                time.time() - start))
            start = time.time()
            inception.store_index(features, files, count, INDEX_PATH)
Exemplo n.º 2
0
def test():
    inception.load_network()
    count = 0
    start = time.time()
    test_images = os.path.join(os.path.dirname(__file__), 'tests/images')
    test_index = os.path.join(os.path.dirname(__file__), 'tests/index')
    try:
        shutil.rmtree(test_index)
    except:
        pass
    os.mkdir(test_index)
    with inception.tf.Session() as sess:
        for image_data in inception.get_batch(test_images, batch_size=2):
            # batch size is set to 2 to distinguish between latency associated with first batch
            if len(image_data):
                print "Batch with {} images loaded in {} seconds".format(
                    len(image_data),
                    time.time() - start)
                start = time.time()
                count += 1
                features, files = inception.extract_features(image_data, sess)
                print "Batch with {} images processed in {} seconds".format(
                    len(features),
                    time.time() - start)
                start = time.time()
                inception.store_index(features, files, count, test_index)
Exemplo n.º 3
0
def index():
    """
    Index images
    """
    inception.load_network()
    count = 0
    start = time.time()
    with inception.tf.Session() as sess:
        for image_data in inception.get_batch():
            logging.info("Batch with {} images loaded in {} seconds".format(len(image_data), time.time() - start))
            start = time.time()
            count += 1
            features, files = inception.extract_features(image_data, sess)
            logging.info("Batch with {} images processed in {} seconds".format(len(features), time.time() - start))
            start = time.time()
            inception.store_index(features, files, count)
Exemplo n.º 4
0
def index():
    """
    Index images
    """
    logging.info("Starting with images present in {} storing index in {}".format(DATA_PATH,INDEX_PATH))
    try:
        os.mkdir(INDEX_PATH)
    except:
        print "Could not created {}, if its on /mnt/ have you set correct permissions?".format(INDEX_PATH)
        raise ValueError
    inception.load_network()
    count = 0
    start = time.time()
    with inception.tf.Session() as sess:
        for image_data in inception.get_batch(DATA_PATH):
            logging.info("Batch with {} images loaded in {} seconds".format(len(image_data),time.time()-start))
            start = time.time()
            count += 1
            features,files = inception.extract_features(image_data,sess)
            logging.info("Batch with {} images processed in {} seconds".format(len(features),time.time()-start))
            start = time.time()
            inception.store_index(features,files,count,INDEX_PATH)