AGENT SKILL

u-2-net

Route U-2-Net salient object detection, human segmentation, portrait generation, architecture, and training-preparation workflows.

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

01 前言 Front Matter

name
u-2-net
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Route U-2-Net salient object detection, human segmentation, portrait generation, architecture, and training-preparation workflows.
disable-model-invocation
true

02 资源文件 8

03 SKILL.md 正文

U-2-Net Repo Skill

Use this skill when the task is about U-2-Net/U2NET PyTorch workflows: salient object detection masks, human/person segmentation, portrait drawing, portrait compositing, model architecture/checkpoints, dependency checks, or DUTS-style training preparation.

First checks

  • This generated skill bundles distilled U-2-Net model code and helper scripts. It does not bundle pretrained .pth weights.

  • Core workflows need Python with torch, torchvision, numpy, Pillow, scikit-image, and usually cv2 for portrait own-image mode.

  • A typical CPU-oriented install is:

    python -m pip install torch torchvision numpy pillow scikit-image opencv-python matplotlib
    

    Choose a CUDA-enabled PyTorch install only when the user explicitly needs GPU acceleration and the host supports it.

  • Run scripts/check_environment.py when debugging imports or optional CUDA.

  • Read model weights before choosing a checkpoint.

  • Read repo provenance when checking staleness against a new checkout.

Route map

User task Read
Choose between U2NET, U2NETP, side outputs, checkpoint compatibility, or run a tiny architecture smoke test. sub-skills/model-architecture/SKILL.md
Run generic saliency masks with u2net/u2netp, human/person segmentation, or troubleshoot mask outputs. sub-skills/salient-object-inference/SKILL.md
Run portrait drawing, own-photo face-crop portrait inference, Haar cascade handling, or sigma/alpha composites. sub-skills/portrait-workflows/SKILL.md
Validate DUTS-style data layout, inspect preprocessing, or plan bounded retraining. sub-skills/data-and-training/SKILL.md
Optional PaddleHub/Gradio web demo. references/optional-demos.md

Minimal dependency check

python scripts/check_environment.py --check-cuda

For architecture-only smoke testing from this skill directory:

python sub-skills/model-architecture/scripts/smoke_architecture.py --model u2netp --height 64 --width 64 --device cpu

For pretrained saliency, supply explicit weights:

python sub-skills/salient-object-inference/scripts/u2net_infer.py \
  --task saliency \
  --model u2netp \
  --weights PATH_TO_WEIGHTS/u2netp.pth \
  --input-dir INPUT_IMAGES \
  --output-dir OUTPUT_MASKS \
  --device cpu

Cross-cutting references

  • Troubleshooting: install/import, missing weights, optional CUDA/PaddleHub, script-style repo, and training safety.
  • Model weights: checkpoint-to-workflow matrix and no-download policy.
  • Optional demos: PaddleHub/Gradio route and why it is not part of the minimum workflow.
  • Routing metadata: structured scenario placement for managed repo-skill import.

Safety and scope

Do not start large downloads, full training, web demos, or checkpoint overwrites without explicit user approval. Use random-weight smoke flags only for dependency and plumbing checks; never present random outputs as U-2-Net predictions.

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