default='none', type=str, dest='test.out_dir', help='The test out directory of images.') # *********** Params for env. ********** parser.add_argument('--seed', default=None, type=int, help='manual seed') parser.add_argument('--cudnn', type=str2bool, nargs='?', default=True, help='Use CUDNN.') parser.add_argument("--local_rank", default=0, type=int) args = parser.parse_args() configer = Configer(args_parser=args) if args.seed is not None: random.seed(args.seed + args.local_rank) torch.manual_seed(args.seed + args.local_rank) cudnn.enabled = True cudnn.benchmark = args.cudnn abs_data_dir = os.path.expanduser(configer.get('data', 'data_dir')) configer.update('data.data_dir', abs_data_dir) if configer.get('gpu') is not None and not configer.get( 'network.distributed', default=False): os.environ["CUDA_VISIBLE_DEVICES"] = ','.join( str(gpu_id) for gpu_id in configer.get('gpu'))
fontScale=0.5, color=self.configer.get( 'details', 'color_list')[label_id % color_num], thickness=2) return image_canvas if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--hypes_file', default=None, type=str, dest='hypes_file', help='The file of the hyper parameters.') parser.add_argument('--data_dir', default=None, type=str, dest='data_dir', help='The data dir of Det Parser.') parser.add_argument('--json_file', default=None, type=str, dest='json_file', help='The json file of Det Parser.') args_parser = parser.parse_args() det_parser = ClsParser(Configer(hypes_file=args_parser.hypes_file)) det_parser.parse_dir_cls(args_parser.data_dir, args_parser.json_file)
prec = -1. ap = -1. return rec, prec, ap if __name__ == "__main__": # Example: # python coco_evaluator.py --config_file ../../../../configs/pose/coco/openpose_vgg19_coco_pose.conf # --json_dir ../../../results/pose/coco/test_dir/coco/json/ # --gt_dir /home/donny/DataSet/MSCOCO/annotations/person_keypoints_val2017.json parser = argparse.ArgumentParser() parser.add_argument('--config_file', default='../../../configs/det/voc/ssd300_vgg16_voc_det.conf', type=str, dest='config_file', help='The configs file of pose.') parser.add_argument('--gt_dir', default='/home/donny/DataSet/VOC/VOCdevkit/VOC2007', type=str, dest='gt_dir', help='The groundtruth annotations file of voc dets.') parser.add_argument('--json_dir', default='../../../val/results/det/voc/test_dir/image/json', type=str, dest='json_dir', help='The json dir of predict annotations.') parser.add_argument('--dataset', default='VOC2007', type=str, dest='dataset', help='The target dataset.') args = parser.parse_args() coco_evaluator = VOCEvaluator(Configer(hypes_file=args.hypes_file)) if args.gt_dir is not None: pred_dir = coco_evaluator.relabel(args.json_dir) coco_evaluator.evaluate(pred_dir, args.gt_dir, use_07=(args.dataset == 'VOC2007')) else: submission_dir = coco_evaluator.relabel(args.json_dir) Log.info('Submisson file path: {}'.format(submission_dir))
(int(object['bbox'][0]), int(object['bbox'][1])), (int(object['bbox'][2]), int(object['bbox'][3])), color=self.configer.get('details', 'color_list')[object['label'] % color_num], thickness=3) cv2.putText(image_canvas, class_name, (int(object['bbox'][0]) + 5, int(object['bbox'][3]) - 5), cv2.FONT_HERSHEY_SIMPLEX, fontScale=0.5, color=self.configer.get('details', 'color_list')[object['label'] % color_num], thickness=2) return image_canvas if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--config_file', default='../../configs/det/coco/yolov3_darknet_coco_det.conf', type=str, dest='config_file', help='The file of the hyper parameters.') parser.add_argument('--image_file', default=None, type=str, dest='image_file', help='The image file of Det Parser.') parser.add_argument('--json_file', default=None, type=str, dest='json_file', help='The json file of Det Parser.') parser.add_argument('--image_dir', default='/home/donny/DataSets/Pallet/train/image', type=str, dest='image_dir', help='The image directory of Det Parser.') parser.add_argument('--json_dir', default='/home/donny/DataSets/Pallet/train/json', type=str, dest='json_dir', help='The json directory of Det Parser.') args_parser = parser.parse_args() det_parser = DetParser(Configer(config_file=args_parser.config_file)) det_parser.parse_img_det(args_parser.image_file, args_parser.json_file) det_parser.parse_dir_det(args_parser.image_dir, args_parser.json_dir)
default='../../configs/seg/coco/mr_fpn_coco_seg.conf', type=str, dest='config_file', help='The file of the hyper parameters.') parser.add_argument('--image_file', default=None, type=str, dest='image_file', help='The image file of Ins Parser.') parser.add_argument('--json_file', default=None, type=str, dest='json_file', help='The json file of Det Parser.') parser.add_argument('--image_dir', default='/home/donny/DataSet/COCO_INS/train/image', type=str, dest='image_dir', help='The image directory of Ins Parser.') parser.add_argument('--json_dir', default='/home/donny/DataSet/COCO_INS/train/json', type=str, dest='json_dir', help='The json directory of Ins Parser.') args_parser = parser.parse_args() ins_parser = InsParser(Configer(hypes_file=args_parser.hypes_file)) ins_parser.parse_img_det(args_parser.image_file, args_parser.json_file) ins_parser.parse_dir_det(args_parser.image_dir, args_parser.json_dir)
dest='config_file', help='The configs file of pose.') parser.add_argument('--gt_dir', default='/home/donny/DataSet/VOC/VOCdevkit/VOC2007', type=str, dest='gt_dir', help='The groundtruth annotations file of voc dets.') parser.add_argument( '--json_dir', default='../../../val/results/det/voc/test_dir/image/json', type=str, dest='json_dir', help='The json dir of predict annotations.') parser.add_argument('--dataset', default='VOC2007', type=str, dest='dataset', help='The target dataset.') args = parser.parse_args() coco_evaluator = VOCEvaluator(Configer(config_file=args.config_file)) if args.gt_dir is not None: pred_dir = coco_evaluator.relabel(args.json_dir) coco_evaluator.evaluate(pred_dir, args.gt_dir, use_07=(args.dataset == 'VOC2007')) else: submission_dir = coco_evaluator.relabel(args.json_dir) Log.info('Submisson file path: {}'.format(submission_dir))
(int(length / 2), self.configer.get('res', 'vis_stick_width')), int(angle), 0, 360, 1) cv2.fillConvexPoly(cur_canvas, polygon, self.configer.get('details', 'color_list')[i]) image_canvas = cv2.addWeighted(image_canvas, 0.4, cur_canvas, 0.6, 0) return image_canvas if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--hypes_file', default=None, type=str, dest='hypes_file', help='The file of the hyper parameters.') parser.add_argument('--image_file', default=None, type=str, dest='image_file', help='The image file of Pose Parser.') parser.add_argument('--json_file', default=None, type=str, dest='json_file', help='The json file of Pose Parser.') parser.add_argument('--mask_file', default=None, type=str, dest='mask_file', help='The mask file of Pose Parser.') parser.add_argument('--image_dir', default=None, type=str, dest='image_dir', help='The image directory of Pose Parser.') parser.add_argument('--json_dir', default=None, type=str, dest='json_dir', help='The json directory of Pose Parser.') parser.add_argument('--mask_dir', default=None, type=str, dest='mask_dir', help='The mask directory of Pose Parser.') args_parser = parser.parse_args() pose_parser = PoseParser(Configer(hypes_file=args_parser.hypes_file)) pose_parser.parse_img_pose(args_parser.image_file, args_parser.json_file, args_parser.mask_file) pose_parser.parse_dir_pose(args_parser.image_dir, args_parser.json_dir, args_parser.mask_dir)
gtmap[np.newaxis, :, :]) img_cnt += 1 Log.info('Evaluate {} images'.format(img_cnt)) Log.info('mIOU: {}'.format(self.seg_running_score.get_mean_iou())) Log.info('Pixel ACC: {}'.format( self.seg_running_score.get_pixel_acc())) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--config_file', default=None, type=str, dest='config_file', help='The configs file of pose.') parser.add_argument('--gt_dir', default=None, type=str, dest='gt_dir', help='The groundtruth annotations.') parser.add_argument('--pred_dir', default=None, type=str, dest='pred_dir', help='The label dir of predict annotations.') args = parser.parse_args() ade20k_evaluator = ADE20KEvaluator(Configer(hypes_file=args.hypes_file)) ade20k_evaluator.evaluate(args.pred_dir, args.gt_dir)
img_cnt += 1 Log.info('Evaluate {} images'.format(img_cnt)) Log.info('Class mIOU: {}'.format(self.seg_running_score.get_cls_iou())) Log.info('mIOU: {}'.format(self.seg_running_score.get_mean_iou())) Log.info('Pixel ACC: {}'.format( self.seg_running_score.get_pixel_acc())) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--config_file', default=None, type=str, dest='config_file', help='The configs file of pose.') parser.add_argument('--gt_dir', default=None, type=str, dest='gt_dir', help='The groundtruth annotations.') parser.add_argument('--pred_dir', default=None, type=str, dest='pred_dir', help='The label dir of predict annotations.') args = parser.parse_args() seg_evaluator = SegEvaluator(Configer(config_file=args.config_file)) seg_evaluator.evaluate(args.pred_dir, args.gt_dir)
default=None, type=str, dest='hypes_file', help='The file of the hyper parameters.') parser.add_argument('--image_file', default=None, type=str, dest='image_file', help='The image file of Seg Parser.') parser.add_argument('--label_file', default=None, type=str, dest='label_file', help='The label file of Seg Parser.') parser.add_argument('--image_dir', default=None, type=str, dest='image_dir', help='The image directory of Seg Parser.') parser.add_argument('--label_dir', default=None, type=str, dest='label_dir', help='The label directory of Seg Parser.') args_parser = parser.parse_args() seg_parser = SegParser(Configer(hypes_file=args_parser.hypes_file)) seg_parser.parse_img_seg(args_parser.image_file, args_parser.label_file) seg_parser.parse_dir_seg(args_parser.image_dir, args_parser.label_dir)