attention-gated-networks
Guides Attention-Gated Networks PyTorch medical imaging workflows for ultrasound classification, attention-gated U-Net segmentation, data layout, CUDA setup, and visualization helpers.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- attention-gated-networks
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Guides Attention-Gated Networks PyTorch medical imaging workflows for ultrasound classification, attention-gated U-Net segmentation, data layout, CUDA setup, and visualization helpers.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/package-overview.md4.7 KB
- 参考文档references/repo-provenance.md2.2 KB
- 参考文档references/repo-routing-metadata.json525 B
- 参考文档references/troubleshooting.md4.2 KB
- 脚本scripts/check_env.py8.3 KB
03 SKILL.md 正文
Attention-Gated Networks
Use this repo skill when a task involves the Attention-Gated-Networks PyTorch
repository or its medical imaging workflows: ultrasound scan-plane
classification, Sononet Grid Attention, Attention U-Net style segmentation,
NIfTI/HDF5 data layouts, CUDA setup, and attention or feature-map visualization.
Start here
- Read package-overview.md for package purpose, installation guidance, config families, generated helpers, and the CUDA policy.
- Read troubleshooting.md for cross-cutting install/import, CUDA, Visdom, dependency, and config portability failures.
- Read repo-provenance.md before deciding whether this skill is current for a checkout or before running a refresh.
- Use repo-routing-metadata.json only for router/import metadata.
- Run check_env.py after installation to verify imports, CUDA, and tiny model smokes.
Route map
| User request | Read |
|---|---|
| Train, test, debug, or configure ultrasound scan-plane classification | classification |
| Use Sononet, Sononet2, Sononet Grid Attention, aggregated classifier, or attention overlays | classification |
| Arrange ultrasound HDF5 splits, labels, class weights, or samplers | classification data layout |
| Train, validate, or configure 2D/3D U-Net segmentation models | segmentation |
| Use CT deep supervision, multi-attention U-Net, non-local blocks, or NIfTI outputs | segmentation |
| Export 3D attention maps, feature maps, NIfTI predictions, or validation metrics | segmentation workflows |
| Diagnose shared install, CUDA, dependency, or config issues | troubleshooting |
Minimal install check
After installing the repository and dependencies, run:
python scripts/check_env.py --repo-root /path/to/Attention-Gated-Networks --mode all
If the package is installed and importable without a checkout on sys.path, the
helper can still run from any working directory; --repo-root is only needed to
point at a local checkout during development or editable installs.
Successful output should include import success, CUDA availability, a tiny
classification output, an attention-classifier output, a tiny segmentation
output, and check-env-ok.
Runtime and external inputs
The helpers require the repository checkout on --repo-root (or an installed
AttentionGatedNetworks package) plus the legacy runtime dependencies listed in
package-overview.md. Datasets and trained
weights/checkpoints are external inputs; this skill does not fabricate or
bundle them. Stock configs contain private historical /vol/... paths and must
be copied with data_path.* and output/checkpoint paths overridden.
For a config supplied as a relative path, always pass --repo-root; the helper
resolves the config from that root and any relative data path from the config's
parent, never from the process cwd. Validate before running:
python scripts/check_env.py --repo-root /path/to/Attention-Gated-Networks \
--config configs/config_sononet_grid_att_8.json --mode imports
This intentionally fails fast on private or missing data paths. The original
train_classifaction.py also contains a 10-hour final-epoch sleep; it is left
untouched as source evidence, while the bundled runner omits that hold.
Important defaults
- Distribution:
AttentionGatedNetworksversion1.0. - Import packages:
models,dataio,utils. - Required backend for the selected workflows: CUDA. The unmodified wrappers
call
.cuda()for models and tensors. - Core dependencies: PyTorch, torchvision, torchsample, NumPy/SciPy, matplotlib, scikit-image, h5py, pandas, tqdm, Visdom, nibabel, scikit-learn, OpenCV, dominate, and SimpleITK for validation exports.
- Configs contain historical machine-specific dataset paths; copy the field structure but replace paths and output directories before use.
- Use the bundled scripts under this generated skill rather than hard-coded source visualization/validation scripts.
Bundled helpers
scripts/check_env.py: import, CUDA, classification, attention-classifier, and segmentation smoke checks.sub-skills/classification/scripts/run_classifier.py: training/testing replacement for classification workflows.sub-skills/classification/scripts/export_attention_overlay.py: safe attention overlay export for grid-attention classifiers.sub-skills/segmentation/scripts/run_segmentation.py: training replacement for segmentation workflows.sub-skills/segmentation/scripts/validate_and_export_maps.py: validation, NIfTI export, and feature/attention-map helper.
Avoid when
Do not use this skill for unrelated modern MONAI/nnU-Net/TorchIO workflows unless the task explicitly names Attention-Gated Networks or needs to port ideas from this repository. Do not use it as proof that CPU-only execution works; the selected repo workflows were verified as CUDA-required.
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).