Skip to content

Commit

Permalink
refactor: raise explicit error when image paths are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
IamGianluca committed Mar 23, 2024
1 parent c86de71 commit efeb520
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions blazingai/vision/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ def __init__(

def setup(self, stage: Optional[str] = None) -> None:
if stage == "fit":
if self.trn_img_paths is None:
raise ValueError("Missing trn_img_path")
if self.val_img_paths is None:
raise ValueError("Missing val_img_path")

self.trn_ds = get_dataset[self.task](
img_paths=self.trn_img_paths,
trgt=self.trn_trgt,
Expand All @@ -186,11 +191,12 @@ def setup(self, stage: Optional[str] = None) -> None:
aug=self.val_aug,
)
elif stage == "predict":
if self.tst_img_paths:
self.test_ds = get_dataset[self.task](
img_paths=self.tst_img_paths,
aug=self.tst_aug,
)
if self.tst_img_paths is None:
raise ValueError("Missing tst_img_paths")
self.test_ds = get_dataset[self.task](
img_paths=self.tst_img_paths,
aug=self.tst_aug,
)
else:
raise ValueError(f"stage `{stage}` currently not supported")

Expand Down

0 comments on commit efeb520

Please sign in to comment.