inference-and-postprocessing
Route BiRefNet image/video inference, mask saving, foreground refinement, and output validation.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- inference-and-postprocessing
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Route BiRefNet image/video inference, mask saving, foreground refinement, and output validation.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/inference-workflows.md4.3 KB
- 参考文档references/troubleshooting.md3.3 KB
- 参考文档references/video-workflows.md2.0 KB
- 脚本scripts/birefnet_image_infer.py18.7 KB
- 脚本scripts/birefnet_refine_smoke.py3.6 KB
03 SKILL.md 正文
inference-and-postprocessing
Use this sub-skill for BiRefNet inference tasks that need:
- a Hugging Face load path or a local
.pthcheckpoint - image or directory-based mask generation
- foreground refinement or matting-style exports
- comparison panels and practical output validation
- notebook-style video inference guidance
Stay in scope
Use the bundled references and scripts when the task is about:
- loading BiRefNet weights for inference
- preparing
Resize+ToTensor+ ImageNet normalization - running
birefnet(input)[-1].sigmoid()in eval mode - saving masks, foregrounds, or comparison images
- understanding native
inference.pyoutput layout
Route elsewhere
- Model/backbone internals, patch helpers, or export mechanics →
../model-architecture/SKILL.md - Dataset layout or config defaults →
../configuration-and-data/SKILL.md - Training, evaluation, metrics, or checkpoint selection →
../training-and-evaluation/SKILL.md
Runtime entry points
references/inference-workflows.mdreferences/video-workflows.mdreferences/troubleshooting.mdscripts/birefnet_image_infer.pyscripts/birefnet_refine_smoke.py
Operating notes
- Start with
--helpor--dry-run. - Pass
--repo-rootexplicitly so imports stay anchored to the intended checkout. - Choose
--model-source localfor a checkpoint file or--model-source hffor hub weights. - Use
--device auto,cpu, orcudabased on the available backend. - Keep
--foreground-refineand--save-comparisonenabled when you need matting-style outputs. - Local checkpoints should be cleaned with
check_state_dictbefore loading; the helper does this for you.
Recommended operating flow
- Confirm whether the task is single image, directory, video, or repo-style dataset inference.
- Run
scripts/birefnet_refine_smoke.py --device cpuif the user only needs postprocessing/backend sanity before loading model weights. - Run
scripts/birefnet_image_infer.py --dry-runwith the intended image directory, output directory, model source, device, and resolution before a real inference run. - For local checkpoints, route persistent key or tensor-size mismatches to
../model-architecture/SKILL.md. - For outputs that will be evaluated with BiRefNet metrics, preserve dataset/model directory names that
../training-and-evaluation/SKILL.mdexpects.
Done criteria
- The model source and required assets are explicit: Hugging Face repo/cache or local
.pthcheckpoint. - The device, resolution, and CPU/CUDA/autocast limits are stated.
- The expected mask, foreground, and comparison output directories are known.
- Optional foreground refinement and video processing are separated from the core mask inference step.
Output conventions
- Masks go to
masks/ - Foreground/matting exports go to
foregrounds/ - Comparison panels go to
comparisons/ - Relative folder structure under
--inputis preserved
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).