Python datasets.task_evaluation.evaluate_all() Examples
The following are 15
code examples of datasets.task_evaluation.evaluate_all().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
datasets.task_evaluation
, or try the search function
.
Example #1
Source File: reval.py From seg_every_thing with Apache License 2.0 | 6 votes |
def do_reval(dataset_name, output_dir, args): dataset = JsonDataset(dataset_name) with open(os.path.join(output_dir, 'detections.pkl'), 'rb') as f: dets = pickle.load(f) # Override config with the one saved in the detections file if args.cfg_file is not None: core.config.merge_cfg_from_cfg(yaml.load(dets['cfg'])) else: core.config._merge_a_into_b(yaml.load(dets['cfg']), cfg) results = task_evaluation.evaluate_all( dataset, dets['all_boxes'], dets['all_segms'], dets['all_keyps'], output_dir, use_matlab=args.matlab_eval ) task_evaluation.log_copy_paste_friendly_results(results)
Example #2
Source File: reval.py From masktextspotter.caffe2 with Apache License 2.0 | 6 votes |
def do_reval(dataset_name, output_dir, args): dataset = JsonDataset(dataset_name) with open(os.path.join(output_dir, 'detections.pkl'), 'rb') as f: dets = pickle.load(f) # Override config with the one saved in the detections file if args.cfg_file is not None: core.config.merge_cfg_from_cfg(yaml.load(dets['cfg'])) else: core.config._merge_a_into_b(yaml.load(dets['cfg']), cfg) results = task_evaluation.evaluate_all( dataset, dets['all_boxes'], dets['all_segms'], dets['all_keyps'], output_dir, use_matlab=args.matlab_eval ) task_evaluation.log_copy_paste_friendly_results(results)
Example #3
Source File: test_engine.py From NucleiDetectron with Apache License 2.0 | 6 votes |
def test_net_on_dataset(output_dir, multi_gpu=False, gpu_id=0): """Run inference on a dataset.""" dataset = JsonDataset(cfg.TEST.DATASET) test_timer = Timer() test_timer.tic() if multi_gpu: num_images = len(dataset.get_roidb()) all_boxes, all_segms, all_keyps = multi_gpu_test_net_on_dataset( num_images, output_dir ) else: all_boxes, all_segms, all_keyps = test_net(output_dir, gpu_id=gpu_id) test_timer.toc() logger.info('Total inference time: {:.3f}s'.format(test_timer.average_time)) results = task_evaluation.evaluate_all( dataset, all_boxes, all_segms, all_keyps, output_dir ) return results
Example #4
Source File: reval.py From NucleiDetectron with Apache License 2.0 | 6 votes |
def do_reval(dataset_name, output_dir, args): dataset = JsonDataset(dataset_name) with open(os.path.join(output_dir, 'detections.pkl'), 'rb') as f: dets = pickle.load(f) # Override config with the one saved in the detections file if args.cfg_file is not None: core.config.merge_cfg_from_cfg(yaml.load(dets['cfg'])) else: core.config._merge_a_into_b(yaml.load(dets['cfg']), cfg) results = task_evaluation.evaluate_all( dataset, dets['all_boxes'], dets['all_segms'], dets['all_keyps'], output_dir, use_matlab=args.matlab_eval ) task_evaluation.log_copy_paste_friendly_results(results)
Example #5
Source File: test_engine.py From Detectron.pytorch with MIT License | 5 votes |
def test_net_on_dataset( args, dataset_name, proposal_file, output_dir, multi_gpu=False, gpu_id=0): """Run inference on a dataset.""" dataset = JsonDataset(dataset_name) test_timer = Timer() test_timer.tic() if multi_gpu: num_images = len(dataset.get_roidb()) all_boxes, all_segms, all_keyps = multi_gpu_test_net_on_dataset( args, dataset_name, proposal_file, num_images, output_dir ) else: all_boxes, all_segms, all_keyps = test_net( args, dataset_name, proposal_file, output_dir, gpu_id=gpu_id ) test_timer.toc() logger.info('Total inference time: {:.3f}s'.format(test_timer.average_time)) results = task_evaluation.evaluate_all( dataset, all_boxes, all_segms, all_keyps, output_dir ) return results
Example #6
Source File: test_engine.py From FPN-Pytorch with MIT License | 5 votes |
def test_net_on_dataset( args, dataset_name, proposal_file, output_dir, multi_gpu=False, gpu_id=0): """Run inference on a dataset.""" dataset = JsonDataset(dataset_name) test_timer = Timer() test_timer.tic() if multi_gpu: num_images = len(dataset.get_roidb()) all_boxes, all_segms, all_keyps = multi_gpu_test_net_on_dataset( args, dataset_name, proposal_file, num_images, output_dir ) else: all_boxes, all_segms, all_keyps = test_net( args, dataset_name, proposal_file, output_dir, gpu_id=gpu_id ) test_timer.toc() logger.info('Total inference time: {:.3f}s'.format(test_timer.average_time)) results = task_evaluation.evaluate_all( dataset, all_boxes, all_segms, all_keyps, output_dir ) return results
Example #7
Source File: test_engine.py From pcl.pytorch with MIT License | 5 votes |
def test_net_on_dataset( args, dataset_name, proposal_file, output_dir, multi_gpu=False, gpu_id=0): """Run inference on a dataset.""" dataset = JsonDataset(dataset_name) test_timer = Timer() test_timer.tic() if multi_gpu: num_images = len(dataset.get_roidb()) all_boxes = multi_gpu_test_net_on_dataset( args, dataset_name, proposal_file, num_images, output_dir ) else: all_boxes = test_net( args, dataset_name, proposal_file, output_dir, gpu_id=gpu_id ) test_timer.toc() logger.info('Total inference time: {:.3f}s'.format(test_timer.average_time)) roidb = dataset.get_roidb() num_images = len(roidb) num_classes = cfg.MODEL.NUM_CLASSES + 1 final_boxes = empty_results(num_classes, num_images) test_corloc = 'train' in dataset_name for i, entry in enumerate(roidb): boxes = all_boxes[entry['image']] if test_corloc: _, _, cls_boxes_i = box_results_for_corloc(boxes['scores'], boxes['boxes']) else: _, _, cls_boxes_i = box_results_with_nms_and_limit(boxes['scores'], boxes['boxes']) extend_results(i, final_boxes, cls_boxes_i) results = task_evaluation.evaluate_all( dataset, final_boxes, output_dir, test_corloc ) return results
Example #8
Source File: test_engine.py From Detectron.pytorch with MIT License | 5 votes |
def test_net_on_dataset( args, dataset_name, proposal_file, output_dir, multi_gpu=False, gpu_id=0): """Run inference on a dataset.""" dataset = JsonDataset(dataset_name) test_timer = Timer() test_timer.tic() if multi_gpu: num_images = len(dataset.get_roidb()) all_boxes, all_segms, all_keyps = multi_gpu_test_net_on_dataset( args, dataset_name, proposal_file, num_images, output_dir ) else: all_boxes, all_segms, all_keyps = test_net( args, dataset_name, proposal_file, output_dir, gpu_id=gpu_id ) test_timer.toc() logger.info('Total inference time: {:.3f}s'.format(test_timer.average_time)) results = task_evaluation.evaluate_all( dataset, all_boxes, all_segms, all_keyps, output_dir ) return results
Example #9
Source File: test_engine.py From Context-aware-ZSR with MIT License | 5 votes |
def test_net_on_dataset( args, dataset_name, proposal_file, output_dir, ind_range=None, multi_gpu=False, gpu_id=0): """Run inference on a dataset.""" dataset = JsonDataset(dataset_name) test_timer = Timer() test_timer.tic() if multi_gpu: num_images = len(dataset.get_roidb()) all_boxes, all_segms, all_keyps = multi_gpu_test_net_on_dataset( args, dataset_name, proposal_file, num_images, output_dir ) else: all_boxes, all_segms, all_keyps = test_net( args, dataset_name, proposal_file, output_dir, ind_range=ind_range, gpu_id=gpu_id ) test_timer.toc() logger.info('Total inference time: {:.3f}s'.format(test_timer.average_time)) dataset.test_img_ids = sorted(dataset.COCO.getImgIds()) if ind_range is not None: dataset.test_img_ids = dataset.test_img_ids[ind_range[0]:ind_range[1]] results = task_evaluation.evaluate_all( dataset, all_boxes, all_segms, all_keyps, output_dir ) return results
Example #10
Source File: test_engine.py From PANet with MIT License | 5 votes |
def test_net_on_dataset( args, dataset_name, proposal_file, output_dir, multi_gpu=False, gpu_id=0): """Run inference on a dataset.""" dataset = JsonDataset(dataset_name) test_timer = Timer() test_timer.tic() if multi_gpu: num_images = len(dataset.get_roidb()) all_boxes, all_segms, all_keyps = multi_gpu_test_net_on_dataset( args, dataset_name, proposal_file, num_images, output_dir ) else: all_boxes, all_segms, all_keyps = test_net( args, dataset_name, proposal_file, output_dir, gpu_id=gpu_id ) test_timer.toc() logger.info('Total inference time: {:.3f}s'.format(test_timer.average_time)) results = task_evaluation.evaluate_all( dataset, all_boxes, all_segms, all_keyps, output_dir ) return results
Example #11
Source File: test_engine.py From seg_every_thing with Apache License 2.0 | 5 votes |
def test_net_on_dataset( weights_file, dataset_name, proposal_file, output_dir, multi_gpu=False, gpu_id=0 ): """Run inference on a dataset.""" dataset = JsonDataset(dataset_name) test_timer = Timer() test_timer.tic() if multi_gpu: num_images = len(dataset.get_roidb()) all_boxes, all_segms, all_keyps = multi_gpu_test_net_on_dataset( weights_file, dataset_name, proposal_file, num_images, output_dir ) else: all_boxes, all_segms, all_keyps = test_net( weights_file, dataset_name, proposal_file, output_dir, gpu_id=gpu_id ) test_timer.toc() logger.info('Total inference time: {:.3f}s'.format(test_timer.average_time)) results = task_evaluation.evaluate_all( dataset, all_boxes, all_segms, all_keyps, output_dir ) return results
Example #12
Source File: test_engine.py From Large-Scale-VRD.pytorch with MIT License | 5 votes |
def test_net_on_dataset( args, dataset_name, proposal_file, output_dir, multi_gpu=False, gpu_id=0): """Run inference on a dataset.""" dataset = JsonDataset(dataset_name) test_timer = Timer() test_timer.tic() if multi_gpu: num_images = len(dataset.get_roidb()) all_boxes, all_segms, all_keyps = multi_gpu_test_net_on_dataset( args, dataset_name, proposal_file, num_images, output_dir ) else: all_boxes, all_segms, all_keyps = test_net( args, dataset_name, proposal_file, output_dir, gpu_id=gpu_id ) test_timer.toc() logger.info('Total inference time: {:.3f}s'.format(test_timer.average_time)) results = task_evaluation.evaluate_all( dataset, all_boxes, all_segms, all_keyps, output_dir ) return results
Example #13
Source File: test_engine.py From detectron-self-train with MIT License | 5 votes |
def test_net_on_dataset( args, dataset_name, proposal_file, output_dir, multi_gpu=False, gpu_id=0): """Run inference on a dataset.""" dataset = JsonDataset(dataset_name) test_timer = Timer() test_timer.tic() if multi_gpu: num_images = len(dataset.get_roidb()) all_boxes, all_segms, all_keyps = multi_gpu_test_net_on_dataset( args, dataset_name, proposal_file, num_images, output_dir ) else: all_boxes, all_segms, all_keyps = test_net( args, dataset_name, proposal_file, output_dir, gpu_id=gpu_id ) test_timer.toc() logger.info('Total inference time: {:.3f}s'.format(test_timer.average_time)) results = task_evaluation.evaluate_all( dataset, all_boxes, all_segms, all_keyps, output_dir ) return results
Example #14
Source File: test_engine.py From DIoU-pytorch-detectron with GNU General Public License v3.0 | 5 votes |
def test_net_on_dataset( args, dataset_name, proposal_file, output_dir, multi_gpu=False, gpu_id=0): """Run inference on a dataset.""" dataset = JsonDataset(dataset_name) test_timer = Timer() test_timer.tic() if multi_gpu: num_images = len(dataset.get_roidb()) all_boxes, all_segms, all_keyps = multi_gpu_test_net_on_dataset( args, dataset_name, proposal_file, num_images, output_dir ) else: all_boxes, all_segms, all_keyps = test_net( args, dataset_name, proposal_file, output_dir, gpu_id=gpu_id ) test_timer.toc() logger.info('Total inference time: {:.3f}s'.format(test_timer.average_time)) results = task_evaluation.evaluate_all( dataset, all_boxes, all_segms, all_keyps, output_dir ) return results
Example #15
Source File: evaluate_json.py From detectron-self-train with MIT License | 4 votes |
def eval_json(det_json,gt_json): json_dataset = JsonDataset(gt_dataset_name) gt_json = dataset_catalog.DATASETS[gt_dataset_name]['annotation_file'] with open(det_json,'rb') as f: det = json.load(f) f.close() with open(gt_json,'rb') as f: gt = json.load(f) f.close() # convert det to the all_boxes list num_images = len(gt['images']) num_classes = 2 print('Total number of images:',len(det['images'])) all_boxes, all_segms, all_keyps = empty_results(num_classes,num_images) for cls in range(num_classes): for image in range(num_images): filename = gt['images'][image]['file_name'] fid = gt['images'][image]['id'] img_prop = get_by_filename(det,filename) if not (img_prop is None): img_id,det_prop = img_prop boxes = get_boxes_by_img_id(det,img_id) if image%100 == 0: print('Reading detections for:',filename,'--',det_prop['file_name']) print('Det json:',det_json) if 'score' in boxes[0]: boxes = np.array([b['bbox']+[b['score']] for b in boxes]) else: boxes = np.array([b['bbox'] for b in boxes]) if len(boxes) > 0: # add w, h to get (x2,y2) boxes[:,2] += boxes[:,0] boxes[:,3] += boxes[:,1] all_boxes[cls][image] = boxes else: all_boxes[cls][image] = [] # save detections with open(os.path.join(output_dir,'detections.pkl'),'wb') as f: pickle.dump(dict(all_boxes=all_boxes,all_segms=all_segms,all_keyps=all_keyps),f) f.close() #input(len(all_boxes[0])) coco_eval = evaluate_boxes(json_dataset,all_boxes,output_dir) #coco_eval = task_evaluation.evaluate_all(json_dataset,all_boxes,all_segms,all_keyps,output_dir) disp_detection_eval_metrics(json_dataset, coco_eval, iou_low=0.5, iou_high=0.5, output_dir=output_dir) disp_detection_eval_metrics(json_dataset, coco_eval, iou_low=0.75, iou_high=0.75, output_dir=output_dir) disp_detection_eval_metrics(json_dataset, coco_eval, iou_low=0.5, iou_high=0.95, output_dir=output_dir)