Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/source/object_detection.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ You can verify the transform works by visualizing the 10th example:
<img src="https://huggingface.co/datasets/nateraw/documentation-images/resolve/main/visualize_detection_example_transformed_2.png">
</div>

Finally, if you wish to create a [`torch.utils.data.DataLoader`](https://alband.github.io/doc_view/data.html?highlight=torch%20utils%20data%20dataloader#torch.utils.data.DataLoader), you can do so as follows:

```py
>>> from torch.utils.data import DataLoader

>>> def collate_fn(examples):
... return {
... "images": torch.stack([example["image"] for example in examples]),
... "bboxes": torch.stack([example["bbox"] for example in examples]),
... "categories": [example["category"] for example in examples],
... }

>>> loader = DataLoader(ds['train'], batch_size=8, collate_fn=collate_fn)
```

<Tip>

Now that you know how to process a dataset for object detection, learn
Expand Down