inference-export
Use Tensorpack PredictConfig, OfflinePredictor, SmartInit, checkpoints, model export, and model-conversion workflows.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- inference-export
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use Tensorpack PredictConfig, OfflinePredictor, SmartInit, checkpoints, model export, and model-conversion workflows.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/api-reference.md4.7 KB
- 参考文档references/checkpoints.md3.4 KB
- 参考文档references/troubleshooting.md3.3 KB
- 参考文档references/workflows.md5.6 KB
- 脚本scripts/export_model_demo.py9.5 KB
- 脚本scripts/inspect_checkpoint.py4.8 KB
03 SKILL.md 正文
inference-export
Root skill id: tensorpack.
This sub-skill covers Tensorpack inference, checkpoint inspection, export, and optional model-conversion flows. Use it when a task is about turning trained weights into a predictor, a SavedModel, a compact graph, or a clean inference graph.
Use this sub-skill for
PredictConfig,OfflinePredictor,OnlinePredictor, andFeedfreePredictor.SmartInit,SaverRestore,DictRestore, and checkpoint /.npzloading.ModelExporter.export_serving()andModelExporter.export_compact().tensorpack.utils.loadcaffeand Caffe-to-npzconversion flows.- Example inference routes from export, saliency, CAM, ResNet loading, and Faster R-CNN prediction scripts.
Route elsewhere
- Training loops, callbacks, trainer selection, or resume semantics ->
../training/SKILL.md. - Input pipelines, augmentation, serializers, or dataset plumbing ->
../dataflow/SKILL.md. - Deployment orchestration beyond TensorFlow export formats -> document only, do not build here.
Read first
- API reference
- Checkpoint guide
- Workflow guide
- Troubleshooting guide
- Checkpoint inspector
- Export demo
Operating rules
- Prefer a clean inference graph. If you build the graph yourself, wrap it in
TowerContext(..., is_training=False). - Do not import a training metagraph for inference. Recreate only the tensors needed for prediction.
- Restore parameters by exact name. When names or shapes differ, read the checkpoint guide before relaxing mismatch checks.
- Expose graph endpoints with
tf.identity(..., name='...')or by using the exact tensor names produced by the tower. - Use
OfflinePredictorfor the common numpy-array path. - Use
OnlinePredictoronly when you already own a live session and tensor handles. - Use
FeedfreePredictoronly when the inputs come from anInputSource. - Prefer
ModelExporter.export_serving()for SavedModel andexport_compact()for a frozen/pruned.pb. - Keep Caffe conversion optional. It depends on Caffe Python bindings, model files, and usually OpenCV.
Predictor roles
PredictConfigis the configuration hub. It can be built from aModelDesc, a plaintower_funcplusinput_signature, or aTowerFuncwrapper.OfflinePredictorbuilds a fresh graph and session from that config, then accepts numpy inputs and returns numpy outputs.OnlinePredictoris a thin wrapper around an existing session plus explicit tensors.FeedfreePredictorconsumes anInputSourceinstead of feeds and is useful when the input is already staged, queued, or dataflow-driven.
Quick decision map
- I have a checkpoint,
.npz, or dict: see Checkpoint guide. - I need to inspect variable names or dump a normalized
.npz: runscripts/inspect_checkpoint.py. - I need a simple predictor from numpy arrays: see Workflow guide.
- I need SavedModel / TensorFlow Serving export: see Workflow guide.
- I need a compact frozen graph: see Workflow guide.
- I need a fake-data end-to-end export demo: run
scripts/export_model_demo.py. - I need a Caffe model converted to Tensorpack weights: see Workflow guide and Troubleshooting guide.
Distilled example patterns
The bundled references cover these source-evidence patterns without requiring the original example checkout:
- Basic export: toy training, a separate inference graph, SavedModel export, compact graph export, and apply modes.
- Caffe-imported vision models: convert Caffe weights to
.npz, preprocess images, and load withSmartInit. - Converted ResNet inference: load converted
.npzweights, run ImageNet-style prediction, and optionally evaluate when the user supplies data. - Saliency and CAM: build predictors around fixed ImageNet-style models and fetch gradients or activation-map tensors.
- Detection prediction/export: detector prediction, evaluation JSON, multiple outputs, postprocessing, and compact/Serving export choices.
What this sub-skill does not own
- Training graph construction, callbacks, monitors, or trainer wiring.
- Data loading, augmentation, serializers, or batching policy.
- General serving orchestration beyond TensorFlow export formats.
If a request mixes inference with any of the above, keep the prediction or export pieces here and route the rest to the adjacent sub-skills.
04 同仓库更多 Skills
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.
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.
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.
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.
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.
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).