def do_benchmark_test(args, model_file, weights_file, iterations=1000): """ Calc the accuracy on the lmdb dataset""" net = caffe.Net(model_file, weights_file, caffe.TEST) top1_total = 0 top5_total = 0 lmdb_data = datasets.LMDBData(args.dataset) lmdb_data.set_scale(SCALE) lmdb_data.set_crop_size(CROP_SIZE) if MEAN_FILE is not None: lmdb_data.set_mean_file(MEAN_FILE) else: lmdb_data.set_mean_value(MEAN_VALUE) for index in range(iterations): data, labels = lmdb_data.get_blobs(BATCH_SIZE) forward_kwargs = {MODEL_INPUT_BLOB_NAME: data} blobs_out = net.forward(**forward_kwargs) top1, top5 = img_postprocess(blobs_out[MODEL_OUTPUT_BLOB_NAME], labels) top1_total += top1 top5_total += top5 print('*****************iteration:{}******************'.format(index)) print('top1_acc:{}'.format(top1)) print('top5_acc:{}'.format(top5)) print('******final top1:{}'.format(top1_total / iterations)) print('******final top5:{}'.format(top5_total / iterations)) return top1_total / iterations, top5_total / iterations
def do_benchmark_test(model_file, weights_file, iterations=150): """ Calc the accuracy on the lmdb dataset""" model_file = os.path.realpath(model_file) weights_file = os.path.realpath(weights_file) net = caffe.Net(model_file, weights_file, caffe.TEST) top1_total = 0 lmdb_data = datasets.LMDBData(LMDB_DATASET_DIR) lmdb_data.set_scale(SCALE) for index in range(iterations): data, labels = lmdb_data.get_blobs(BATCH_SIZE) forward_kwargs = {MODEL_INPUT_BLOB_NAME: data} blobs_out = net.forward(**forward_kwargs) top1, _ = img_postprocess(blobs_out[MODEL_OUTPUT_BLOB_NAME], labels) top1_total += top1 print('*****************iteration:{}******************'.format(index)) print('top1_acc:{}'.format(top1)) print('******final top1:{}'.format(top1_total / iterations)) return top1_total / iterations