Ejemplo n.º 1
0
def evaluate_single_image(model, img_path, cfg):
    """
    Computes detection results for the given model on the provided image
    :param model: the model
    :param img_path: the path to the image
    :param cfg: the configuration
    :return:
        regressed_rois - the predicted bounding boxes
        cls_probs - class probabilities per bounding box
    """

    detector_name = _get_detector_name(cfg)
    regressed_rois = None
    cls_probs = None
    print("detecting objects in image {}".format(img_path))
    if detector_name == 'FastRCNN':
        from FastRCNN.FastRCNN_eval import FastRCNN_Evaluator
        evaluator = FastRCNN_Evaluator(model, cfg)
        regressed_rois, cls_probs = evaluator.process_image(img_path)
    elif detector_name == 'FasterRCNN':
        from FasterRCNN.FasterRCNN_eval import FasterRCNN_Evaluator
        evaluator = FasterRCNN_Evaluator(model, cfg)
        regressed_rois, cls_probs = evaluator.process_image(img_path)
    else:
        print('Unknown detector: {}'.format(detector_name))

    return regressed_rois, cls_probs
Ejemplo n.º 2
0
def evaluate_single_image(model, img_path, cfg):
    """
    Computes detection results for the given model on the provided image
    :param model: the model
    :param img_path: the path to the image
    :param cfg: the configuration
    :return:
        regressed_rois - the predicted bounding boxes
        cls_probs - class probabilities per bounding box
    """

    detector_name = _get_detector_name(cfg)
    regressed_rois = None
    cls_probs = None
    print("detecting objects in image {}".format(img_path))
    if detector_name == 'FastRCNN':
        from FastRCNN.FastRCNN_eval import FastRCNN_Evaluator
        evaluator = FastRCNN_Evaluator(model, cfg)
        regressed_rois, cls_probs = evaluator.process_image(img_path)
    elif detector_name == 'FasterRCNN':
        from FasterRCNN.FasterRCNN_eval import FasterRCNN_Evaluator
        evaluator = FasterRCNN_Evaluator(model, cfg)
        regressed_rois, cls_probs = evaluator.process_image(img_path)
    else:
        print('Unknown detector: {}'.format(detector_name))

    return regressed_rois, cls_probs
Ejemplo n.º 3
0
def measure_inference_time(model, img_path, cfg, num_repetitions=100):
    """
    Computes detection results for the given model on the provided image
    :param model: the model
    :param img_path: the path to the image
    :param cfg: the configuration
    :return:
        regressed_rois - the predicted bounding boxes
        cls_probs - class probabilities per bounding box
    """

    detector_name = _get_detector_name(cfg)
    print(
        "Measuring inference time (seconds per image) as average over {} runs".
        format(num_repetitions))
    if detector_name == 'FastRCNN':
        from FastRCNN.FastRCNN_eval import FastRCNN_Evaluator
        evaluator = FastRCNN_Evaluator(model, cfg)
    elif detector_name == 'FasterRCNN':
        from FasterRCNN.FasterRCNN_eval import FasterRCNN_Evaluator
        evaluator = FasterRCNN_Evaluator(model, cfg)
    else:
        print('Unknown detector: {}'.format(detector_name))
        return

    from time import time
    start = time()
    for i in range(num_repetitions):
        _, _ = evaluator.process_image(img_path)
    total = time() - start
    print("seconds per image: {:2f} (total for {} images: {:2f})".format(
        total / num_repetitions, num_repetitions, total))
Ejemplo n.º 4
0
def measure_inference_time(model, img_path, cfg, num_repetitions=100):
    """
    Computes detection results for the given model on the provided image
    :param model: the model
    :param img_path: the path to the image
    :param cfg: the configuration
    :return:
        regressed_rois - the predicted bounding boxes
        cls_probs - class probabilities per bounding box
    """

    detector_name = _get_detector_name(cfg)
    print("Measuring inference time (seconds per image) as average over {} runs".format(num_repetitions))
    if detector_name == 'FastRCNN':
        from FastRCNN.FastRCNN_eval import FastRCNN_Evaluator
        evaluator = FastRCNN_Evaluator(model, cfg)
    elif detector_name == 'FasterRCNN':
        from FasterRCNN.FasterRCNN_eval import FasterRCNN_Evaluator
        evaluator = FasterRCNN_Evaluator(model, cfg)
    else:
        print('Unknown detector: {}'.format(detector_name))
        return

    from time import time
    start = time()
    for i in range(num_repetitions):
        _,_ = evaluator.process_image(img_path)
    total = time() - start
    print("seconds per image: {:2f} (total for {} images: {:2f})".format(total/num_repetitions, num_repetitions, total))