def setup(args): """ Create configs and perform basic setups. """ cfg = get_cfg() cfg.merge_from_file(args.train_config_path) cfg.merge_from_list(args.opts) train_data_path = args.train_data_path data_path_name = train_data_path.split("/")[-1] class_names = get_classname(train_data_path) register_all_pascal_voc(train_data_path=train_data_path, class_names=class_names) register_train_name = data_path_name + '_trainval' cfg.DATASETS.TRAIN = (register_train_name,) cfg.DATASETS.TEST = () # no metrics implemented for this dataset cfg.MODEL.WEIGHTS = args.weight_path num_class = get_class_num(train_data_path) cfg.MODEL.ROI_HEADS.NUM_CLASSES = num_class # get classes from sda cfg.OUTPUT_DIR = args.out_dir cfg.freeze() default_setup(cfg, args) return cfg
'/home/data/hou/workspaces/my_knowledge_base/competition/detectron2_devkit/out/visual', help="path to out visual images directory ", ) return parser if __name__ == '__main__': args = get_parser().parse_args() train_data_path = args.train_data_path train_config_path = args.train_config_path input_image_path = args.input_image_path model_path = args.model_path out_visual_images = args.out_visual_images if not os.path.exists(out_visual_images): os.makedirs(out_visual_images) data_path_name = train_data_path.split("/")[-1] class_names = get_classname(train_data_path) register_all_pascal_voc( train_data_path=train_data_path, class_names=class_names, ) register_val_name = data_path_name + '_test' visual_iobjectspy_voc(train_data_path, train_config_path, input_image_path, register_val_name, model_path, out_visual_images)