Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸš€ Allow validation splits from training data #1865

Merged
merged 3 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/anomalib/data/base/datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,15 @@ def _create_test_split(self) -> None:

def _create_val_split(self) -> None:
"""Obtain the validation set based on the settings in the config."""
if self.val_split_mode == ValSplitMode.FROM_TEST:
if self.val_split_mode == ValSplitMode.FROM_TRAIN:
# randomly sampled from train set
self.train_data, self.val_data = random_split(
self.train_data,
self.val_split_ratio,
label_aware=True,
seed=self.seed,
)
elif self.val_split_mode == ValSplitMode.FROM_TEST:
# randomly sampled from test set
self.test_data, self.val_data = random_split(
self.test_data,
Expand Down
1 change: 1 addition & 0 deletions src/anomalib/data/utils/split.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ValSplitMode(str, Enum):

NONE = "none"
SAME_AS_TEST = "same_as_test"
FROM_TRAIN = "from_train"
FROM_TEST = "from_test"
SYNTHETIC = "synthetic"

Expand Down
Loading