配置文件"/>
MMDetection 系列(一): 初步入门配置文件
参考文档
不得不知的 MMDetection 学习路线(个人经验版)
轻松掌握 MMDetection 整体构建流程(一)
学习配置文件 MaskRCNN
配置文件的逻辑
整体来说,配置文件包含以下几个部分:
- 数据集和评测器配置
- 模型配置
- 训练和测试的配置
- 优化相关配置
- 钩子配置(TODO)
- 运行相关配置
配置文件最终都是为了适应 Runner 的构建。可以具体查看 runner 的类细节
- mmengine/runner/runner.py
- 执行器
- Runner API
配置参数查找
比如评测器:
val_evaluator = dict( # 验证过程使用的评测器type="CocoMetric", # 用于评估检测和实例分割的 AR、AP 和 mAP 的 coco 评价指标ann_file=data_root + "annotations/instances_val2017.json", # 标注文件路径metric=["bbox", "segm"], # 需要计算的评价指标,`bbox` 用于检测,`segm` 用于实例分割format_only=False,
)
test_evaluator = val_evaluator # 测试过程使用的评测器
type 参数对应着一个注册器。
mmengine 中 mmengine/registry/root.py 文件可以查看到所有根注册器。
__all__ = ['Registry', 'RUNNERS', 'RUNNER_CONSTRUCTORS', 'HOOKS', 'DATASETS','DATA_SAMPLERS', 'TRANSFORMS', 'MODELS', 'WEIGHT_INITIALIZERS','OPTIMIZERS', 'OPTIM_WRAPPER_CONSTRUCTORS', 'TASK_UTILS','PARAM_SCHEDULERS', 'METRICS', 'MODEL_WRAPPERS', 'OPTIM_WRAPPERS', 'LOOPS','VISBACKENDS', 'VISUALIZERS', 'LOG_PROCESSORS', 'EVALUATOR', 'INFERENCERS','DefaultScope', 'traverse_registry_tree', 'count_registered_modules','build_model_from_cfg', 'build_runner_from_cfg', 'build_from_cfg','build_scheduler_from_cfg', 'init_default_scope', 'FUNCTIONS', 'STRATEGIES'
]
配置文件中的 type 都被注册为相应的注册器,这里可以推断对应的 Metric, 而相应的type 一定是一个具体的函数或者类,然后在 mmdet 的核心代码文件夹中查找 metric 有可能存在的文件中,最后在 mmdet/evaluation/metrics/coco_metric.py 找到 CocoMetric. 通过查看 这个类的签名,可以找到相应的配置参数,以及配置参数的说明。
class CocoMetric(BaseMetric):"""COCO evaluation metric.Evaluate AR, AP, and mAP for detection tasks including proposal/boxdetection and instance segmentation. Please refer to for more details.Args:ann_file (str, optional): Path to the coco format annotation file.If not specified, ground truth annotations from the dataset willbe converted to coco format. Defaults to None.metric (str | List[str]): Metrics to be evaluated. Valid metricsinclude 'bbox', 'segm', 'proposal', and 'proposal_fast'.Defaults to 'bbox'.classwise (bool): Whether to evaluate the metric class-wise.Defaults to False.proposal_nums (Sequence[int]): Numbers of proposals to be evaluated.Defaults to (100, 300, 1000).iou_thrs (float | List[float], optional): IoU threshold to compute APand AR. If not specified, IoUs from 0.5 to 0.95 will be used.Defaults to None.metric_items (List[str], optional): Metric result names to berecorded in the evaluation result. Defaults to None.format_only (bool): Format the output results without performevaluation. It is useful when you want to format the resultto a specific format and submit it to the test server.Defaults to False.outfile_prefix (str, optional): The prefix of json files. It includesthe file path and the prefix of filename, e.g., "a/b/prefix".If not specified, a temp file will be created. Defaults to None.file_client_args (dict, optional): Arguments to instantiate thecorresponding backend in mmdet <= 3.0.0rc6. Defaults to None.backend_args (dict, optional): Arguments to instantiate thecorresponding backend. Defaults to None.collect_device (str): Device name used for collecting results fromdifferent ranks during distributed training. Must be 'cpu' or'gpu'. Defaults to 'cpu'.prefix (str, optional): The prefix that will be added in the metricnames to disambiguate homonymous metrics of different evaluators.If prefix is not provided in the argument, self.default_prefixwill be used instead. Defaults to None.sort_categories (bool): Whether sort categories in annotations. Onlyused for `Objects365V1Dataset`. Defaults to False.use_mp_eval (bool): Whether to use mul-processing evaluation"""default_prefix: Optional[str] = 'coco'def __init__(self,ann_file: Optional[str] = None,metric: Union[str, List[str]] = 'bbox',classwise: bool = False,proposal_nums: Sequence[int] = (100, 300, 1000),iou_thrs: Optional[Union[float, Sequence[float]]] = None,metric_items: Optional[Sequence[str]] = None,format_only: bool = False,outfile_prefix: Optional[str] = None,file_client_args: dict = None,backend_args: dict = None,collect_device: str = 'cpu',prefix: Optional[str] = None,sort_categories: bool = False,use_mp_eval: bool = False) -> None:
框架的架构
’
更多推荐
MMDetection 系列(一): 初步入门配置文件
发布评论