Returns: bool: whether the arguments contain CfgNode and should be considered forwarded to from_config.
(*args, **kwargs)
| 93 | return wrapper |
| 94 | |
| 95 | def _called_with_cfg(*args, **kwargs): |
| 96 | """ |
| 97 | Returns: |
| 98 | bool: whether the arguments contain CfgNode and should be considered |
| 99 | forwarded to from_config. |
| 100 | """ |
| 101 | from omegaconf import DictConfig, OmegaConf, ListConfig |
| 102 | # from detectron2.config import LazyConfig |
| 103 | |
| 104 | if len(args) and (isinstance(args[0], (dict)) or (isinstance(args[0], (DictConfig)))): |
| 105 | return True |
| 106 | if isinstance(kwargs.pop("cfg", None), (dict)): |
| 107 | return True |
| 108 | # `from_config`'s first argument is forced to be "cfg". |
| 109 | # So the above check covers all cases. |
| 110 | return False |
| 111 | |
| 112 | def _get_args_from_config(from_config_func, *args, **kwargs): |
| 113 | """ |