协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
model-architecture【开发与工程】Understand and safely smoke-test U-2-Net model variants, side outputs, builders, and checkpoint-loading decisions.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when the task is to choose, instantiate, smoke-test, or diagnose U-2-Net model architectures. It covers the original U2NET and U2NETP classes, the refactored U2NET_full() and U2NET_lite() builders, seven-output forward semantics, and safe checkpoint/device loading decisions.
salient-object-inference.portrait-workflows.data-and-training.--repo-root.model.U2NET(in_ch=3, out_ch=1) and model.U2NETP(in_ch=3, out_ch=1).model.u2net_refactor.U2NET_full() and model.u2net_refactor.U2NET_lite().(N, 3, H, W) produces seven sigmoid probability maps. For out_ch=1, each output is shaped (N, 1, H, W). The first output is the fused prediction; the remaining six are side outputs.U2NETP(3, 1) for quick CPU smoke tests. Use U2NET(3, 1) for official full-size, human-segmentation, and portrait checkpoints unless a checkpoint explicitly targets U2NETP.scripts/smoke_architecture.py: run this to verify imports and a tiny forward pass without pretrained weights.python scripts/smoke_architecture.py \
--model u2netp \
--height 64 \
--width 64 \
--device cpu
The command prints JSON with the selected device, input shape, output count, and output tensor shapes. Request --device cuda only when the local PyTorch build reports CUDA as available; otherwise the helper fails clearly instead of silently falling back.
--model u2netp --device cpu.u2net.pth, human segmentation, or portrait weights? Instantiate U2NET(3, 1) unless evidence says the checkpoint targets U2NETP.out_ch, original-vs-refactor implementation, and CPU/CUDA map_location before changing strict loading.