"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "13a78b3cd3affcd9ab984bc24b9e07323c1ecb78"
Commit f3d05021 authored by Yanghan Wang's avatar Yanghan Wang Committed by Facebook GitHub Bot
Browse files

remove adet's default config from base runner

Reviewed By: zhanghang1989

Differential Revision: D28346653

fbshipit-source-id: d80a1f824b097c05029edb171739a4928e47e4d8
parent 0848c589
...@@ -4,13 +4,12 @@ ...@@ -4,13 +4,12 @@
import contextlib import contextlib
import logging import logging
import os
import mock import mock
import yaml import yaml
from d2go.utils.helper import reroute_config_path
from detectron2.config import CfgNode as _CfgNode from detectron2.config import CfgNode as _CfgNode
from fvcore.common.registry import Registry from fvcore.common.registry import Registry
from d2go.utils.helper import reroute_config_path
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -18,6 +17,7 @@ logger = logging.getLogger(__name__) ...@@ -18,6 +17,7 @@ logger = logging.getLogger(__name__)
def get_cfg_diff_table(cfg, original_cfg): def get_cfg_diff_table(cfg, original_cfg):
# print out the differences # print out the differences
from d2go.config import CfgNode from d2go.config import CfgNode
def _find_all_keys(obj): def _find_all_keys(obj):
assert isinstance(obj, CfgNode) assert isinstance(obj, CfgNode)
ret = [] ret = []
...@@ -47,6 +47,7 @@ def get_cfg_diff_table(cfg, original_cfg): ...@@ -47,6 +47,7 @@ def get_cfg_diff_table(cfg, original_cfg):
diff_table.append([full_key, old_value, new_value]) diff_table.append([full_key, old_value, new_value])
from tabulate import tabulate from tabulate import tabulate
table = tabulate( table = tabulate(
diff_table, diff_table,
tablefmt="pipe", tablefmt="pipe",
...@@ -54,7 +55,17 @@ def get_cfg_diff_table(cfg, original_cfg): ...@@ -54,7 +55,17 @@ def get_cfg_diff_table(cfg, original_cfg):
) )
return table return table
class CfgNode(_CfgNode): class CfgNode(_CfgNode):
@classmethod
def cast_from_other_class(cls, other_cfg):
"""Cast an instance of other CfgNode to D2Go's CfgNode (or its subclass)"""
new_cfg = CfgNode(other_cfg)
# copy all fields inside __dict__, this will preserve fields like __deprecated_keys__
for k, v in other_cfg.__dict__.items():
new_cfg.__dict__[k] = v
return new_cfg
def merge_from_file(self, cfg_filename: str, *args, **kwargs): def merge_from_file(self, cfg_filename: str, *args, **kwargs):
cfg_filename = reroute_config_path(cfg_filename) cfg_filename = reroute_config_path(cfg_filename)
with reroute_load_yaml_with_base(): with reroute_load_yaml_with_base():
...@@ -71,8 +82,11 @@ class CfgNode(_CfgNode): ...@@ -71,8 +82,11 @@ class CfgNode(_CfgNode):
# TODO: remove this by end of 2020. # TODO: remove this by end of 2020.
if cfg_other.get("MODEL", {}).get("FBNET_V2", {}).get("ARCH_DEF", None) == "": if cfg_other.get("MODEL", {}).get("FBNET_V2", {}).get("ARCH_DEF", None) == "":
import logging import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logger.warning("Default value for MODEL.FBNET_V2.ARCH_DEF has changed to []") logger.warning(
"Default value for MODEL.FBNET_V2.ARCH_DEF has changed to []"
)
cfg_other.MODEL.FBNET_V2.ARCH_DEF = [] cfg_other.MODEL.FBNET_V2.ARCH_DEF = []
return super().merge_from_other_cfg(cfg_other) return super().merge_from_other_cfg(cfg_other)
......
...@@ -15,7 +15,7 @@ import detectron2.utils.comm as comm ...@@ -15,7 +15,7 @@ import detectron2.utils.comm as comm
import mock import mock
import torch import torch
from d2go.config import ( from d2go.config import (
CfgNode as CN, CfgNode,
CONFIG_SCALING_METHOD_REGISTRY, CONFIG_SCALING_METHOD_REGISTRY,
temp_defrost, temp_defrost,
get_cfg_diff_table, get_cfg_diff_table,
...@@ -174,7 +174,15 @@ class BaseRunner(object): ...@@ -174,7 +174,15 @@ class BaseRunner(object):
from detectron2.config import get_cfg as get_d2_cfg from detectron2.config import get_cfg as get_d2_cfg
cfg = get_d2_cfg() cfg = get_d2_cfg()
cfg = CN(cfg) # upgrade from D2's CfgNode to D2Go's CfgNode cfg = CfgNode.cast_from_other_class(cfg) # upgrade from D2's CfgNode to D2Go's CfgNode
try:
from d2go.runner import get_unintentional_added_configs_during_runner_import
for key in get_unintentional_added_configs_during_runner_import():
cfg.register_deprecated_key(key)
except ImportError:
pass
cfg.SOLVER.AUTO_SCALING_METHODS = ["default_scale_d2_configs"] cfg.SOLVER.AUTO_SCALING_METHODS = ["default_scale_d2_configs"]
return cfg return cfg
...@@ -661,7 +669,7 @@ class GeneralizedRCNNRunner(Detectron2GoRunner): ...@@ -661,7 +669,7 @@ class GeneralizedRCNNRunner(Detectron2GoRunner):
@staticmethod @staticmethod
def get_default_cfg(): def get_default_cfg():
_C = super(GeneralizedRCNNRunner, GeneralizedRCNNRunner).get_default_cfg() _C = super(GeneralizedRCNNRunner, GeneralizedRCNNRunner).get_default_cfg()
_C.EXPORT_CAFFE2 = CN() _C.EXPORT_CAFFE2 = CfgNode()
_C.EXPORT_CAFFE2.USE_HEATMAP_MAX_KEYPOINT = False _C.EXPORT_CAFFE2.USE_HEATMAP_MAX_KEYPOINT = False
_C.RCNN_PREPARE_FOR_EXPORT = "default_rcnn_prepare_for_export" _C.RCNN_PREPARE_FOR_EXPORT = "default_rcnn_prepare_for_export"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment