计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
prediction-evaluation【效率与协作】Use Pytorch-UNet prediction, mask conversion, evaluation, and Dice metric workflows.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when the task is about running or adapting Pytorch-UNet inference, saving predicted mask images, visualizing predictions, computing validation Dice, or debugging prediction/evaluation shape and palette issues.
predict.py interface: --model, --input, --output, --viz, --no-save, --mask-threshold, --scale, --bilinear, and --classes.predict_img(net, full_img, device, scale_factor=1, out_threshold=0.5).mask_to_image(mask, mask_values).mask_values metadata during prediction output conversion.evaluate(net, dataloader, device, amp) and Dice helpers: dice_coeff, multiclass_dice_coeff, and dice_loss.model-api.data-training when those files are present.Run scripts/prediction_smoke.py from an environment where the Pytorch-UNet imports resolve. The script creates a tiny synthetic image and temporary dummy UNet checkpoint with mask_values, loads it, calls predict_img and mask_to_image, validates output size and class IDs, optionally saves a mask, and prints JSON. It performs no downloads and uses CPU by default.
Example smoke commands from this sub-skill directory:
python scripts/prediction_smoke.py
python scripts/prediction_smoke.py --save-mask smoke_mask.png
Use scripts/prediction_cli_wrapper.py as a dry-run-first wrapper for a user-provided Pytorch-UNet checkout. Use it to preview the underlying predict.py command and only pass --execute after the user approves reading checkpoints/images and writing masks.
--classes, --bilinear, and model construction must match the saved weights. Keep the popped mask_values for output conversion.n_classes == 1 uses sigmoid plus --mask-threshold; n_classes > 1 uses channel argmax and ignores --mask-threshold.UNet(n_channels=3, ...); use the API route and a matching checkpoint for grayscale or non-RGB inputs.mask_to_image maps predicted class IDs through mask_values; mismatched or too-short palettes silently leave unmapped IDs as zero.{"image": tensor, "mask": tensor} with label indices already mapped into the expected class range.