feat(utils): 配置继承、注册表、日志与 Nvidia GPU 守卫

- config: yaml `_base_` 继承 + 深度合并 + 命令行 `--set a.b.c=value` 覆盖,检测循环引用
- registry: 组件按名注册与构建,模型/数据集共用
- device: require_cuda() 守卫,按 CLAUDE.md 约定禁止在无 Nvidia GPU 的设备上训练;
  评估与导出走 resolve_device() 允许 CPU
- labels: multilabel / multiclass 两种图像级标签形式的共用定义
- logging / seed: 控制台+文件日志、随机种子与 cudnn 确定性

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Shaun Zhou
2026-09-02 17:54:55 +08:00
co-authored by Claude Opus 5
parent 0645fc19f7
commit f4eff8beee
7 changed files with 327 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
"""通用工具:配置、注册表、日志、随机种子、设备检查。"""
from utils.config import Config, load_config
from utils.device import require_cuda, resolve_device
from utils.labels import LABEL_MODES, MULTICLASS, MULTILABEL, check_label_mode
from utils.logging import get_logger, setup_logging
from utils.registry import Registry
from utils.seed import seed_everything
__all__ = [
"Config",
"load_config",
"require_cuda",
"resolve_device",
"LABEL_MODES",
"MULTILABEL",
"MULTICLASS",
"check_label_mode",
"get_logger",
"setup_logging",
"Registry",
"seed_everything",
]