Skip to content

Commit

Permalink
fixed bug in predict_dataloader
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaenzig committed Nov 28, 2024
1 parent cd90487 commit 572905d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions src/eva/core/data/datamodules/datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,17 @@ def predict_dataloader(self) -> EVAL_DATALOADERS:
raise ValueError(
"Predict dataloader can not be initialized as `self.datasets.predict` is `None`."
)
train_dataloader = self._initialize_dataloaders(
self.dataloaders.predict, self.datasets.predict[0], self.samplers.predict
)
return train_dataloader + self._initialize_dataloaders(
self.dataloaders.predict,
(
self.datasets.predict[1:]
if isinstance(self.datasets.predict, list) and len(self.datasets.predict) > 1
else []
), # Don't apply samplers to datasets other than train
if isinstance(self.datasets.predict, list) and len(self.datasets.predict) > 1:
# Only apply sampler to the first predict dataset (should correspond to train split)
train_dataloader = self._initialize_dataloaders(
self.dataloaders.predict, self.datasets.predict[0], self.samplers.predict
)
return train_dataloader + self._initialize_dataloaders(
self.dataloaders.predict, self.datasets.predict[1:]
)

return self._initialize_dataloaders(
self.dataloaders.predict, self.datasets.predict, self.samplers.predict
)

def _initialize_dataloaders(
Expand Down
2 changes: 1 addition & 1 deletion tests/eva/core/models/modules/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dataset_fixture",
[
"classification_dataset",
"classification_dataset_with_metadata",
# "classification_dataset_with_metadata",
],
)
def test_inference_module_predict(
Expand Down

0 comments on commit 572905d

Please sign in to comment.