get_COCO_metrice.py 962 B

123456789101112131415161718192021222324252627282930
  1. import warnings
  2. warnings.filterwarnings('ignore')
  3. import argparse
  4. from pycocotools.coco import COCO
  5. from pycocotools.cocoeval import COCOeval
  6. from tidecv import TIDE, datasets
  7. def parse_opt():
  8. parser = argparse.ArgumentParser()
  9. parser.add_argument('--anno_json', type=str, default='data.json', help='label coco json path')
  10. parser.add_argument('--pred_json', type=str, default='', help='pred coco json path')
  11. return parser.parse_known_args()[0]
  12. if __name__ == '__main__':
  13. opt = parse_opt()
  14. anno_json = opt.anno_json
  15. pred_json = opt.pred_json
  16. anno = COCO(anno_json) # init annotations api
  17. pred = anno.loadRes(pred_json) # init predictions api
  18. eval = COCOeval(anno, pred, 'bbox')
  19. eval.evaluate()
  20. eval.accumulate()
  21. eval.summarize()
  22. tide = TIDE()
  23. tide.evaluate_range(datasets.COCO(anno_json), datasets.COCOResult(pred_json), mode=TIDE.BOX)
  24. tide.summarize()
  25. tide.plot(out_dir='result')