Skip to content

Commit

Permalink
[ADD][FEAT] Allow additional params to init DatasetHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
wbenbihi committed Aug 19, 2022
1 parent 414f725 commit 6723c8e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ data:

dataset:
object: "hourglass_tensorflow.datasets.HTFBaseDatasetHandler"
params:
mockup_param: to_pass_to_object_init_method
sets:
test: true
validation: true
Expand Down
13 changes: 12 additions & 1 deletion hourglass_tensorflow/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@ class HTFDatasetSetsConfig(BaseModel):
test: bool = False


class HTFDatasetParamsConfig(BaseModel):
class Config:
extra = "allow"


class HTFDatasetConfig(BaseModel):
object: str
params: Optional[HTFDatasetParamsConfig] = Field(
default_factory=HTFDatasetParamsConfig
)
sets: Optional[HTFDatasetSetsConfig]
split: Optional[HTFDatasetSplitConfig] = Field(
default_factory=HTFDatasetSplitConfig
Expand Down Expand Up @@ -407,7 +415,10 @@ def _load_dataset_object(self) -> None:
def prepare_dataset(self) -> None:
self._load_dataset_object()
self.dataset_handler: "HTFBaseDatasetHandler" = self._metadata.dataset_object(
dataset=self._labels_df, config=self.config.dataset, global_config=self
dataset=self._labels_df,
config=self.config.dataset,
global_config=self,
**self.config.dataset.params.dict(),
)
self.dataset_handler.split_train_test()

Expand Down

0 comments on commit 6723c8e

Please sign in to comment.