面向实时设备部署,全程只用 convolution,不含 attention / transformer。 - backbones: 自研 tiny_conv(深度可分离,默认)与 torchvision 封装(resnet/mobilenet/shufflenet) - necks: nearest 上采样 + 3x3 卷积,把特征恢复到 stride 4,兼顾小缺陷定位与速度 - heads: anchor-free 中心点定位头(heatmap + wh + offset)与图像级分类头; 分类头输出维度随 label_mode 切换(多类多热 / 单类互斥含背景位) - postprocess: 3x3 max-pool 峰值抑制替代 NMS 循环,无循环、可导出 TensorRT / OpenVINO Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
16 lines
369 B
Python
16 lines
369 B
Python
"""按配置构建模型。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Mapping
|
|
from typing import Any
|
|
|
|
from torch import nn
|
|
|
|
from models.registry import MODELS
|
|
|
|
|
|
def build_model(cfg: Mapping[str, Any]) -> nn.Module:
|
|
"""`cfg` 至少包含 `name` 与 `num_classes`,其余透传给模型构造函数。"""
|
|
return MODELS.build(dict(cfg))
|