def build_train_loader(cls, cfg): """ Returns: iterable It now calls :func:`fastreid.data.build_reid_train_loader`. Overwrite it if you'd like a different data loader. """ logger = logging.getLogger("fastreid.clas_dataset") logger.info("Prepare training set") train_items = list() for d in cfg.DATASETS.NAMES: data = DATASET_REGISTRY.get(d)(root=_root) if comm.is_main_process(): data.show_train() train_items.extend(data.train) transforms = build_transforms(cfg, is_train=True) train_set = ClasDataset(train_items, transforms) data_loader = build_reid_train_loader(cfg, train_set=train_set) # Save index to class dictionary output_dir = cfg.OUTPUT_DIR if comm.is_main_process() and output_dir: path = os.path.join(output_dir, "idx2class.json") with PathManager.open(path, "w") as f: json.dump(train_set.idx_to_class, f) return data_loader
def build_train_loader(cls, cfg): path_imgrec = cfg.DATASETS.REC_PATH if path_imgrec != "": transforms = build_transforms(cfg, is_train=True) train_set = MXFaceDataset(path_imgrec, transforms) return build_reid_train_loader(cfg, train_set=train_set) else: return DefaultTrainer.build_train_loader(cfg)
def build_train_loader(cls, cfg): """ Returns: iterable It now calls :func:`fastreid.data.build_reid_train_loader`. Overwrite it if you'd like a different data loader. """ logger = logging.getLogger("fastreid.clas_dataset") logger.info("Prepare training set") data_loader = build_reid_train_loader(cfg, Dataset=ClasDataset) # Save index to class dictionary output_dir = cfg.OUTPUT_DIR if comm.is_main_process() and output_dir: path = os.path.join(output_dir, "idx2class.json") with PathManager.open(path, "w") as f: json.dump(data_loader.dataset.idx_to_class, f) return data_loader
def build_train_loader(cls, cfg): logger = logging.getLogger("fastreid.attr_dataset") train_items = list() attr_dict = None for d in cfg.DATASETS.NAMES: dataset = DATASET_REGISTRY.get(d)( root=_root, combineall=cfg.DATASETS.COMBINEALL) if comm.is_main_process(): dataset.show_train() if attr_dict is not None: assert attr_dict == dataset.attr_dict, f"attr_dict in {d} does not match with previous ones" else: attr_dict = dataset.attr_dict train_items.extend(dataset.train) train_transforms = build_transforms(cfg, is_train=True) train_set = AttrDataset(train_items, train_transforms, attr_dict) data_loader = build_reid_train_loader(cfg, train_set=train_set) AttrTrainer.sample_weights = data_loader.dataset.sample_weights return data_loader
def build_train_loader(cls, cfg): """ Returns: iterable It now calls :func:`fastreid.data.build_reid_train_loader`. Overwrite it if you'd like a different data loader. """ logger = logging.getLogger("fastreid.clas_dataset") logger.info("Prepare training set") train_items = list() for d in cfg.DATASETS.NAMES: data = DATASET_REGISTRY.get(d)(root=_root) if comm.is_main_process(): data.show_train() train_items.extend(data.train) transforms = build_transforms(cfg, is_train=True) train_set = ClasDataset(train_items, transforms) cls.idx2class = train_set.idx_to_class data_loader = build_reid_train_loader(cfg, train_set=train_set) return data_loader