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

Add SpaceNet5 #263

Merged
merged 8 commits into from
Nov 29, 2021
Merged

Add SpaceNet5 #263

merged 8 commits into from
Nov 29, 2021

Conversation

ashnair1
Copy link
Collaborator

@ashnair1 ashnair1 commented Nov 26, 2021

  • Added SpaceNet 5
  • Added tests and test data for SpaceNet 5
  • _load_mask and plot overrided to support multi channel speed masks.

Sample Plots:

Binary Mask (With speed_mask=False)
binary_mask

Speed Mask (With speed_mask=True)
speed_mask

By default, every 10 mph constitutes a class hence 7 classes (not including background).

@adamjstewart adamjstewart added this to the 0.2.0 milestone Nov 26, 2021
@adamjstewart adamjstewart added the datasets Geospatial or benchmark datasets label Nov 26, 2021
tests/datasets/test_spacenet.py Outdated Show resolved Hide resolved
torchgeo/datasets/spacenet.py Show resolved Hide resolved

if self.speed_mask:
val = speed_cls_arr[
int(feature["properties"]["inferred_speed_mph"]) - 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why -1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

speed_cls_arr is an array of length 65 with a class corresponding to each index/speed mph. Essentially its a mapping between speed mph (index) and the class. -1 is to account for index starting at 0.

"""
min_speed_bin = 1
max_speed_bin = 65
speed_arr_bin = np.arange(min_speed_bin, max_speed_bin + 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why +1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

np.arange(min, max) produces an array ranging from min to max-1. +1 is to include the max

speed_arr_bin = np.arange(min_speed_bin, max_speed_bin + 1)
bin_size_mph = 10.0
speed_cls_arr = np.array(
[int(math.ceil(s / bin_size_mph)) for s in speed_arr_bin]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we binning these? Wouldn't it be better to leave them as floats and use it in a regression problem?

Copy link
Collaborator Author

@ashnair1 ashnair1 Nov 26, 2021

Choose a reason for hiding this comment

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

Binning is done to create a multi channel speed mask which would enable training a segmentation model. This was the strategy adopted by the SpaceNet authors (cresi) and the winning solutions hence why I opted for this.

@ashnair1 ashnair1 mentioned this pull request Nov 26, 2021
7 tasks
adamjstewart
adamjstewart previously approved these changes Nov 27, 2021
adamjstewart
adamjstewart previously approved these changes Nov 27, 2021
@calebrob6
Copy link
Member

Good to merge @ashnair1?

@ashnair1
Copy link
Collaborator Author

ashnair1 commented Nov 29, 2021

Good to merge @ashnair1?

@calebrob6 Good to go 👍

@calebrob6 calebrob6 merged commit 28e5f24 into microsoft:main Nov 29, 2021
@ashnair1 ashnair1 deleted the sn5 branch November 30, 2021 04:35
@adamjstewart adamjstewart added utilities Utilities for working with geospatial data and removed utilities Utilities for working with geospatial data labels Jan 2, 2022
yichiac pushed a commit to yichiac/torchgeo that referenced this pull request Apr 29, 2023
* Add SpaceNet5

* Add speed_mask option and test data

* Fix docs

* Combine fixtures

* Use python copy

* Remove list

* Predictions -> Labels

* Better error message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datasets Geospatial or benchmark datasets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants