def main():
    # TODO: Erase dummy net
    net = None
    """
    TODO: Comment in
    deploy_fpath = 'deploy.prototxt'
    model_fpath = 'model.protobinary'

    caffe.set_mode_gpu()
    net = caffe.Net(deploy_fpath, model_fpath, caffe.TEST)
    """

    bpath = '../yandere-crawler/illust/'

    code_db = []

    # TODO: For train.txt
    with open('./test.txt') as f:
        for line in f:
            preview_fpath, _ = line.rstrip().split(' ')
            preview_fpath = bpath + preview_fpath

            print preview_fpath

            # Make BGR 227x227 image
            data = util.load_image(preview_fpath)

            # Make code
            code = util.make_code(net, data)

            code_db.append((code, preview_fpath))

    with open('./code_db.pickle', 'wb') as f:
        pickle.dump(code_db, f)
def main():
    # TODO: Erase dummy net
    net = None
    """
    TODO: Comment in
    deploy_fpath = 'deploy.prototxt'
    model_fpath = 'model.protobinary'

    caffe.set_mode_gpu()
    net = caffe.Net(deploy_fpath, model_fpath, caffe.TEST)
    """

    preview_fpath = '../yandere-crawler/illust/preview/335/335201.jpg'
    code_db_fpath = './code_db.pickle'

    code_db = []
    with open(code_db_fpath, 'rb') as f:
        code_db = pickle.load(f)

    data = util.load_image(preview_fpath)
    code = util.make_code(net, data)

    result = search(code_db, code, 5)
    print result