-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Add crestereo dataset #6269
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
Closed
Closed
Add crestereo dataset #6269
Changes from 30 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
cad18a4
Added Stereo Matching dataset interface and several classic datasets.
TeodorPoncu df6ec4b
added SceneFlow, FallingThings and CREStereo
TeodorPoncu d0c5afb
added SceneFlow, FallingThings and CREStereo
TeodorPoncu a566475
"removed duplicate folder"
TeodorPoncu 8ea74f2
Added InStereo2k. Started working on dataset tests
TeodorPoncu 0959499
"Added calibrartion arg for Middlebury2014 (#6259)"
TeodorPoncu a9365fe
"Fixed test calibration test Middlebury2014 (#6259)"
TeodorPoncu 96c7bf4
Clean-up. Disp map format to (C, H, W) & valid mask to (H, W). (#6259)
TeodorPoncu bbb1c56
Ran ufmt. (#6259)
TeodorPoncu 669611e
Adressed CI/CD errors
TeodorPoncu d9d17a8
Ran formatting pre-commit hook
TeodorPoncu a31ee83
Added Stereo Matching dataset interface and several classic datasets.
TeodorPoncu 4a5ac89
added SceneFlow, FallingThings and CREStereo
TeodorPoncu a1fc699
added SceneFlow, FallingThings and CREStereo
TeodorPoncu 62368b1
"removed duplicate folder"
TeodorPoncu 33c52a5
Added InStereo2k. Started working on dataset tests
TeodorPoncu 2deab62
"Added calibrartion arg for Middlebury2014 (#6259)"
TeodorPoncu cbc55f3
"Fixed test calibration test Middlebury2014 (#6259)"
TeodorPoncu 0759706
Clean-up. Disp map format to (C, H, W) & valid mask to (H, W). (#6259)
TeodorPoncu de94c2c
Ran ufmt. (#6259)
TeodorPoncu 4256ca4
Adressed CI/CD errors
TeodorPoncu d7882ca
Ran formatting pre-commit hook
TeodorPoncu f8d1228
Merge branch 'add-crestereo-dataset' of https://github.com/pytorch/vi…
TeodorPoncu 1436d64
Merge branch 'main' of https://github.com/pytorch/vision into add-cre…
TeodorPoncu 5f291c2
Added reusable _pfm_read. Addressed CI issues.
TeodorPoncu af6b343
Removed duplicate test code for stereo dataset testcases
TeodorPoncu 67eacf2
Removed string replaces. Moved pattern matching in parent class.
TeodorPoncu 07e0067
Addressed doc comments
TeodorPoncu ec550e8
Middlebury disparity quickfix
TeodorPoncu 1dd1753
Fixed mypy errors. Addressed download checks.
TeodorPoncu 9f70687
Dataset renaming. Test changes. getitem removed. Warnings removed. Mi…
TeodorPoncu 78f4a52
Forced disparity to be positive
TeodorPoncu 1baaaef
Merge branch 'main' into add-crestereo-dataset
TeodorPoncu e2ad8d2
Removed implicit mask creation. Added private built_in_mask flag simi…
TeodorPoncu 71343fe
Merge branch 'add-crestereo-dataset' of https://github.com/pytorch/vi…
TeodorPoncu 93f4b6c
Added getiem & docs to inform support multi shape returns
TeodorPoncu c83bc80
removed path returns from helper test functions
TeodorPoncu 650bf67
replaced os.path.join with pathlib in tests
TeodorPoncu 39efae5
crestereo draft implementation
TeodorPoncu ce66e4c
Merging from training prototyping
TeodorPoncu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
from collections import defaultdict | ||
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, Tuple, Union | ||
|
||
import numpy as np | ||
import PIL | ||
import PIL.Image | ||
import pytest | ||
|
@@ -561,7 +562,9 @@ def test_feature_types(self, config): | |
@test_all_configs | ||
def test_num_examples(self, config): | ||
with self.create_dataset(config) as (dataset, info): | ||
assert len(dataset) == info["num_examples"] | ||
assert ( | ||
len(dataset) == info["num_examples"] | ||
), f"The number of examples {len(dataset)} does not match the expected {info['num_examples']}" | ||
|
||
@test_all_configs | ||
def test_transforms(self, config): | ||
|
@@ -931,6 +934,38 @@ def create_random_string(length: int, *digits: str) -> str: | |
return "".join(random.choice(digits) for _ in range(length)) | ||
|
||
|
||
def shape_test_for_stereo_disp( | ||
left: PIL.Image.Image, right: PIL.Image.Image, disparity: np.ndarray, valid_mask: np.ndarray | ||
): | ||
left_array = np.array(left) | ||
right_array = np.array(right) | ||
h, w, c = left_array.shape | ||
# check that left and right are the same size | ||
assert left_array.shape == right_array.shape | ||
# check general shapes | ||
assert c == 3 | ||
assert len(disparity.shape) == 3 | ||
assert len(valid_mask.shape) == 2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT or just FYI: this is equivalent to |
||
assert disparity.shape == (1, h, w) | ||
# check that valid mask is the same size as the disparity | ||
_, dh, dw = disparity.shape | ||
mh, mw = valid_mask.shape | ||
assert dh == mh | ||
assert dw == mw | ||
|
||
|
||
def shape_test_for_stereo_none(left: PIL.Image.Image, right: PIL.Image.Image, disparity: None, valid_mask: None): | ||
left_array = np.array(left) | ||
right_array = np.array(right) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here regarding |
||
_, _, c = left_array.shape | ||
# check that left and right are the same size | ||
assert left_array.shape == right_array.shape | ||
# check general shapes | ||
assert c == 3 | ||
assert disparity is None | ||
assert valid_mask is None | ||
|
||
|
||
def make_fake_pfm_file(h, w, file_name): | ||
values = list(range(3 * h * w)) | ||
# Note: we pack everything in little endian: -1.0, and "<" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could rely on
transforms.functional.get_dimensions()
to avoid converting into numpy arrays. It can handle tensors and PIL images.