AGENT SKILL

segmentation

Operate PaddleViT semantic_segmentation for SETR, UperNet, DPT, Segmenter, Trans2Seg, SegFormer, and TopFormer: select compatible configs, validate dataset layouts, run train/val/demo inference, manage checkpoints and metrics, and keep conversion and GPU-expense boundaries explicit.

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

01 前言 Front Matter

name
segmentation
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Operate PaddleViT semantic_segmentation for SETR, UperNet, DPT, Segmenter, Trans2Seg, SegFormer, and TopFormer: select compatible configs, validate dataset layouts, run train/val/demo inference, manage checkpoints and metrics, and keep conversion and GPU-expense boundaries explicit.
disable-model-invocation
true

02 资源文件 6

03 SKILL.md 正文

PaddleViT semantic segmentation

Use this operating skill for the standalone semantic_segmentation/ toolkit: pixel-wise semantic prediction, dataset preparation, model-family/config selection, training, validation, directory demo inference, checkpoint resume, metrics, and dataset conversion boundaries. It is not a general export skill and it does not download data or weights.

Route before acting

Establish these facts before constructing a command:

  1. Operation: train, single-scale validation, multi-scale validation, or unlabeled directory demo.
  2. Config: an existing YAML under semantic_segmentation/configs/ (or a copied, explicitly reviewed variant). Treat DATA.DATASET, DATA.DATA_PATH, DATA.NUM_CLASSES, DATA.CROP_SIZE, model wiring, loss, validation geometry, and SAVE_DIR as one contract.
  3. Data: the exact root and split. Do not infer the dataset from a model name or checkpoint filename.
  4. Weights: a full segmentation --model_path, an optional backbone --pretrained_backbone, a training --resume pair, or a deliberate train-from-scratch choice.
  5. Compute: CPU parser/layout checks versus CPU model allocation versus a real GPU forward; requested GPU count and an explicit budget for slide, multi-scale, distributed, or training work.
  6. Output ownership: SAVE_DIR and demo --results_dir. The source demo recursively deletes an existing results directory; never point it at valuable data without explicit approval.

Run the source-independent preflight before importing PaddleViT:

python skills/disco/paddlevit/sub-skills/segmentation/scripts/validate_segmentation_layout.py --help
python skills/disco/paddlevit/sub-skills/segmentation/scripts/segmentation_demo_check.py --help

Read the smallest supporting reference needed:

Supported model registry

src/models/__init__.py dispatches by substring in MODEL.NAME to SETR, UperNet, DPT, Segmenter, Trans2Seg, Segformer, and TopFormer. The current TopFormer dispatch has a source typo: it checks "TopFomer" (missing r), so use that spelling in this checkout unless a separately tested source patch changes both factory and configs. See the model reference for exact family wiring and known UperNet/auxiliary-head constraints.

Source command contract

Run training and validation from semantic_segmentation/:

python train.py --config CONFIG [--resume CHECKPOINT]
python val.py --config CONFIG [--model_path MODEL] [--multi_scales True]

Run the demo from semantic_segmentation/demo/ (or make every relative path explicit):

python demo.py --config CONFIG --model_path MODEL \
  --pretrained_backbone BACKBONE --img_dir IMAGE_DIR --results_dir OUTPUT_DIR

The training parser exposes --config and --resume, not --model_path. Validation's --model_path is a full segmentation state dict and falls back to SAVE_DIR/iter_{TRAIN.ITERS}_model_state.pdparams when omitted. The demo accepts the five named paths above; --pretrained_backbone is used to set MODEL.PRETRAINED, while --model_path loads the segmentation model.

The validation parser declares --multi_scales with type=bool: omit the flag for single-scale; passing the string False is truthy in ordinary argparse. The demo reads every entry in img_dir, not only recognized image suffixes, so keep that directory image-only. It writes an overlay and a palette PNG per input under results_dir, and deletes that directory first if it exists.

Verification ladder and stop conditions

Record the evidence tier; never promote one tier to another:

  • Static/parser: CLI help, YAML/BASE inspection, path checks, and layout pairing. No Paddle model is built.
  • CPU model construction: Paddle imports and a model is allocated/built on CPU. This does not validate CUDA kernels, memory, or data quality.
  • GPU smoke: the selected model performs an approved tiny forward/batch on the target Paddle/CUDA environment. The supplied live facts are Paddle GPU 2.6.2, yacs/PyYAML/OpenCV/SciPy/cityscapesScripts passing, and a CUDA smoke; re-probe the active shell before a real run.
  • Task validation: a real split and compatible full checkpoint produce mIoU, accuracy, Kappa, and class-wise values.

Stop instead of claiming success when the config is absent, required pairings are incomplete, class ids are ambiguous, the checkpoint is missing or incompatible, the requested backend/budget is unavailable, or a conversion would mutate an uncontrolled tree. Multi-scale, slide, distributed, and training commands are expensive operations requiring an explicit budget and stop condition.

Evidence boundary

This skill was distilled from the available segmentation README, requirements.txt, config.py, train.py, val.py, demo/demo.py, the segmentation src dataset/model/transform/checkpoint/metric utilities, family configs and READMEs, tutorial/custom_dataset.md, and tools/*.py. The requested docs/paddlevit-predict.md is absent in this checkout; the available docs/paddlevit-predict-cn.md describes classification prediction rather than this segmentation demo, so it is not treated as segmentation evidence. The available export/port docs are used only for the conversion boundary: a .pdparams state dict is not automatically an inference export or a cross-framework weight conversion.

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