技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
single-image-inference【数据与研究】Safely use or adapt pytorch-semseg test.py for one-image semantic segmentation with trained checkpoints, dataset palette decoding, output mask creation, and optional DenseCRF.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when the task is to run, adapt, or debug test.py for a single RGB image and an existing trained checkpoint. It covers the inference CLI, checkpoint-name architecture parsing, dataset palette decoding, output image semantics, compatibility patches, and optional DenseCRF post-processing.
Route elsewhere:
training-and-evaluation.data-and-configs.model-zoo-and-apis.test.py.--model_path, --dataset, --img_norm / --no-img_norm, --dcrf / --no-dcrf, --img_path, and --out_path.icnetBN_cityscapes_best_model.pkl selects icnetBN; a name without _ is unsafe because the script's slicing logic will not recover the intended model id.root=None, is_transform=True, the chosen img_norm, and test_mode=True, then calls loader.decode_segmap(pred) to produce the colorized output mask.decode_segmap if a numeric label image is required.pspnet, icnet, and icnetBN, the input image is resized to odd spatial dimensions before model inference and the prediction is resized back to the original image size with nearest-neighbor interpolation.pydensecrf cannot be imported, but a --dcrf run still needs the package available and compatible.scipy.misc.imread, scipy.misc.imresize, and scipy.misc.imsave; modern environments often need a compatibility patch or a legacy SciPy/Pillow environment.Use the bundled dry-run helper before running real inference:
test.py command and warnings for unsafe checkpoint names, missing files, optional dependency risk, and PSPNet/ICNet odd-size behavior.Detailed recipes and adaptation notes are in references/workflows.md. Failure modes and fixes are in references/troubleshooting.md.
model_state entry._.decode_segmap uses the intended color palette.test.py command from a checkout or environment where test.py and ptsemseg are importable.pydensecrf, patch the helpers or disable DenseCRF using the guidance in the references.