Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
init target_formatter not only typed (#1665)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Borda and pre-commit-ci[bot] authored Aug 9, 2023
1 parent cad3cac commit e76a61a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/flash/audio/classification/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def load_data(
# If we had binary multi-class targets then we also know the labels (column names)
if (
self.training
and hasattr(self, "target_formatter")
and isinstance(self.target_formatter, MultiBinaryTargetFormatter)
and isinstance(target_keys, List)
):
Expand Down
1 change: 1 addition & 0 deletions src/flash/image/classification/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def load_data(
# If we had binary multi-class targets then we also know the labels (column names)
if (
self.training
and hasattr(self, "target_formatter")
and isinstance(self.target_formatter, MultiBinaryTargetFormatter)
and isinstance(target_keys, List)
):
Expand Down
6 changes: 5 additions & 1 deletion src/flash/text/classification/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ def load_data(
self.load_target_metadata(targets, target_formatter=target_formatter)

# If we had binary multi-class targets then we also know the labels (column names)
if isinstance(self.target_formatter, MultiBinaryTargetFormatter) and isinstance(target_keys, List):
if (
hasattr(self, "target_formatter")
and isinstance(self.target_formatter, MultiBinaryTargetFormatter)
and isinstance(target_keys, List)
):
self.labels = target_keys

# remove extra columns
Expand Down
2 changes: 2 additions & 0 deletions src/flash/video/classification/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def load_data(
# If we had binary multi-class targets then we also know the labels (column names)
if (
self.training
and hasattr(self, "target_formatter")
and isinstance(self.target_formatter, MultiBinaryTargetFormatter)
and isinstance(target_keys, List)
):
Expand Down Expand Up @@ -243,6 +244,7 @@ def load_data(
# If we had binary multi-class targets then we also know the labels (column names)
if (
self.training
and hasattr(self, "target_formatter")
and isinstance(self.target_formatter, MultiBinaryTargetFormatter)
and isinstance(targets, List)
):
Expand Down

0 comments on commit e76a61a

Please sign in to comment.