AGENT SKILL

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.

License 许可
MIT
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
single-image-inference
license
MIT
metadata
{ "disco-role": "operating" }
description
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.
disable-model-invocation
true

02 资源文件 3

03 SKILL.md 正文

Single Image Inference

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 commands, checkpoint production, validation metrics, and resume behavior belong to training-and-evaluation.
  • Dataset filesystem layouts, YAML config authoring, and dataset split preparation belong to data-and-configs.
  • Model constructor signatures, registry internals, and architecture API details belong to model-zoo-and-apis.

Core operating facts

  • The source inference entry point is test.py.
  • Supported CLI flags are --model_path, --dataset, --img_norm / --no-img_norm, --dcrf / --no-dcrf, --img_path, and --out_path.
  • The architecture id is parsed from the checkpoint basename before the first underscore. A checkpoint named 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.
  • The script constructs the dataset loader with 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.
  • The saved output is a dataset-palettized RGB segmentation visualization, not a raw class-index mask. Adapt the script before decode_segmap if a numeric label image is required.
  • For 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.
  • DenseCRF is optional. The source script prints a warning if pydensecrf cannot be imported, but a --dcrf run still needs the package available and compatible.
  • The original image helper calls use legacy scipy.misc.imread, scipy.misc.imresize, and scipy.misc.imsave; modern environments often need a compatibility patch or a legacy SciPy/Pillow environment.

Safe command construction

Use the bundled dry-run helper before running real inference:

  • scripts/build_inference_command.py validates the dataset key, checkpoint basename pattern, image path, output parent, normalization flag, and DenseCRF selection without loading images, checkpoints, datasets, or models.
  • It prints a ready-to-run 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.

Minimal workflow

  1. Confirm you already have a trained pytorch-semseg checkpoint containing a model_state entry.
  2. Confirm the checkpoint basename begins with a supported architecture id followed by _.
  3. Choose the matching dataset key so decode_segmap uses the intended color palette.
  4. Run the bundled command builder from this sub-skill directory, or pass its path from your working directory.
  5. Run the printed test.py command from a checkout or environment where test.py and ptsemseg are importable.
  6. If the run fails before inference because of SciPy or pydensecrf, patch the helpers or disable DenseCRF using the guidance in the references.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351