AGENT SKILL

inference-and-deployment

Use DLTK's TensorFlow 1.x prediction, full-volume sliding-window assembly, crop averaging, metrics, and metadata-preserving medical-image deployment workflows.

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

01 前言 Front Matter

name
inference-and-deployment
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Use DLTK's TensorFlow 1.x prediction, full-volume sliding-window assembly, crop averaging, metrics, and metadata-preserving medical-image deployment workflows.
disable-model-invocation
true

02 资源文件 5

03 SKILL.md 正文

DLTK inference and deployment

Use this route when the task is to run prediction with an exported DLTK model, assemble patch predictions into a full volume, average stochastic crops, calculate segmentation metrics, or write a NIfTI result. This is an operating guide for DLTK 0.2.1's TensorFlow 1.x graph-execution deployment path.

Compatibility gate

  • Expect Python 3.7 and TensorFlow 1.15-era graph execution. The documented deployment path is tensorflow.contrib.predictor.from_saved_model; do not claim that a modern TF2 installation provides this predictor or that these recipes are TF2-compatible.
  • Confirm the model input and fetched output static shapes before running a volume. The sliding-window utility expects rank-compatible static shapes and a channels-last tensor. The input sample normally has [batch, spatial..., channels]; a full-volume application adds a dummy batch dimension.
  • Keep model construction and output-key details in model-building, input/file/reader assumptions in data-pipelines, and export/training setup in training-and-estimators.

Choose the workflow

  1. From the directory containing this file (inference-and-deployment/), run python scripts/sliding_window_plan.py --help, then provide spatial --input-shape, --window-shape, and --output-shape. The helper performs validation without importing TensorFlow, reading data, or contacting a network.
  2. From that same sub-skill directory, run python scripts/sliding_window_smoke.py. It exercises the native test shape plus output-smaller, overlapping, and batched assembly using constant synthetic predictions; it does not load a model or dataset.
  3. For a real export, read deployment-workflows.md and api-reference.md first. Discover a numeric export directory, load the TF1 predictor, inspect its tensors, assemble a volume, convert probabilities/logits to the required result, calculate metrics if labels exist, and write output only to an explicitly chosen directory.

Inference checklist

  • Validate all spatial dimensions, the predictor's input/output keys, channel count, batch_size, and explicit stride before session execution. A malformed output/window combination can fail in padding or produce empty slices and a zero division counter.
  • Treat sliding_window_segmentation_inference as an averaging assembler: it runs each patch, adds each output to the corresponding output slice, increments a separate coverage counter, and returns sum / counter for each requested op. It returns a list in ops_list order, not class labels.
  • For segmentation, convert a [batch, spatial..., classes] probability or logit result with np.argmax(result, axis=-1). For probabilities, averaging overlapping patches before argmax is the DLTK MRBrainS pattern. For logits, a numerically stable softmax is useful when probabilities are needed, but argmax is unchanged.
  • Exclude or report background explicitly when aggregating Dice. DLTK's dice returns NaN for a class with no predicted and no reference voxels; np.nanmean(dice[1:]) is an application policy, not a universal score.
  • For SimpleITK output, create the array image with the correct spatial order, call CopyInformation from the source image, and only then write the requested .nii/.nii.gz. A shape or direction/spacing mismatch must be diagnosed rather than silently discarded.
  • Random-crop regression/classification deployment is stochastic. Record the crop count, shape, seed policy (if any), and aggregation axis; the original IXI examples average four random crops and explicitly warn that results vary between runs.

See troubleshooting.md before changing geometry, predictor access, export discovery, or metric handling.

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