microsoft/X-Decoder

The dataset type does not have the len() attribute

Opened this issue · 8 comments

I tried both the 2.0 and main branches , and produced the same error.

Part of the error code:
`
class JointLoader(torchdata.IterableDataset):

def __init__(self, loaders, key_dataset):
    dataset_names = []
    for key, loader in loaders.items():
        name = "{}".format(key.split('_')[0])
        setattr(self, name, loader)
        dataset_names += [name]
    self.dataset_names = dataset_names
    self.key_dataset = key_dataset

def __iter__(self):
    for batch in zip(*[getattr(self, name) for name in self.dataset_names]):
        yield {key: batch[i] for i, key in enumerate(self.dataset_names)}

def __len__(self):
    return len(getattr(self, self.key_dataset))`

Output error:

object of type 'AspectRatioGroupedDataset' has no len()
File "/home/ckt/projects/X-Decoder-main/datasets/build.py", line 80, in len
return len(getattr(self, self.key_dataset))
File "/home/ckt/projects/X-Decoder-main/pipeline/XDecoderPipeline.py", line 71, in get_dataloaders
logger.info(f'num of train samples: {len(dataloader)}')
File "/home/ckt/projects/X-Decoder-main/trainer/default_trainer.py", line 182, in init_train
self.train_dataloaders = self.pipeline.get_dataloaders(self, 'train', is_evaluation=False)
File "/home/ckt/projects/X-Decoder-main/trainer/default_trainer.py", line 226, in train
self.init_train()
File "/home/ckt/projects/X-Decoder-main/entry.py", line 48, in main
trainer.train()
File "/home/ckt/projects/X-Decoder-main/entry.py", line 55, in
main()
TypeError: object of type 'AspectRatioGroupedDataset' has no len()

屏幕截图 2023-11-30 161344

i dont know why the object of type 'AspectRatioGroupedDataset' has no len()

I have encountered the same problem. Have you resolved it?

logger.info(f'num of train samples: {len(dataloader)}')
TypeError: object of type 'AspectRatioGroupedDataset' has no len()

I have encountered the same problem. Have you resolved it?

Unfortunately, I have not solved this problem either, and I am waiting for the author to answer.
Now I'm going to focus on another project, and then I'll come back to it and try to solve this problem.
If you have any progress, please write your answers here, thanks a lot!

please install customized detectron2: git+https://github.com/MaureenZOU/detectron2-xyz.git

please install customized detectron2: git+https://github.com/MaureenZOU/detectron2-xyz.git

I will download detectron2 again according to your suggestion. I hope it will work, thank you.

please install customized detectron2: git+https://github.com/MaureenZOU/detectron2-xyz.git

Thank you very much! This is because of the detectron2 version issue. Moreover, thank you very much for your work on X-decoder, it gives me some inspiration.

I have encountered the same problem. Have you resolved it?

The author's answer has solved this problem, you can try it out.
There may be some installation issues, you can ask for help