def main():
    tl.check_arguments(sys.argv, 1, "You have to specify settings file!\n./classify.py settings_file")
    settings_filename = sys.argv[1]
    settings = tl.load_settings(settings_filename)

    caffe_prototxt = settings["caffe_prototxt"]
    caffe_model    = settings["caffe_model"]
    test_list      = settings["test_list"]

    caffe.set_mode_gpu()
    net = caffe.Net(caffe_prototxt, caffe_model, caffe.TEST)
    transformer = create_transformer(net)

    img_test_names, img_test_labels = tl.read_img_names_from_csv(test_list,
                                                                 skip_header=False,
                                                                 delimiter=',')

    submission_file, confusion_matrix, accuracy = classify_images(net,
                                                                  transformer,
                                                                  img_test_names,
                                                                  img_test_labels,
                                                                  settings)

    if (settings["print_csv"]):
        print "Results written to " + submission_file

    print "Accuracy: " + str(accuracy)

    # Confusion matrix
    if (settings["conf_matrix"]):
        plt.figure(figsize=(2,2), dpi=200)
        plt.clf()
        plt.imshow(confusion_matrix, norm=LogNorm())
        #plt.colorbar()
        plt.savefig(settings["conf_matrix_path"])
def main():
    tl.check_arguments(sys.argv, 1, "You have to specify settings file!\n./train.py settings_file")

    settings_filename = sys.argv[1]
    settings = tl.load_settings(settings_filename)

    train_id = tl.generate_unique_id()
    settings = modify_solver(train_id, settings)

    caffe_stream = io.StringIO()
    with tl.redirect_caffe_log(caffe_stream): 
        caffe.set_mode_gpu()
        prepare_data(settings)
        solver = prepare_model(settings)
        train_loss, duration, iteration = train_model(solver, settings)

    log(solver, train_loss, duration, iteration, caffe_stream, settings)