-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🔥 Add Tensorstore based data fetching
- Loading branch information
1 parent
a49ade1
commit 73185d2
Showing
6 changed files
with
197 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
__email__ = "[email protected]" | ||
|
||
from .dataloader import CellMapDataLoader | ||
from .multidataset import CellMapMultiDataset | ||
from .datasplit import CellMapDataSplit | ||
from .dataset import CellMapDataset | ||
from .image import CellMapImage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,48 @@ | ||
from torch.utils.data import DataLoader | ||
|
||
from .multidataset import CellMapMultiDataset | ||
from .datasplit import CellMapDataSplit | ||
from typing import Callable, Iterable | ||
from typing import Callable, Iterable, Optional | ||
|
||
|
||
class CellMapDataLoader(DataLoader): | ||
"""This subclasses PyTorch DataLoader to load CellMap data for training. It maintains the same API as the DataLoader class. This includes applying augmentations to the data and returning the data in the correct format for training, such as generating the target arrays (e.g. signed distance transform of labels). It retrieves raw and groundtruth data from a CellMapDataSplit object, which is a subclass of PyTorch Dataset. Training and validation data are split using the CellMapDataSplit object, and separate dataloaders are maintained as `train_loader` and `val_loader` respectively.""" | ||
class CellMapDataLoader: | ||
# TODO: docstring corrections | ||
"""This subclasses PyTorch DataLoader to load CellMap data for training. It maintains the same API as the DataLoader class. This includes applying augmentations to the data and returning the data in the correct format for training, such as generating the target arrays (e.g. signed distance transform of labels). It retrieves raw and groundtruth data from a CellMapDataSplit object, which is a subclass of PyTorch Dataset. Training and validation data are split using the CellMapDataSplit object, and separate dataloaders are maintained as `train_loader` and `validate_loader` respectively.""" | ||
|
||
input_arrays: dict[str, dict[str, tuple[int | float]]] | ||
target_arrays: dict[str, dict[str, tuple[int | float]]] | ||
classes: list[str] | ||
datasplit: CellMapDataSplit | ||
train_datasets: CellMapMultiDataset | ||
validate_datasets: CellMapMultiDataset | ||
train_loader: DataLoader | ||
val_loader: DataLoader | ||
validate_loader: DataLoader | ||
batch_size: int | ||
num_workers: int | ||
is_train: bool | ||
augmentations: list[dict[str, any]] | ||
to_target: Callable | ||
|
||
def __init__( | ||
self, | ||
datasplit: CellMapDataSplit, | ||
batch_size: int, | ||
num_workers: int, | ||
is_train: bool, | ||
): | ||
self.datasplit = datasplit | ||
self.batch_size = batch_size | ||
self.num_workers = num_workers | ||
self.is_train = is_train | ||
self.construct() | ||
|
||
def construct(self): | ||
self.train_datasets = self.datasplit.train_datasets_combined | ||
self.validate_datasets = self.datasplit.validate_datasets_combined | ||
self.train_loader = DataLoader( | ||
self.train_datasets, | ||
batch_size=self.batch_size, | ||
num_workers=self.num_workers, | ||
shuffle=self.is_train, | ||
) | ||
self.validate_loader = DataLoader( | ||
self.validate_datasets, | ||
batch_size=1, | ||
num_workers=self.num_workers, | ||
shuffle=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.