|
@@ -41,12 +41,12 @@ class StereoMatchingDataset(ABC, VisionDataset):
|
|
|
For training splits generally the datasets provide a minimal guarantee of
|
|
For training splits generally the datasets provide a minimal guarantee of
|
|
|
images: (``PIL.Image``, ``PIL.Image``)
|
|
images: (``PIL.Image``, ``PIL.Image``)
|
|
|
disparities: (``np.ndarray``, ``None``) with shape (1, H, W)
|
|
disparities: (``np.ndarray``, ``None``) with shape (1, H, W)
|
|
|
- Optionally, based on the dataset, it can return a ``mask`` as well:
|
|
|
|
|
|
|
+ Optionally, based on the dataset, it can return a ``ins`` as well:
|
|
|
valid_masks: (``np.ndarray | None``, ``None``) with shape (H, W)
|
|
valid_masks: (``np.ndarray | None``, ``None``) with shape (H, W)
|
|
|
For some test splits, the datasets provides outputs that look like:
|
|
For some test splits, the datasets provides outputs that look like:
|
|
|
imgaes: (``PIL.Image``, ``PIL.Image``)
|
|
imgaes: (``PIL.Image``, ``PIL.Image``)
|
|
|
disparities: (``None``, ``None``)
|
|
disparities: (``None``, ``None``)
|
|
|
- Optionally, based on the dataset, it can return a ``mask`` as well:
|
|
|
|
|
|
|
+ Optionally, based on the dataset, it can return a ``ins`` as well:
|
|
|
valid_masks: (``None``, ``None``)
|
|
valid_masks: (``None``, ``None``)
|
|
|
"""
|
|
"""
|
|
|
super().__init__(root=root)
|
|
super().__init__(root=root)
|
|
@@ -104,7 +104,7 @@ class StereoMatchingDataset(ABC, VisionDataset):
|
|
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
|
tuple: A 3 or 4-tuple with ``(img_left, img_right, disparity, Optional[valid_mask])`` where ``valid_mask``
|
|
tuple: A 3 or 4-tuple with ``(img_left, img_right, disparity, Optional[valid_mask])`` where ``valid_mask``
|
|
|
- can be a numpy boolean mask of shape (H, W) if the dataset provides a file
|
|
|
|
|
|
|
+ can be a numpy boolean ins of shape (H, W) if the dataset provides a file
|
|
|
indicating which disparity pixels are valid. The disparity is a numpy array of
|
|
indicating which disparity pixels are valid. The disparity is a numpy array of
|
|
|
shape (1, H, W) and the images are PIL images. ``disparity`` is None for
|
|
shape (1, H, W) and the images are PIL images. ``disparity`` is None for
|
|
|
datasets on which for ``split="test"`` the authors did not provide annotations.
|
|
datasets on which for ``split="test"`` the authors did not provide annotations.
|
|
@@ -278,7 +278,7 @@ class Kitti2012Stereo(StereoMatchingDataset):
|
|
|
tuple: A 4-tuple with ``(img_left, img_right, disparity, valid_mask)``.
|
|
tuple: A 4-tuple with ``(img_left, img_right, disparity, valid_mask)``.
|
|
|
The disparity is a numpy array of shape (1, H, W) and the images are PIL images.
|
|
The disparity is a numpy array of shape (1, H, W) and the images are PIL images.
|
|
|
``valid_mask`` is implicitly ``None`` if the ``transforms`` parameter does not
|
|
``valid_mask`` is implicitly ``None`` if the ``transforms`` parameter does not
|
|
|
- generate a valid mask.
|
|
|
|
|
|
|
+ generate a valid ins.
|
|
|
Both ``disparity`` and ``valid_mask`` are ``None`` if the dataset split is test.
|
|
Both ``disparity`` and ``valid_mask`` are ``None`` if the dataset split is test.
|
|
|
"""
|
|
"""
|
|
|
return cast(T1, super().__getitem__(index))
|
|
return cast(T1, super().__getitem__(index))
|
|
@@ -366,7 +366,7 @@ class Kitti2015Stereo(StereoMatchingDataset):
|
|
|
tuple: A 4-tuple with ``(img_left, img_right, disparity, valid_mask)``.
|
|
tuple: A 4-tuple with ``(img_left, img_right, disparity, valid_mask)``.
|
|
|
The disparity is a numpy array of shape (1, H, W) and the images are PIL images.
|
|
The disparity is a numpy array of shape (1, H, W) and the images are PIL images.
|
|
|
``valid_mask`` is implicitly ``None`` if the ``transforms`` parameter does not
|
|
``valid_mask`` is implicitly ``None`` if the ``transforms`` parameter does not
|
|
|
- generate a valid mask.
|
|
|
|
|
|
|
+ generate a valid ins.
|
|
|
Both ``disparity`` and ``valid_mask`` are ``None`` if the dataset split is test.
|
|
Both ``disparity`` and ``valid_mask`` are ``None`` if the dataset split is test.
|
|
|
"""
|
|
"""
|
|
|
return cast(T1, super().__getitem__(index))
|
|
return cast(T1, super().__getitem__(index))
|
|
@@ -573,7 +573,7 @@ class Middlebury2014Stereo(StereoMatchingDataset):
|
|
|
disparity_map = _read_pfm_file(file_path)
|
|
disparity_map = _read_pfm_file(file_path)
|
|
|
disparity_map = np.abs(disparity_map) # ensure that the disparity is positive
|
|
disparity_map = np.abs(disparity_map) # ensure that the disparity is positive
|
|
|
disparity_map[disparity_map == np.inf] = 0 # remove infinite disparities
|
|
disparity_map[disparity_map == np.inf] = 0 # remove infinite disparities
|
|
|
- valid_mask = (disparity_map > 0).squeeze(0) # mask out invalid disparities
|
|
|
|
|
|
|
+ valid_mask = (disparity_map > 0).squeeze(0) # ins out invalid disparities
|
|
|
return disparity_map, valid_mask
|
|
return disparity_map, valid_mask
|
|
|
|
|
|
|
|
def _download_dataset(self, root: str) -> None:
|
|
def _download_dataset(self, root: str) -> None:
|
|
@@ -712,7 +712,7 @@ class CREStereo(StereoMatchingDataset):
|
|
|
tuple: A 4-tuple with ``(img_left, img_right, disparity, valid_mask)``.
|
|
tuple: A 4-tuple with ``(img_left, img_right, disparity, valid_mask)``.
|
|
|
The disparity is a numpy array of shape (1, H, W) and the images are PIL images.
|
|
The disparity is a numpy array of shape (1, H, W) and the images are PIL images.
|
|
|
``valid_mask`` is implicitly ``None`` if the ``transforms`` parameter does not
|
|
``valid_mask`` is implicitly ``None`` if the ``transforms`` parameter does not
|
|
|
- generate a valid mask.
|
|
|
|
|
|
|
+ generate a valid ins.
|
|
|
"""
|
|
"""
|
|
|
return cast(T1, super().__getitem__(index))
|
|
return cast(T1, super().__getitem__(index))
|
|
|
|
|
|
|
@@ -1001,7 +1001,7 @@ class SintelStereo(StereoMatchingDataset):
|
|
|
self._disparities += self._scan_pairs(disparity_pattern, None)
|
|
self._disparities += self._scan_pairs(disparity_pattern, None)
|
|
|
|
|
|
|
|
def _get_occlussion_mask_paths(self, file_path: str) -> Tuple[str, str]:
|
|
def _get_occlussion_mask_paths(self, file_path: str) -> Tuple[str, str]:
|
|
|
- # helper function to get the occlusion mask paths
|
|
|
|
|
|
|
+ # helper function to get the occlusion ins paths
|
|
|
# a path will look like .../.../.../training/disparities/scene1/img1.png
|
|
# a path will look like .../.../.../training/disparities/scene1/img1.png
|
|
|
# we want to get something like .../.../.../training/occlusions/scene1/img1.png
|
|
# we want to get something like .../.../.../training/occlusions/scene1/img1.png
|
|
|
fpath = Path(file_path)
|
|
fpath = Path(file_path)
|
|
@@ -1014,10 +1014,10 @@ class SintelStereo(StereoMatchingDataset):
|
|
|
outofframe_path = str(sampledir / "outofframe" / scenedir.name / basename)
|
|
outofframe_path = str(sampledir / "outofframe" / scenedir.name / basename)
|
|
|
|
|
|
|
|
if not os.path.exists(occlusion_path):
|
|
if not os.path.exists(occlusion_path):
|
|
|
- raise FileNotFoundError(f"Occlusion mask {occlusion_path} does not exist")
|
|
|
|
|
|
|
+ raise FileNotFoundError(f"Occlusion ins {occlusion_path} does not exist")
|
|
|
|
|
|
|
|
if not os.path.exists(outofframe_path):
|
|
if not os.path.exists(outofframe_path):
|
|
|
- raise FileNotFoundError(f"Out of frame mask {outofframe_path} does not exist")
|
|
|
|
|
|
|
+ raise FileNotFoundError(f"Out of frame ins {outofframe_path} does not exist")
|
|
|
|
|
|
|
|
return occlusion_path, outofframe_path
|
|
return occlusion_path, outofframe_path
|
|
|
|
|
|
|
@@ -1218,7 +1218,7 @@ class ETH3DStereo(StereoMatchingDataset):
|
|
|
tuple: A 4-tuple with ``(img_left, img_right, disparity, valid_mask)``.
|
|
tuple: A 4-tuple with ``(img_left, img_right, disparity, valid_mask)``.
|
|
|
The disparity is a numpy array of shape (1, H, W) and the images are PIL images.
|
|
The disparity is a numpy array of shape (1, H, W) and the images are PIL images.
|
|
|
``valid_mask`` is implicitly ``None`` if the ``transforms`` parameter does not
|
|
``valid_mask`` is implicitly ``None`` if the ``transforms`` parameter does not
|
|
|
- generate a valid mask.
|
|
|
|
|
|
|
+ generate a valid ins.
|
|
|
Both ``disparity`` and ``valid_mask`` are ``None`` if the dataset split is test.
|
|
Both ``disparity`` and ``valid_mask`` are ``None`` if the dataset split is test.
|
|
|
"""
|
|
"""
|
|
|
return cast(T2, super().__getitem__(index))
|
|
return cast(T2, super().__getitem__(index))
|