Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update VHR-10 snippet #1920

Merged
merged 2 commits into from
Mar 2, 2024
Merged
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
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,29 @@ TorchGeo includes a number of [*benchmark datasets*](https://torchgeo.readthedoc
If you've used [torchvision](https://pytorch.org/vision) before, these datasets should seem very familiar. In this example, we'll create a dataset for the Northwestern Polytechnical University (NWPU) very-high-resolution ten-class ([VHR-10](https://github.com/chaozhong2010/VHR-10_dataset_coco)) geospatial object detection dataset. This dataset can be automatically downloaded, checksummed, and extracted, just like with torchvision.

```python
from torch.utils.data import DataLoader

from torchgeo.datamodules.utils import collate_fn_detection
from torchgeo.datasets import VHR10

# Initialize the dataset
dataset = VHR10(root="...", download=True, checksum=True)
dataloader = DataLoader(dataset, batch_size=128, shuffle=True, num_workers=4)

# Initialize the dataloader with the custom collate function
dataloader = DataLoader(
dataset,
batch_size=128,
shuffle=True,
num_workers=4,
collate_fn=collate_fn_detection,
)

# Training loop
for batch in dataloader:
image = batch["image"]
label = batch["label"]
images = batch["image"] # list of images
boxes = batch["boxes"] # list of boxes
labels = batch["labels"] # list of labels
masks = batch["masks"] # list of masks

# train a model, or make predictions using a pre-trained model
```
Expand Down
Loading