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

Make max_windows a required argument for RandomWindowGeoDataset #2223

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

keves1
Copy link
Contributor

@keves1 keves1 commented Aug 22, 2024

Overview

This PR makes max_windows a required argument for RandomWindowGeoDataset, and removes the option for this argument to be None. The purpose of this is to avoid a runtime error that would occur when iterating through a PyTorch dataloader that uses this dataset if max_windows uses the current default value of None. The PR also makes all arguments other than scene keyword args in order to allow the order of the args to stay the same.

Checklist

  • Added unit tests, if applicable
  • Updated documentation, if applicable
  • Added needs-backport label if the change should be back-ported to the previous release
  • PR has a name that won't get you publicly shamed for vagueness

Notes

Updated relevant unit tests and tutorials.

Testing Instructions

See updated unit tests.

Test case (should run with no errors)

from rastervision.core.data import ClassConfig
from rastervision.core.data.utils import make_ss_scene
from rastervision.pytorch_learner import SemanticSegmentationRandomWindowGeoDataset

from torch.utils.data import DataLoader

image_uri = 's3://spacenet-dataset/spacenet/SN7_buildings/train/L15-0331E-1257N_1327_3160_13/images/global_monthly_2018_01_mosaic_L15-0331E-1257N_1327_3160_13.tif'
label_uri = 's3://spacenet-dataset/spacenet/SN7_buildings/train/L15-0331E-1257N_1327_3160_13/labels/global_monthly_2018_01_mosaic_L15-0331E-1257N_1327_3160_13_Buildings.geojson'

class_config = ClassConfig(
    names=['background', 'building'],
    colors=['lightgray', 'darkred'],
    null_class='background')

scene = make_ss_scene(
    class_config=class_config,
    image_uri=image_uri,
    label_vector_uri=label_uri,
    label_vector_default_class_id=class_config.get_class_id('building'),
    image_raster_source_kw=dict(allow_streaming=True))

dataset = SemanticSegmentationRandomWindowGeoDataset(scene, out_size=224, size_lims=[220,224], max_windows=10)

dataloader = DataLoader(dataset, batch_size=5, shuffle=True, num_workers=0)
x, y = next(iter(dataloader))

Closes #2222

Copy link
Collaborator

@AdeelH AdeelH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thank you for the PR!

@AdeelH AdeelH merged commit 2fd86d3 into azavea:master Aug 23, 2024
2 checks passed
@keves1
Copy link
Contributor Author

keves1 commented Aug 23, 2024

Great! You're welcome, glad to contribute.

@AdeelH AdeelH added the needs-backport This PR needs to be backported to release branches label Aug 29, 2024
Copy link

codecov bot commented Aug 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.34%. Comparing base (eb83d30) to head (dba5ff4).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2223      +/-   ##
==========================================
- Coverage   90.34%   90.34%   -0.01%     
==========================================
  Files         199      199              
  Lines        9910     9908       -2     
==========================================
- Hits         8953     8951       -2     
  Misses        957      957              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

AdeelH pushed a commit to AdeelH/raster-vision that referenced this pull request Aug 29, 2024
…ea#2223)

* Makes max_windows a required argument and make all args other than scene keyword args.

* Updated tutorials to reflect change to RandomWindowGeoDataset.
AdeelH pushed a commit that referenced this pull request Aug 30, 2024
* Makes max_windows a required argument and make all args other than scene keyword args.

* Updated tutorials to reflect change to RandomWindowGeoDataset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-backport This PR needs to be backported to release branches
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Runtime error when max_windows not set for SemanticSegmentationRandomGeoDataset
2 participants