def setup(self, stage=None): super().setup(stage=stage) cfg = self.cfg if HydraConfig.initialized(): # Current directory changed! # Update paths with original_cwd csv_path = to_absolute_path(cfg.data.csv_path) root_dir = to_absolute_path(cfg.data.root_dir) else: # Keep relative paths csv_path = cfg.data.csv_path root_dir = cfg.data.root_dir df = pd.read_csv(csv_path) df[["x", "y", "x1", "y1"]] = pd.DataFrame( np.stack(df["box"].apply(ast.literal_eval)).astype(np.float32) ) train_df = df.loc[df["fold"] != cfg.data.valid_fold].copy() valid_df = df.loc[df["fold"] == cfg.data.valid_fold].copy() self.train_dataset = PennFudanDataset( train_df, root_dir=root_dir, transforms=self.train_transforms, mode="train", ) self.val_dataset = PennFudanDataset( valid_df, root_dir=root_dir, transforms=self.val_transforms, mode="val" )
def get_output_dir(subfolder: Optional[str] = None) -> str: """Return an unique output dir based on the configuration overrides""" path = HydraConfig.get().run.dir if subfolder is not None: name = os.path.basename(path) path = os.path.dirname(path) path = os.path.join(path, subfolder, name) if not os.path.exists(path): os.makedirs(path) return path
def __init__(self, cfg: DictConfig, train_transforms=None, val_transforms=None): super().__init__( train_transforms=train_transforms, val_transforms=val_transforms, test_transforms=val_transforms, ) self.train_transforms = train_transforms self.val_transforms = val_transforms self.cfg = cfg if HydraConfig.initialized(): # Current directory changed! # Update paths with original_cwd self.data_csv_path = to_absolute_path(cfg.data.csv_path) self.root_dir = to_absolute_path(cfg.data.root_dir) else: # Keep relative paths self.data_csv_path = cfg.data.csv_path self.root_dir = cfg.data.root_dir
def get_sweep_dir() -> str: return HydraConfig.get().sweep.dir
def get_overrides() -> str: """Return the configuration overrides""" return HydraConfig.get().job.override_dirname
def get_hydra_config() -> DictConfig: r""" Return the configuration """ return HydraConfig.get()
def get_output_dir() -> str: r""" Return an unique output dir based on the configuration overrides """ return HydraConfig.get().run.dir
def get_output_dir() -> str: r""" Specific output dir based on the override """ return HydraConfig.get().run.dir
def get_overrides() -> str: return HydraConfig.get().job.override_dirname
def get_hydra_config() -> DictConfig: return HydraConfig.get()