预留任务与扩展
ReservedTASK_REGISTRY 任务注册规范、预留 Runner 占位机制以及五大任务 Results 容器数据结构。
任务注册与调度规范
Detrium 通过 TASK_REGISTRY(TaskSpec)将每种任务与对应的四个执行器以及评估指标类绑定在一起:
trainer(继承BaseTrainer):负责执行fit()训练闭环;validator(继承BaseValidator):负责执行val()指标评估;predictor(继承BasePredictor):负责执行predict()推理并返回Results;exporter(继承BaseExporter):负责执行export()模型导出。
对于 segment、semseg、pose、classify、obb 五项预留任务,框架通过 make_reserved_task_spec 生成带有完整类型注解的占位 TaskSpec(implemented=False);在尚未实现具体模型前调用其训练或推理方法,会抛出 NotImplementedError。
预留 Results 容器与张量布局
这 5 项任务的 Results 输出容器已在 results.py 中完成定义、设备迁移(.cpu() / .numpy())与单元测试覆盖:
| 容器类 | 所属任务 | 内部张量形状与语义 | 常用快捷属性 |
|---|---|---|---|
Masks |
segment |
(N, H, W) 二值或软实例掩码 |
.data, .shape, .xy(或与 boxes 联动) |
SemSeg |
semseg |
(H, W) 或 (C, H, W) 语义分割图 |
.data, .shape, .cpu(), .numpy() |
Keypoints |
pose |
(N, K, 2) 或 (N, K, 3) [x, y, conf] |
.xy, .xyn, .conf |
Probs |
classify |
(num_classes,) 类别概率分布向量 |
.top1, .top5, .top1conf, .top5conf |
OBB |
obb |
(N, 7) [cx, cy, w, h, angle, conf, cls] |
.xywhr, .xyxyxyxy, .conf, .cls |