Esempio n. 1
0
def main(args):
    imgaug.seed(42)
    torch.random.manual_seed(42)
    random.seed(42)

    if os.path.isabs(args.cfg):
        cfg.merge_from_file(args.cfg)
    else:
        cfg.merge_from_file(os.path.join(RepoPaths.configs_dir(), args.cfg))

    if args.dataset == "coco":
        dataset = CocoDataLoader(CocoPaths.images_dir(),
                                 CocoPaths.ids_file(),
                                 category_agnostic=False)

    elif args.dataset == "mapillary":
        dataset = MapillaryDataLoader(MapillaryPaths.images_dir(),
                                      MapillaryPaths.ids_file())

    elif args.dataset == "pascalvoc":
        dataset = PascalVOCDataLoader(PascalVOCPaths.images_dir(),
                                      PascalVOCPaths.ids_file(),
                                      category_agnostic=False)
    elif args.dataset == "ytvis":
        dataset = YoutubeVISDataLoader(YoutubeVISPaths.training_base_dir(),
                                       YoutubeVISPaths.train_vds_file(),
                                       cfg.TRAINING.TRACKER.MAX_ITERATIONS,
                                       category_agnostic=False,
                                       single_instance_duplication=cfg.DATA.
                                       YOUTUBE_VIS.SINGLE_INSTANCE_DUPLICATION)
    elif args.dataset == "davis":
        dataset = DavisDataLoader(
            DavisUnsupervisedPaths.trainval_base_dir(),
            DavisUnsupervisedPaths.train_vds_file(),
            apply_augmentation=False,
            samples_to_create=cfg.DATA.DAVIS.TRAINING_SUBSEQUENCES,
            single_instance_duplication=cfg.DATA.DAVIS.
            SINGLE_INSTANCE_DUPLICATION)
    elif args.dataset == "kittimots":
        dataset = MOTSDataLoader(
            KITTIMOTSPaths.train_images_dir(),
            KITTIMOTSPaths.train_vds_file(),
            samples_to_create=cfg.TRAINING.TRACKER.MAX_ITERATIONS,
            apply_augmentation=cfg.DATA.KITTI_MOTS.AUGMENTATION,
            frame_gap_lower=cfg.DATA.KITTI_MOTS.FRAME_GAP_LOWER,
            frame_gap_upper=cfg.DATA.KITTI_MOTS.FRAME_GAP_UPPER)
    else:
        raise ValueError("Invalid dataset name given")

    visualize_data_loader_output(dataset, args.num_workers, args.batch_size,
                                 args.shuffle)
Esempio n. 2
0
def load_cfg(args):
    cfg_file = os.path.join(os.path.dirname(args.model_path), 'config.yaml')
    if not os.path.exists(cfg_file):
        dataset_cfgs = {
            "davis": "davis_2.yaml",
            "ytvis": "youtube_vis.yaml",
            "kittimots": "kitti_mots_2.yaml"
        }
        assert args.dataset in dataset_cfgs, \
            "Invalid '--dataset' argument. Should be either 'davis', 'ytvis' or 'kittimots'"
        cfg_file = os.path.join(RepoPaths.configs_dir(), dataset_cfgs[args.dataset])

    print("Loading config from {}".format(cfg_file))
    cfg.merge_from_file(cfg_file)
Esempio n. 3
0
def main(args):
    if os.path.isabs(args.cfg):
        cfg_path = args.cfg
    else:
        cfg_path = os.path.join(RepoPaths.configs_dir(), args.cfg)

    print("Restoring config from: {}".format(cfg_path))
    global_cfg.merge_from_file(cfg_path)

    num_gpus = torch.cuda.device_count()

    if args.allow_multigpu and num_gpus > 1:
        init_distributed(args, global_cfg.TRAINING, num_gpus)
    else:
        start(args, global_cfg.TRAINING)
Esempio n. 4
0
def setup_cfg(args, model_dir, ignore_existing_cfg):
    # if a config file has been provided, load it
    if args.cfg:
        print("[ INFO] Loading config from {}".format(args.cfg))
        global_cfg.merge_from_file(args.cfg)
        return

    if ignore_existing_cfg:
        return

    # when restoring session, load the config file already present in that directory
    if args.restore_session:
        expected_config_filepath = os.path.realpath(
            os.path.join(args.restore_session, os.pardir, 'config.yaml'))
        print("[ INFO] Restoring config from {}".format(
            expected_config_filepath))
        global_cfg.merge_from_file(expected_config_filepath)

    # if the output directory already exists and there is a config file present there, then load it
    else:
        expected_config_filepath = os.path.join(model_dir, 'config.yaml')
        if os.path.exists(expected_config_filepath):
            print("[ INFO] Restoring config from {}".format(
                expected_config_filepath))
            global_cfg.merge_from_file(expected_config_filepath)