1- from fvcore .common .file_io import PathHandler , PathManager , HTTPURLHandler
1+ from iopath .common .file_io import PathHandler , PathManager , HTTPURLHandler
2+ from iopath .common .file_io import PathManager as PathManagerBase
3+ # A trick learned from https://github.com/facebookresearch/detectron2/blob/65faeb4779e4c142484deeece18dc958c5c9ad18/detectron2/utils/file_io.py#L3
24
35MODEL_CATALOG = {
46 'HJDataset' : {
@@ -61,7 +63,7 @@ class LayoutParserHandler(PathHandler):
6163 def _get_supported_prefixes (self ):
6264 return [self .PREFIX ]
6365
64- def _get_local_path (self , path ):
66+ def _get_local_path (self , path , ** kwargs ):
6567 model_name = path [len (self .PREFIX ):]
6668 dataset_name , * model_name , data_type = model_name .split ('/' )
6769
@@ -71,11 +73,12 @@ def _get_local_path(self, path):
7173 model_url = CONFIG_CATALOG [dataset_name ]['/' .join (model_name )]
7274 else :
7375 raise ValueError (f"Unknown data_type { data_type } " )
74- return PathManager .get_local_path (model_url )
76+ return PathManager .get_local_path (model_url , ** kwargs )
7577
7678 def _open (self , path , mode = "r" , ** kwargs ):
7779 return PathManager .open (self ._get_local_path (path ), mode , ** kwargs )
7880
7981
82+ PathManager = PathManagerBase ()
8083PathManager .register_handler (DropboxHandler ())
8184PathManager .register_handler (LayoutParserHandler ())
0 commit comments