1414from  .utils  import  _read_pfm , download_and_extract_archive , verify_str_arg 
1515from  .vision  import  VisionDataset 
1616
17- T1  =  Tuple [Image .Image , Image .Image , Optional [np .ndarray ], np .ndarray ]
18- T2  =  Tuple [Image .Image , Image .Image , Optional [np .ndarray ]]
17+ T1  =  tuple [Image .Image , Image .Image , Optional [np .ndarray ], np .ndarray ]
18+ T2  =  tuple [Image .Image , Image .Image , Optional [np .ndarray ]]
1919
2020__all__  =  ()
2121
@@ -65,11 +65,11 @@ def _scan_pairs(
6565        self ,
6666        paths_left_pattern : str ,
6767        paths_right_pattern : Optional [str ] =  None ,
68-     ) ->  List [ Tuple [str , Optional [str ]]]:
68+     ) ->  list [ tuple [str , Optional [str ]]]:
6969
7070        left_paths  =  list (sorted (glob (paths_left_pattern )))
7171
72-         right_paths : List [Union [None , str ]]
72+         right_paths : list [Union [None , str ]]
7373        if  paths_right_pattern :
7474            right_paths  =  list (sorted (glob (paths_right_pattern )))
7575        else :
@@ -92,7 +92,7 @@ def _scan_pairs(
9292        return  paths 
9393
9494    @abstractmethod  
95-     def  _read_disparity (self , file_path : str ) ->  Tuple [Optional [np .ndarray ], Optional [np .ndarray ]]:
95+     def  _read_disparity (self , file_path : str ) ->  tuple [Optional [np .ndarray ], Optional [np .ndarray ]]:
9696        # function that returns a disparity map and an occlusion map 
9797        pass 
9898
@@ -178,7 +178,7 @@ def __init__(self, root: Union[str, Path], transforms: Optional[Callable] = None
178178        disparities  =  self ._scan_pairs (left_disparity_pattern , right_disparity_pattern )
179179        self ._disparities  =  disparities 
180180
181-     def  _read_disparity (self , file_path : str ) ->  Tuple [np .ndarray , None ]:
181+     def  _read_disparity (self , file_path : str ) ->  tuple [np .ndarray , None ]:
182182        disparity_map  =  _read_pfm_file (file_path )
183183        disparity_map  =  np .abs (disparity_map )  # ensure that the disparity is positive 
184184        valid_mask  =  None 
@@ -257,7 +257,7 @@ def __init__(self, root: Union[str, Path], split: str = "train", transforms: Opt
257257        else :
258258            self ._disparities  =  list ((None , None ) for  _  in  self ._images )
259259
260-     def  _read_disparity (self , file_path : str ) ->  Tuple [Optional [np .ndarray ], None ]:
260+     def  _read_disparity (self , file_path : str ) ->  tuple [Optional [np .ndarray ], None ]:
261261        # test split has no disparity maps 
262262        if  file_path  is  None :
263263            return  None , None 
@@ -345,7 +345,7 @@ def __init__(self, root: Union[str, Path], split: str = "train", transforms: Opt
345345        else :
346346            self ._disparities  =  list ((None , None ) for  _  in  self ._images )
347347
348-     def  _read_disparity (self , file_path : str ) ->  Tuple [Optional [np .ndarray ], None ]:
348+     def  _read_disparity (self , file_path : str ) ->  tuple [Optional [np .ndarray ], None ]:
349349        # test split has no disparity maps 
350350        if  file_path  is  None :
351351            return  None , None 
@@ -549,7 +549,7 @@ def _read_img(self, file_path: Union[str, Path]) -> Image.Image:
549549        When ``use_ambient_views`` is True, the dataset will return at random one of ``[im1.png, im1E.png, im1L.png]`` 
550550        as the right image. 
551551        """ 
552-         ambient_file_paths : List [Union [str , Path ]]  # make mypy happy 
552+         ambient_file_paths : list [Union [str , Path ]]  # make mypy happy 
553553
554554        if  not  isinstance (file_path , Path ):
555555            file_path  =  Path (file_path )
@@ -565,7 +565,7 @@ def _read_img(self, file_path: Union[str, Path]) -> Image.Image:
565565            file_path  =  random .choice (ambient_file_paths )  # type: ignore 
566566        return  super ()._read_img (file_path )
567567
568-     def  _read_disparity (self , file_path : str ) ->  Union [Tuple [None , None ], Tuple [np .ndarray , np .ndarray ]]:
568+     def  _read_disparity (self , file_path : str ) ->  Union [tuple [None , None ], tuple [np .ndarray , np .ndarray ]]:
569569        # test split has not disparity maps 
570570        if  file_path  is  None :
571571            return  None , None 
@@ -694,7 +694,7 @@ def __init__(
694694            disparities  =  self ._scan_pairs (left_disparity_pattern , right_disparity_pattern )
695695            self ._disparities  +=  disparities 
696696
697-     def  _read_disparity (self , file_path : str ) ->  Tuple [np .ndarray , None ]:
697+     def  _read_disparity (self , file_path : str ) ->  tuple [np .ndarray , None ]:
698698        disparity_map  =  np .asarray (Image .open (file_path ), dtype = np .float32 )
699699        # unsqueeze the disparity map into (C, H, W) format 
700700        disparity_map  =  disparity_map [None , :, :] /  32.0 
@@ -788,13 +788,13 @@ def __init__(self, root: Union[str, Path], variant: str = "single", transforms:
788788            right_disparity_pattern  =  str (root  /  s  /  split_prefix [s ] /  "*.right.depth.png" )
789789            self ._disparities  +=  self ._scan_pairs (left_disparity_pattern , right_disparity_pattern )
790790
791-     def  _read_disparity (self , file_path : str ) ->  Tuple [np .ndarray , None ]:
791+     def  _read_disparity (self , file_path : str ) ->  tuple [np .ndarray , None ]:
792792        # (H, W) image 
793793        depth  =  np .asarray (Image .open (file_path ))
794794        # as per https://research.nvidia.com/sites/default/files/pubs/2018-06_Falling-Things/readme_0.txt 
795795        # in order to extract disparity from depth maps 
796796        camera_settings_path  =  Path (file_path ).parent  /  "_camera_settings.json" 
797-         with  open (camera_settings_path ,  "r" ) as  f :
797+         with  open (camera_settings_path ) as  f :
798798            # inverse of depth-from-disparity equation: depth = (baseline * focal) / (disparity * pixel_constant) 
799799            intrinsics  =  json .load (f )
800800            focal  =  intrinsics ["camera_settings" ][0 ]["intrinsic_settings" ]["fx" ]
@@ -911,7 +911,7 @@ def __init__(
911911            right_disparity_pattern  =  str (root  /  "disparity"  /  prefix_directories [variant ] /  "right"  /  "*.pfm" )
912912            self ._disparities  +=  self ._scan_pairs (left_disparity_pattern , right_disparity_pattern )
913913
914-     def  _read_disparity (self , file_path : str ) ->  Tuple [np .ndarray , None ]:
914+     def  _read_disparity (self , file_path : str ) ->  tuple [np .ndarray , None ]:
915915        disparity_map  =  _read_pfm_file (file_path )
916916        disparity_map  =  np .abs (disparity_map )  # ensure that the disparity is positive 
917917        valid_mask  =  None 
@@ -999,7 +999,7 @@ def __init__(self, root: Union[str, Path], pass_name: str = "final", transforms:
999999            disparity_pattern  =  str (root  /  "training"  /  "disparities"  /  "*"  /  "*.png" )
10001000            self ._disparities  +=  self ._scan_pairs (disparity_pattern , None )
10011001
1002-     def  _get_occlussion_mask_paths (self , file_path : str ) ->  Tuple [str , str ]:
1002+     def  _get_occlussion_mask_paths (self , file_path : str ) ->  tuple [str , str ]:
10031003        # helper function to get the occlusion mask paths 
10041004        # a path will look like  .../.../.../training/disparities/scene1/img1.png 
10051005        # we want to get something like .../.../.../training/occlusions/scene1/img1.png 
@@ -1020,7 +1020,7 @@ def _get_occlussion_mask_paths(self, file_path: str) -> Tuple[str, str]:
10201020
10211021        return  occlusion_path , outofframe_path 
10221022
1023-     def  _read_disparity (self , file_path : str ) ->  Union [Tuple [None , None ], Tuple [np .ndarray , np .ndarray ]]:
1023+     def  _read_disparity (self , file_path : str ) ->  Union [tuple [None , None ], tuple [np .ndarray , np .ndarray ]]:
10241024        if  file_path  is  None :
10251025            return  None , None 
10261026
@@ -1101,7 +1101,7 @@ def __init__(self, root: Union[str, Path], split: str = "train", transforms: Opt
11011101        right_disparity_pattern  =  str (root  /  "*"  /  "right_disp.png" )
11021102        self ._disparities  =  self ._scan_pairs (left_disparity_pattern , right_disparity_pattern )
11031103
1104-     def  _read_disparity (self , file_path : str ) ->  Tuple [np .ndarray , None ]:
1104+     def  _read_disparity (self , file_path : str ) ->  tuple [np .ndarray , None ]:
11051105        disparity_map  =  np .asarray (Image .open (file_path ), dtype = np .float32 )
11061106        # unsqueeze disparity to (C, H, W) 
11071107        disparity_map  =  disparity_map [None , :, :] /  1024.0 
@@ -1195,7 +1195,7 @@ def __init__(self, root: Union[str, Path], split: str = "train", transforms: Opt
11951195            disparity_pattern  =  str (root  /  anot_dir  /  "*"  /  "disp0GT.pfm" )
11961196            self ._disparities  =  self ._scan_pairs (disparity_pattern , None )
11971197
1198-     def  _read_disparity (self , file_path : str ) ->  Union [Tuple [None , None ], Tuple [np .ndarray , np .ndarray ]]:
1198+     def  _read_disparity (self , file_path : str ) ->  Union [tuple [None , None ], tuple [np .ndarray , np .ndarray ]]:
11991199        # test split has no disparity maps 
12001200        if  file_path  is  None :
12011201            return  None , None 
0 commit comments