MMDetection 系列(一): 初步入门配置文件

编程入门 行业动态 更新时间:2024-10-18 14:23:00

MMDetection 系列(一): 初步入门<a href=https://www.elefans.com/category/jswz/34/1770506.html style=配置文件"/>

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 系列(一): 初步入门配置文件

本文发布于:2023-11-16 15:47:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626770.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:配置文件   入门   系列   MMDetection

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!