Arulkumar03/Fox_Sheep_Detector_Computer_Vision_model
0
1# Copyright (c) Facebook, Inc. and its affiliates.2from iopath.common.file_io import HTTPURLHandler, OneDrivePathHandler, PathHandler3from iopath.common.file_io import PathManager as PathManagerBase4 5__all__ = ["PathManager", "PathHandler"]6 7 8PathManager = PathManagerBase()9"""10This is a detectron2 project-specific PathManager.11We try to stay away from global PathManager in fvcore as it12introduces potential conflicts among other libraries.13"""14 15 16class Detectron2Handler(PathHandler):17 """18 Resolve anything that's hosted under detectron2's namespace.19 """20 21 PREFIX = "detectron2://"22 S3_DETECTRON2_PREFIX = "https://dl.fbaipublicfiles.com/detectron2/"23 24 def _get_supported_prefixes(self):25 return [self.PREFIX]26 27 def _get_local_path(self, path, **kwargs):28 name = path[len(self.PREFIX) :]29 return PathManager.get_local_path(self.S3_DETECTRON2_PREFIX + name, **kwargs)30 31 def _open(self, path, mode="r", **kwargs):32 return PathManager.open(33 self.S3_DETECTRON2_PREFIX + path[len(self.PREFIX) :], mode, **kwargs34 )35 36 37PathManager.register_handler(HTTPURLHandler())38PathManager.register_handler(OneDrivePathHandler())39PathManager.register_handler(Detectron2Handler())40 