Skip to content

Commit

Permalink
[FIX] Modify config structure for bbox processing
Browse files Browse the repository at this point in the history
  • Loading branch information
wbenbihi committed Aug 20, 2022
1 parent 5feb2ff commit 3a3b7a9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
5 changes: 4 additions & 1 deletion config/config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,7 @@ dataset:
validation_ratio: 0.15
bbox:
activate: true
padding: 0.2
padding:
x: 0
y: 0
factor: 1.5
20 changes: 13 additions & 7 deletions hourglass_tensorflow/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,17 @@ class HTFColsConfig(BaseModel):
cols: List[str] = Field(default_factory=list)


class HTFDatasetBBoxConfig(HTFColsConfig):
class HTFDatasetBBoxPaddingConfig(HTFColsConfig):
x: int = 0
y: int = 0


class HTFDatasetBBoxConfig(BaseModel):
activate: bool = False
padding: float = 0
cols: List[str] = Field(default_factory=list)
factor: float = 1
padding: HTFDatasetBBoxPaddingConfig = Field(
default_factory=HTFDatasetBBoxPaddingConfig
)


class HTFDatasetConfig(BaseModel):
Expand All @@ -71,7 +78,6 @@ class HTFDatasetConfig(BaseModel):
default_factory=HTFDatasetSplitConfig
)
bbox: Optional[HTFDatasetBBoxConfig] = Field(default_factory=HTFDatasetBBoxConfig)
center: Optional[HTFColsConfig] = Field(default_factory=HTFColsConfig)


ImageModes = Union[
Expand Down Expand Up @@ -411,15 +417,15 @@ def _read_labels(self, _error: bool = False) -> bool:
self._metadata.label_mapper = {
label: i for i, label in enumerate(self._metadata.label_headers)
}
if self._cfg_data_out.source_prefixed:
if not self._cfg_data_out.source_prefixed:
# Now we also prefix the image column with the image folder
# in case the source_prefix attribute is set to false
folder_prefix = self._cfg_data_inp.source
source_column = self._cfg_data_out.source_column
self._labels_df = self._labels_df.assign(
**{
source_column: lambda x: os.path.join(
folder_prefix, x[source_column]
source_column: self._labels_df[source_column].apply(
lambda x: os.path.join(folder_prefix, x)
)
}
)
Expand Down

0 comments on commit 3a3b7a9

Please sign in to comment.