def benchmark(config):
    """Computes and stores predictions and then
    evaluates them on COCO metrics and supplementary benchmarking script."""

    print("Benchmarking Baseline method {}.".format(
        config["detector"]["type"]))

    # Create new directory for run outputs
    # In what location should we put this new directory?
    output_dir = config["output_dir"]
    mkdir_if_missing(output_dir)

    # Save config in run directory
    config.save(os.path.join(output_dir, config["save_conf_name"]))

    # directory of test images and segmasks
    detector_type = config["detector"]["type"]
    if detector_type == "euclidean" or detector_type == "region_growing":
        from sd_maskrcnn.pcl.pydetect import detect
    elif detector_type == "gop" or detector_type == "mcg":
        from sd_maskrcnn.gop.detect import detect
    else:
        print("Detector type not supported")
        exit()

    # Create predictions and record where everything gets stored.
    pred_mask_dir, pred_info_dir, gt_mask_dir = detect(
        detector_type,
        config["detector"][detector_type],
        output_dir,
        config["dataset"],
    )

    ap, ar = coco_benchmark(pred_mask_dir, pred_info_dir, gt_mask_dir)
    if config["vis"]["predictions"]:
        visualize_predictions(
            output_dir,
            config["dataset"],
            pred_mask_dir,
            pred_info_dir,
            show_bbox=config["vis"]["show_bbox_pred"],
            show_class=config["vis"]["show_class_pred"],
        )
    if config["vis"]["s_bench"]:
        s_benchmark(
            output_dir,
            config["dataset"],
            pred_mask_dir,
            pred_info_dir,
            gt_mask_dir,
        )

    print("Saved benchmarking output to {}.\n".format(output_dir))
    return ap, ar
Beispiel #2
0
def benchmark(config):
    """Computes and stores predictions and then
    evaluates them on COCO metrics and supplementary benchmarking script."""

    print("Benchmarking Baseline method {}.".format(
        config['detector']['type']))

    # Create new directory for run outputs
    # In what location should we put this new directory?
    output_dir = config['output_dir']
    mkdir_if_missing(output_dir)

    # Save config in run directory
    config.save(os.path.join(output_dir, config['save_conf_name']))

    # directory of test images and segmasks
    detector_type = config['detector']['type']
    if detector_type == 'euclidean' or detector_type == 'region_growing':
        from sd_maskrcnn.pcl.pydetect import detect
    elif detector_type == 'gop' or detector_type == 'mcg':
        from sd_maskrcnn.gop.detect import detect
    else:
        print('Detector type not supported')
        exit()

    # Create predictions and record where everything gets stored.
    pred_mask_dir, pred_info_dir, gt_mask_dir = \
        detect(detector_type, config['detector'][detector_type], output_dir, config['dataset'])

    ap, ar = coco_benchmark(pred_mask_dir, pred_info_dir, gt_mask_dir)
    if config['vis']['predictions']:
        visualize_predictions(output_dir,
                              config['dataset'],
                              pred_mask_dir,
                              pred_info_dir,
                              show_bbox=config['vis']['show_bbox_pred'],
                              show_class=config['vis']['show_class_pred'])
    if config['vis']['s_bench']:
        s_benchmark(output_dir, config['dataset'], pred_mask_dir,
                    pred_info_dir, gt_mask_dir)

    print("Saved benchmarking output to {}.\n".format(output_dir))
    return ap, ar