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

Fix datamodule #28

Merged
merged 3 commits into from
Aug 12, 2023
Merged
Changes from all commits
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: 7 additions & 3 deletions viscy/light/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,11 @@ def _setup_predict(self, dataset_settings: dict):
)

def on_before_batch_transfer(self, batch: Sample, dataloader_idx: int) -> Sample:
if self.trainer.predicting or isinstance(batch, torch.Tensor):
predicting = False
if self.trainer:
if self.trainer.predicting:
predicting = True
if predicting or isinstance(batch, torch.Tensor):
# skipping example input array
return batch
if self.target_2d:
Expand All @@ -448,7 +452,7 @@ def train_dataloader(self):
batch_size=self.batch_size,
num_workers=self.num_workers,
shuffle=True,
persistent_workers=True,
persistent_workers=bool(self.num_workers),
)

def val_dataloader(self):
Expand All @@ -457,7 +461,7 @@ def val_dataloader(self):
batch_size=self.batch_size,
num_workers=self.num_workers,
shuffle=False,
persistent_workers=True,
persistent_workers=bool(self.num_workers),
)

def test_dataloader(self):
Expand Down