In [1]:
import numpy as np
import matplotlib.pyplot as plt
import time
%matplotlib inline

# Make sure that caffe is on the python path:
caffe_root = '/afs/ee.cooper.edu/user/t/a/tam8/documents/caffe/'  # this file is expected to be in {caffe_root}/examples
import sys
sys.path.insert(0, caffe_root + 'python')

import caffe

# Set the right path to your model definition file, pretrained model weights,
# and the image you would like to classify.
MODEL_FILE = './deploy_lb.prototxt'
# PRETRAINED = './models/caffenet_train_iter_30000.caffemodel'
PRETRAINED = './models/lb65_iter_100000.caffemodel'
MEAN_FILE = './data/64x64/ndsb_mean_test.npy'
# IMAGE_FILE = '/afs/ee.cooper.edu/user/t/a/tam8/data/ndsb/train/acantharia_protist/100224.jpg'
TEST_FILE = './data/test_final.txt'

In [2]:
caffe.set_phase_test()
caffe.set_mode_gpu()
net = caffe.Classifier(MODEL_FILE, PRETRAINED,
                       mean=np.load(MEAN_FILE),
                       raw_scale=255,
                       image_dims=(57, 57),
                       gpu=True)

In [7]:
# Loading test paths
test_doc = np.genfromtxt(TEST_FILE,dtype='str')
test_files = test_doc
# test_files = test_doc[:, 0]
# test_labels = test_doc[:, 1].astype(int)

In [8]:
start = time.time()
images = [caffe.io.load_image(im_path, color=False) for im_path in test_files]
print "Done in %.2f s." % (time.time() - start)

In [ ]:
start = time.time()
prediction = net.predict(images)
print "Done in %.2f s." % (time.time() - start)

In [2]:
import tools.submission as sub

sub.make_submission(test_files, prediction, f_name='SUBMISSION_lmdb.csv')