协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
model-building【开发与工程】Create and debug segmentation_models_pytorch model architectures, create_model calls, output shapes, auxiliary heads, and encoder freezing.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when the task asks to create, choose, inspect, or debug a segmentation_models_pytorch semantic segmentation model. SMP models are PyTorch torch.nn.Module objects that consume NCHW tensors and return segmentation masks, or (mask, label) when an auxiliary classification head is enabled.
smp.create_model, output contracts, and encoder freeze helpers.Unet, FPN, DeepLabV3Plus, Segformer, DPT, and the other SMP architectures.smp.Unet, smp.FPN, smp.DeepLabV3Plus, or another architecture class when the architecture is fixed in code.smp.create_model(arch="unet", encoder_name="resnet34", encoder_weights=None, in_channels=1, classes=1) for config-driven architecture selection.in_channels to the input tensor channel count and classes to the number of mask channels the model should emit.aux_params={"pooling": "avg", "classes": label_count, "dropout": 0.5, "activation": "sigmoid"} and unpack mask, label = model(x).model.freeze_encoder() before decoder-only fine-tuning and model.unfreeze_encoder() when full-model training should resume.encoder_weights=None by default before wiring the model into a training or export workflow.encoder_name discovery, pretrained preprocessing functions, and input normalization belong in Encoders And Preprocessing.import torch
import segmentation_models_pytorch as smp
model = smp.create_model(
arch="unet",
encoder_name="resnet34",
encoder_weights=None,
in_channels=1,
classes=1,
).eval()
x = torch.zeros(1, 1, 64, 64)
with torch.inference_mode():
mask = model(x)
assert tuple(mask.shape) == (1, 1, 64, 64)