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:
AttentionGatedNetworks version 1.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.
1---2name: attention-gated-networks3description: "Guides Attention-Gated Networks PyTorch medical imaging workflows4 for ultrasound classification, attention-gated U-Net segmentation, data5 layout, CUDA setup, and visualization helpers."6disable-model-invocation: true7metadata:8 source: https://skillmd.com/skills/vectorspacelab/attention-gated-networks9 disco-role: operating10license: MIT11---1213# Attention-Gated Networks1415Use this repo skill when a task involves the `Attention-Gated-Networks` PyTorch16repository or its medical imaging workflows: ultrasound scan-plane17classification, Sononet Grid Attention, Attention U-Net style segmentation,18NIfTI/HDF5 data layouts, CUDA setup, and attention or feature-map visualization.1920## Start here2122- Read [package-overview.md](references/package-overview.md) for package23 purpose, installation guidance, config families, generated helpers, and the24 CUDA policy.25- Read [troubleshooting.md](references/troubleshooting.md) for cross-cutting26 install/import, CUDA, Visdom, dependency, and config portability failures.27- Read [repo-provenance.md](references/repo-provenance.md) before deciding28 whether this skill is current for a checkout or before running a refresh.29- Use [repo-routing-metadata.json](references/repo-routing-metadata.json) only30 for router/import metadata.31- Run [check_env.py](scripts/check_env.py) after installation to verify imports,32 CUDA, and tiny model smokes.3334## Route map3536| User request | Read |37| --- | --- |38| Train, test, debug, or configure ultrasound scan-plane classification | [classification](sub-skills/classification/SKILL.md) |39| Use Sononet, Sononet2, Sononet Grid Attention, aggregated classifier, or attention overlays | [classification](sub-skills/classification/SKILL.md) |40| Arrange ultrasound HDF5 splits, labels, class weights, or samplers | [classification data layout](sub-skills/classification/references/data-layout.md) |41| Train, validate, or configure 2D/3D U-Net segmentation models | [segmentation](sub-skills/segmentation/SKILL.md) |42| Use CT deep supervision, multi-attention U-Net, non-local blocks, or NIfTI outputs | [segmentation](sub-skills/segmentation/SKILL.md) |43| Export 3D attention maps, feature maps, NIfTI predictions, or validation metrics | [segmentation workflows](sub-skills/segmentation/references/workflows.md) |44| Diagnose shared install, CUDA, dependency, or config issues | [troubleshooting](references/troubleshooting.md) |4546## Minimal install check4748After installing the repository and dependencies, run:4950```bash51python scripts/check_env.py --repo-root /path/to/Attention-Gated-Networks --mode all52```5354If the package is installed and importable without a checkout on `sys.path`, the55helper can still run from any working directory; `--repo-root` is only needed to56point at a local checkout during development or editable installs.5758Successful output should include import success, CUDA availability, a tiny59classification output, an attention-classifier output, a tiny segmentation60output, and `check-env-ok`.6162## Runtime and external inputs6364The helpers require the repository checkout on `--repo-root` (or an installed65`AttentionGatedNetworks` package) plus the legacy runtime dependencies listed in66[package-overview.md](references/package-overview.md). Datasets and trained67weights/checkpoints are external inputs; this skill does not fabricate or68bundle them. Stock configs contain private historical `/vol/...` paths and must69be copied with `data_path.*` and output/checkpoint paths overridden.7071For a config supplied as a relative path, always pass `--repo-root`; the helper72resolves the config from that root and any relative data path from the config's73parent, never from the process cwd. Validate before running:7475```bash76python scripts/check_env.py --repo-root /path/to/Attention-Gated-Networks \77 --config configs/config_sononet_grid_att_8.json --mode imports78```7980This intentionally fails fast on private or missing data paths. The original81`train_classifaction.py` also contains a 10-hour final-epoch sleep; it is left82untouched as source evidence, while the bundled runner omits that hold.8384## Important defaults8586- Distribution: `AttentionGatedNetworks` version `1.0`.87- Import packages: `models`, `dataio`, `utils`.88- Required backend for the selected workflows: CUDA. The unmodified wrappers89 call `.cuda()` for models and tensors.90- Core dependencies: PyTorch, torchvision, torchsample, NumPy/SciPy,91 matplotlib, scikit-image, h5py, pandas, tqdm, Visdom, nibabel,92 scikit-learn, OpenCV, dominate, and SimpleITK for validation exports.93- Configs contain historical machine-specific dataset paths; copy the field94 structure but replace paths and output directories before use.95- Use the bundled scripts under this generated skill rather than hard-coded96 source visualization/validation scripts.9798## Bundled helpers99100- `scripts/check_env.py`: import, CUDA, classification, attention-classifier,101 and segmentation smoke checks.102- `sub-skills/classification/scripts/run_classifier.py`: training/testing103 replacement for classification workflows.104- `sub-skills/classification/scripts/export_attention_overlay.py`: safe105 attention overlay export for grid-attention classifiers.106- `sub-skills/segmentation/scripts/run_segmentation.py`: training replacement107 for segmentation workflows.108- `sub-skills/segmentation/scripts/validate_and_export_maps.py`: validation,109 NIfTI export, and feature/attention-map helper.110111## Avoid when112113Do not use this skill for unrelated modern MONAI/nnU-Net/TorchIO workflows114unless the task explicitly names Attention-Gated Networks or needs to port ideas115from this repository. Do not use it as proof that CPU-only execution works; the116selected repo workflows were verified as CUDA-required.