Wraps an arbitrary object with __len__ and __getitem__ into a pytorch dataset
| 133 | |
| 134 | |
| 135 | class WrappedDataset(Dataset): |
| 136 | """Wraps an arbitrary object with __len__ and __getitem__ into a pytorch dataset""" |
| 137 | |
| 138 | def __init__(self, dataset): |
| 139 | self.data = dataset |
| 140 | |
| 141 | def __len__(self): |
| 142 | return len(self.data) |
| 143 | |
| 144 | def __getitem__(self, idx): |
| 145 | return self.data[idx] |
| 146 | |
| 147 | |
| 148 | def worker_init_fn(_): |