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


Python cfg.is_immutable方法代碼示例

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


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

示例1: configure_bbox_reg_weights

# 需要導入模塊: from detectron.core.config import cfg [as 別名]
# 或者: from detectron.core.config.cfg import is_immutable [as 別名]
def configure_bbox_reg_weights(model, saved_cfg):
    """Compatibility for old models trained with bounding box regression
    mean/std normalization (instead of fixed weights).
    """
    if 'MODEL' not in saved_cfg or 'BBOX_REG_WEIGHTS' not in saved_cfg.MODEL:
        logger.warning('Model from weights file was trained before config key '
                       'MODEL.BBOX_REG_WEIGHTS was added. Forcing '
                       'MODEL.BBOX_REG_WEIGHTS = (1., 1., 1., 1.) to ensure '
                       'correct **inference** behavior.')
        # Generally we don't allow modifying the config, but this is a one-off
        # hack to support some very old models
        is_immutable = cfg.is_immutable()
        cfg.immutable(False)
        cfg.MODEL.BBOX_REG_WEIGHTS = (1., 1., 1., 1.)
        cfg.immutable(is_immutable)
        logger.info('New config:')
        logger.info(pprint.pformat(cfg))
        assert not model.train, (
            'This model was trained with an older version of the code that '
            'used bounding box regression mean/std normalization. It can no '
            'longer be used for training. To upgrade it to a trainable model '
            'please use fb/compat/convert_bbox_reg_normalized_model.py.'
        ) 
開發者ID:yihui-he,項目名稱:KL-Loss,代碼行數:25,代碼來源:net.py


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