当前位置: 首页>>代码示例>>Python>>正文


Python COCOeval.evaluate方法代码示例

本文整理汇总了Python中pycocotools.cocoeval.COCOeval.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Python COCOeval.evaluate方法的具体用法?Python COCOeval.evaluate怎么用?Python COCOeval.evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pycocotools.cocoeval.COCOeval的用法示例。


在下文中一共展示了COCOeval.evaluate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _do_python_eval

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
 def _do_python_eval(self, _coco):
     coco_dt = _coco.loadRes(self._result_file)
     coco_eval = COCOeval(_coco, coco_dt)
     coco_eval.params.useSegm = False
     coco_eval.evaluate()
     coco_eval.accumulate()
     self._print_detection_metrics(coco_eval)
开发者ID:dpom,项目名称:incubator-mxnet,代码行数:9,代码来源:coco.py

示例2: evaluate

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
def evaluate():
    cocoGt = COCO('annotations.json')
    cocoDt = cocoGt.loadRes('detections.json')
    cocoEval = COCOeval(cocoGt, cocoDt, 'bbox')
    cocoEval.evaluate()
    cocoEval.accumulate()
    cocoEval.summarize()
开发者ID:cyberCBM,项目名称:DetectO,代码行数:9,代码来源:face_detector_accuracy.py

示例3: coco_evaluate

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
def coco_evaluate(json_dataset, res_file, image_ids):
    coco_dt = json_dataset.COCO.loadRes(str(res_file))
    coco_eval = COCOeval(json_dataset.COCO, coco_dt, 'bbox')
    coco_eval.params.imgIds = image_ids
    coco_eval.evaluate()
    coco_eval.accumulate()
    coco_eval.summarize()
    return coco_eval
开发者ID:ArsenLuca,项目名称:Detectron,代码行数:10,代码来源:test_retinanet.py

示例4: _do_keypoint_eval

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
def _do_keypoint_eval(json_dataset, res_file, output_dir):
    ann_type = 'keypoints'
    imgIds = json_dataset.COCO.getImgIds()
    imgIds.sort()
    coco_dt = json_dataset.COCO.loadRes(res_file)
    coco_eval = COCOeval(json_dataset.COCO, coco_dt, ann_type)
    coco_eval.params.imgIds = imgIds
    coco_eval.evaluate()
    coco_eval.accumulate()
    eval_file = os.path.join(output_dir, 'keypoint_results.pkl')
    robust_pickle_dump(coco_eval, eval_file)
    logger.info('Wrote json eval results to: {}'.format(eval_file))
    coco_eval.summarize()
开发者ID:TPNguyen,项目名称:DetectAndTrack,代码行数:15,代码来源:json_dataset_evaluator.py

示例5: _do_segmentation_eval

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
def _do_segmentation_eval(json_dataset, res_file, output_dir):
    coco_dt = json_dataset.COCO.loadRes(str(res_file))
    coco_eval = COCOeval(json_dataset.COCO, coco_dt, 'segm')
    coco_eval.evaluate()
    coco_eval.accumulate()
    _log_detection_eval_metrics(json_dataset, coco_eval)
    eval_file = os.path.join(output_dir, 'segmentation_results.pkl')
    robust_pickle_dump(coco_eval, eval_file)
    logger.info('Wrote json eval results to: {}'.format(eval_file))
开发者ID:TPNguyen,项目名称:DetectAndTrack,代码行数:11,代码来源:json_dataset_evaluator.py

示例6: _do_detection_eval

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
def _do_detection_eval(json_dataset, res_file, output_dir):
    coco_dt = json_dataset.COCO.loadRes(str(res_file))
    coco_eval = COCOeval(json_dataset.COCO, coco_dt, 'bbox')
    coco_eval.evaluate()
    coco_eval.accumulate()
    _log_detection_eval_metrics(json_dataset, coco_eval)
    eval_file = os.path.join(output_dir, 'detection_results.pkl')
    save_object(coco_eval, eval_file)
    logger.info('Wrote json eval results to: {}'.format(eval_file))
    return coco_eval
开发者ID:zymale,项目名称:Detectron,代码行数:12,代码来源:json_dataset_evaluator.py

示例7: cocoval

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
def cocoval(detected_json):
    eval_json = config.eval_json
    eval_gt = COCO(eval_json)

    eval_dt = eval_gt.loadRes(detected_json)
    cocoEval = COCOeval(eval_gt, eval_dt, iouType='bbox')

    # cocoEval.params.imgIds = eval_gt.getImgIds()
    cocoEval.evaluate()
    cocoEval.accumulate()
    cocoEval.summarize()
开发者ID:Zumbalamambo,项目名称:light_head_rcnn,代码行数:13,代码来源:cocoval.py

示例8: compute_ap

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
    def compute_ap(self):
        coco_res = self.loader.coco.loadRes(self.filename)

        cocoEval = COCOeval(self.loader.coco, coco_res)
        cocoEval.params.imgIds = self.loader.get_filenames()
        cocoEval.params.useSegm = False

        cocoEval.evaluate()
        cocoEval.accumulate()
        cocoEval.summarize()
        return cocoEval
开发者ID:heidongxianhau,项目名称:blitznet,代码行数:13,代码来源:evaluation.py

示例9: _do_coco_eval

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
 def _do_coco_eval(self, dtFile, output_dir):
     """
     Evaluate using COCO API
     """
     if self._image_set == 'train' or self._image_set == 'val':
         cocoGt = self._coco[0]
         cocoDt = COCO(dtFile)
         E = COCOeval(cocoGt, cocoDt)
         E.evaluate()
         E.accumulate()
         E.summarize()
开发者ID:baiyancheng20,项目名称:az-net,代码行数:13,代码来源:coco.py

示例10: evaluate_detections

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
 def evaluate_detections(self, all_boxes, output_dir=None):
     resFile = self._write_coco_results_file(all_boxes)
     cocoGt = self._annotations
     cocoDt = cocoGt.loadRes(resFile)
     # running evaluation
     cocoEval = COCOeval(cocoGt,cocoDt)
     # useSegm should default to 0
     #cocoEval.params.useSegm = 0
     cocoEval.evaluate()
     cocoEval.accumulate()
     cocoEval.summarize()
开发者ID:ghostcow,项目名称:fast-rcnn,代码行数:13,代码来源:coco.py

示例11: _do_detection_eval

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
 def _do_detection_eval(self, res_file, output_dir):
   ann_type = 'bbox'
   coco_dt = self._COCO.loadRes(res_file)
   coco_eval = COCOeval(self._COCO, coco_dt)
   coco_eval.params.useSegm = (ann_type == 'segm')
   coco_eval.evaluate()
   coco_eval.accumulate()
   self._print_detection_eval_metrics(coco_eval)
   eval_file = osp.join(output_dir, 'detection_results.pkl')
   with open(eval_file, 'wb') as fid:
     pickle.dump(coco_eval, fid, pickle.HIGHEST_PROTOCOL)
   print('Wrote COCO eval results to: {}'.format(eval_file))
开发者ID:StanislawAntol,项目名称:tf-faster-rcnn,代码行数:14,代码来源:coco.py

示例12: evaluate_coco

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
def evaluate_coco(model, dataset, coco, eval_type="bbox", limit=0, image_ids=None):
    """Runs official COCO evaluation.
    dataset: A Dataset object with valiadtion data
    eval_type: "bbox" or "segm" for bounding box or segmentation evaluation
    limit: if not 0, it's the number of images to use for evaluation
    """
    # Pick COCO images from the dataset
    image_ids = image_ids or dataset.image_ids

    # Limit to a subset
    if limit:
        image_ids = image_ids[:limit]

    # Get corresponding COCO image IDs.
    coco_image_ids = [dataset.image_info[id]["id"] for id in image_ids]

    t_prediction = 0
    t_start = time.time()

    results = []
    for i, image_id in enumerate(image_ids):
        # Load image
        image = dataset.load_image(image_id)

        # Run detection
        t = time.time()
        r = model.detect([image], verbose=0)[0]
        t_prediction += (time.time() - t)

        # Convert results to COCO format
        # Cast masks to uint8 because COCO tools errors out on bool
        image_results = build_coco_results(dataset, coco_image_ids[i:i + 1],
                                           r["rois"], r["class_ids"],
                                           r["scores"],
                                           r["masks"].astype(np.uint8))
        results.extend(image_results)

    # Load results. This modifies results with additional attributes.
    coco_results = coco.loadRes(results)

    # Evaluate
    cocoEval = COCOeval(coco, coco_results, eval_type)
    cocoEval.params.imgIds = coco_image_ids
    cocoEval.evaluate()
    cocoEval.accumulate()
    cocoEval.summarize()

    print("Prediction time: {}. Average {}/image".format(
        t_prediction, t_prediction / len(image_ids)))
    print("Total time: ", time.time() - t_start)
开发者ID:RubensZimbres,项目名称:Mask_RCNN,代码行数:52,代码来源:coco.py

示例13: evaluate_coco

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
def evaluate_coco(model, dataset, coco, config, eval_type="bbox", limit=None, image_ids=None):
    """Runs official COCO evaluation.
    dataset: A Dataset object with valiadtion data
    eval_type: "bbox" or "segm" for bounding box or segmentation evaluation
    """
    # Pick COCO images from the dataset
    image_ids = image_ids or dataset.image_ids

    # Limit to a subset
    if limit:
        image_ids = image_ids[:limit]
        
    # Get corresponding COCO image IDs.
    coco_image_ids = [dataset.image_info[id]["id"] for id in image_ids]

    t_prediction = 0
    t_start = time.time()

    results = []
    for i, image_id in enumerate(image_ids):
        if i%10==0:
            print('Processed %d images'%i )
        # Load image
        image = dataset.load_image(image_id)
        # Run detection
        t = time.time()
        r = inference(image, model, config)
        t_prediction += (time.time() - t)

        # Convert results to COCO format
        image_results = build_coco_results(dataset, coco_image_ids[i:i + 1],
                                           r["rois"], r["class_ids"],
                                           r["scores"], r["masks"])
        results.extend(image_results)

    # Load results. This modifies results with additional attributes.
    coco_results = coco.loadRes(results)

    # Evaluate
    cocoEval = COCOeval(coco, coco_results, eval_type)
    cocoEval.params.imgIds = coco_image_ids
    # Only evaluate for person.
    cocoEval.params.catIds = coco.getCatIds(catNms=['person']) 
    cocoEval.evaluate()
    a=cocoEval.accumulate()
    b=cocoEval.summarize()

    print("Prediction time: {}. Average {}/image".format(
        t_prediction, t_prediction / len(image_ids)))
    print("Total time: ", time.time() - t_start)
开发者ID:huanglizhi,项目名称:Pytorch_Mask_RCNN,代码行数:52,代码来源:eval.py

示例14: validate

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
def validate(val_loader, model, i, silence=False):
    batch_time = AverageMeter()
    coco_gt = val_loader.dataset.coco
    coco_pred = COCO()
    coco_pred.dataset['images'] = [img for img in coco_gt.datasets['images']]
    coco_pred.dataset['categories'] = copy.deepcopy(coco_gt.dataset['categories'])
    id = 0

    # switch to evaluate mode
    model.eval()

    end = time.time()
    for i, (inputs, anns) in enumerate(val_loader):

        # forward images one by one (TODO: support batch mode later, or
        # multiprocess)
        for j, input in enumerate(inputs):
            input_anns= anns[j] # anns of this input
            gt_bbox= np.vstack([ann['bbox'] + [ann['ordered_id']] for ann in input_anns])
            im_info= [[input.size(1), input.size(2),
                        input_anns[0]['scale_ratio']]]
            input_var= Variable(input.unsqueeze(0),
                                 requires_grad=False).cuda()

            cls_prob, bbox_pred, rois = model(input_var, im_info)
            scores, pred_boxes = model.interpret_outputs(cls_prob, bbox_pred, rois, im_info)
            print(scores, pred_boxes)
            # for i in range(scores.shape[0]):


        # measure elapsed time
        batch_time.update(time.time() - end)
        end= time.time()

    coco_pred.createIndex()
    coco_eval = COCOeval(coco_gt, coco_pred, 'bbox')
    coco_eval.params.imgIds= sorted(coco_gt.getImgIds())
    coco_eval.evaluate()
    coco_eval.accumulate()
    coco_eval.summarize()

    print('iter: [{0}] '
          'Time {batch_time.avg:.3f} '
          'Val Stats: {1}'
          .format(i, coco_eval.stats,
                  batch_time=batch_time))

    return coco_eval.stats[0]
开发者ID:tony32769,项目名称:mask_rcnn_pytorch,代码行数:50,代码来源:main.py

示例15: _do_eval

# 需要导入模块: from pycocotools.cocoeval import COCOeval [as 别名]
# 或者: from pycocotools.cocoeval.COCOeval import evaluate [as 别名]
def _do_eval(res_file, output_dir,_COCO,classes):
## The function is borrowed from https://github.com/rbgirshick/fast-rcnn/ and changed
        ann_type = 'bbox'
        coco_dt = _COCO.loadRes(res_file)
        coco_eval = COCOeval(_COCO, coco_dt)
        coco_eval.params.useSegm = (ann_type == 'segm')
        coco_eval.evaluate()
        coco_eval.accumulate()
        _print_eval_metrics(coco_eval,classes)
        # Write the result file
        eval_file = osp.join(output_dir)
        eval_result = {}
        eval_result['precision'] = coco_eval.eval['precision']
        eval_result['recall'] = coco_eval.eval['recall']
        sio.savemat(eval_file,eval_result)
        print 'Wrote COCO eval results to: {}'.format(eval_file)
开发者ID:879229395,项目名称:fast-rcnn-torch,代码行数:18,代码来源:evaluate_coco.py


注:本文中的pycocotools.cocoeval.COCOeval.evaluate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。