當前位置: 首頁>>代碼示例>>Python>>正文


Python model_zoo.cache_url方法代碼示例

本文整理匯總了Python中maskrcnn_benchmark.utils.model_zoo.cache_url方法的典型用法代碼示例。如果您正苦於以下問題:Python model_zoo.cache_url方法的具體用法?Python model_zoo.cache_url怎麽用?Python model_zoo.cache_url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maskrcnn_benchmark.utils.model_zoo的用法示例。


在下文中一共展示了model_zoo.cache_url方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _load_file

# 需要導入模塊: from maskrcnn_benchmark.utils import model_zoo [as 別名]
# 或者: from maskrcnn_benchmark.utils.model_zoo import cache_url [as 別名]
def _load_file(self, f):
        # catalog lookup
        if f.startswith("catalog://"):
            paths_catalog = import_file(
                "maskrcnn_benchmark.config.paths_catalog", self.cfg.PATHS_CATALOG, True
            )
            catalog_f = paths_catalog.ModelCatalog.get(f[len("catalog://") :])
            self.logger.info("{} points to {}".format(f, catalog_f))
            f = catalog_f
        # download url files
        if f.startswith("http"):
            # if the file is a url path, download it and cache it
            cached_f = cache_url(f)
            self.logger.info("url {} cached in {}".format(f, cached_f))
            f = cached_f
        # convert Caffe2 checkpoint from pkl
        if f.endswith(".pkl"):
            return load_c2_format(self.cfg, f)
        # load native detectron.pytorch checkpoint
        loaded = super(DetectronCheckpointer, self)._load_file(f)
        if "model" not in loaded:
            loaded = dict(model=loaded)
        return loaded 
開發者ID:Res2Net,項目名稱:Res2Net-maskrcnn,代碼行數:25,代碼來源:checkpoint.py

示例2: _load_file

# 需要導入模塊: from maskrcnn_benchmark.utils import model_zoo [as 別名]
# 或者: from maskrcnn_benchmark.utils.model_zoo import cache_url [as 別名]
def _load_file(self, f):
        # catalog lookup
        if f.startswith("catalog://"):
            paths_catalog = import_file(
                "maskrcnn_benchmark.config.paths_catalog", self.cfg.PATHS_CATALOG, True
            )
            catalog_f = paths_catalog.ModelCatalog.get(f[len("catalog://") :])
            self.logger.info("{} points to {}".format(f, catalog_f))
            f = catalog_f
        # download url files
        if f.startswith("http"):
            # if the file is a url path, download it and cache it
            cached_f = cache_url(f, model_dir=self.cfg.MODEL.PRETRAINED_MODELS)
            self.logger.info("url {} cached in {}".format(f, cached_f))
            f = cached_f
        # convert Caffe2 checkpoint from pkl
        if f.endswith(".pkl"):
            return load_c2_format(self.cfg, f)
        # load native detectron.pytorch checkpoint
        loaded = super(DetectronCheckpointer, self)._load_file(f)
        if "model" not in loaded:
            loaded = dict(model=loaded)
        return loaded 
開發者ID:zjhuang22,項目名稱:maskscoring_rcnn,代碼行數:25,代碼來源:checkpoint.py


注:本文中的maskrcnn_benchmark.utils.model_zoo.cache_url方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。