[data] added error handling to dataset

This commit is contained in:
FrankLeeeee 2024-06-24 08:50:35 +00:00
parent 7115864314
commit 6a72b8910b
2 changed files with 10 additions and 1 deletions

View file

@ -111,6 +111,9 @@ def prepare_dataloader(
def collate_fn_default(batch):
# filter out None
batch = [x for x in batch if x is not None]
# HACK: for loading text features
use_mask = False
if "mask" in batch[0] and isinstance(batch[0]["mask"], int):
@ -132,6 +135,9 @@ def collate_fn_batch(batch):
"""
Used only with BatchDistributedSampler
"""
# filter out None
batch = [x for x in batch if x is not None]
res = torch.utils.data.default_collate(batch)
# squeeze the first dimension, which is due to torch.stack() in default_collate()

View file

@ -190,7 +190,10 @@ class VariableVideoTextDataset(VideoTextDataset):
return ret
def __getitem__(self, index):
return self.getitem(index)
try:
return self.getitem(index)
except:
return None
@DATASETS.register_module()