Function that collates lists or tuples together into one list (of lists/tuples). Use this as the collate function in a Dataloader, if you want to have a list of items as an output, as opposed to tensors (eg. Brambox.boxes).
(batch)
| 162 | |
| 163 | |
| 164 | def list_collate(batch): |
| 165 | """ |
| 166 | Function that collates lists or tuples together into one list (of lists/tuples). |
| 167 | Use this as the collate function in a Dataloader, if you want to have a list of |
| 168 | items as an output, as opposed to tensors (eg. Brambox.boxes). |
| 169 | """ |
| 170 | items = list(zip(*batch)) |
| 171 | |
| 172 | for i in range(len(items)): |
| 173 | if isinstance(items[i][0], (list, tuple)): |
| 174 | items[i] = list(items[i]) |
| 175 | else: |
| 176 | items[i] = default_collate(items[i]) |
| 177 | |
| 178 | return items |
nothing calls this directly
no outgoing calls
no test coverage detected