Lightnet dataloader that enables on the fly resizing of the images. See :class:`torch.utils.data.DataLoader` for more information on the arguments. Check more on the following website: https://gitlab.com/EAVISE/lightnet/-/blob/master/lightnet/data/_dataloading.py Note:
| 27 | |
| 28 | |
| 29 | class DataLoader(torchDataLoader): |
| 30 | """ |
| 31 | Lightnet dataloader that enables on the fly resizing of the images. |
| 32 | See :class:`torch.utils.data.DataLoader` for more information on the arguments. |
| 33 | Check more on the following website: |
| 34 | https://gitlab.com/EAVISE/lightnet/-/blob/master/lightnet/data/_dataloading.py |
| 35 | |
| 36 | Note: |
| 37 | This dataloader only works with :class:`lightnet.data.Dataset` based datasets. |
| 38 | |
| 39 | Example: |
| 40 | >>> class CustomSet(ln.data.Dataset): |
| 41 | ... def __len__(self): |
| 42 | ... return 4 |
| 43 | ... @ln.data.Dataset.resize_getitem |
| 44 | ... def __getitem__(self, index): |
| 45 | ... # Should return (image, anno) but here we return (input_dim,) |
| 46 | ... return (self.input_dim,) |
| 47 | >>> dl = ln.data.DataLoader( |
| 48 | ... CustomSet((200,200)), |
| 49 | ... batch_size = 2, |
| 50 | ... collate_fn = ln.data.list_collate # We want the data to be grouped as a list |
| 51 | ... ) |
| 52 | >>> dl.dataset.input_dim # Default input_dim |
| 53 | (200, 200) |
| 54 | >>> for d in dl: |
| 55 | ... d |
| 56 | [[(200, 200), (200, 200)]] |
| 57 | [[(200, 200), (200, 200)]] |
| 58 | >>> dl.change_input_dim(320, random_range=None) |
| 59 | (320, 320) |
| 60 | >>> for d in dl: |
| 61 | ... d |
| 62 | [[(320, 320), (320, 320)]] |
| 63 | [[(320, 320), (320, 320)]] |
| 64 | >>> dl.change_input_dim((480, 320), random_range=None) |
| 65 | (480, 320) |
| 66 | >>> for d in dl: |
| 67 | ... d |
| 68 | [[(480, 320), (480, 320)]] |
| 69 | [[(480, 320), (480, 320)]] |
| 70 | """ |
| 71 | |
| 72 | def __init__(self, *args, **kwargs): |
| 73 | super().__init__(*args, **kwargs) |
| 74 | self.__initialized = False |
| 75 | shuffle = False |
| 76 | batch_sampler = None |
| 77 | if len(args) > 5: |
| 78 | shuffle = args[2] |
| 79 | sampler = args[3] |
| 80 | batch_sampler = args[4] |
| 81 | elif len(args) > 4: |
| 82 | shuffle = args[2] |
| 83 | sampler = args[3] |
| 84 | if "batch_sampler" in kwargs: |
| 85 | batch_sampler = kwargs["batch_sampler"] |
| 86 | elif len(args) > 3: |
no outgoing calls
no test coverage detected