classification
Guides Attention-Gated Networks ultrasound classification workflows, including Sononet training, evaluation, HDF5 data layout, and attention overlays.
- License 许可
- MIT
- 最近更新
- 2026-10-08
- Stars
- ★ 11
- Forks
- 3
01 前言 Front Matter
- name
- classification
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Guides Attention-Gated Networks ultrasound classification workflows, including Sononet training, evaluation, HDF5 data layout, and attention overlays.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md6.5 KB
- 参考文档references/data-layout.md3.3 KB
- 参考文档references/troubleshooting.md4.1 KB
- 参考文档references/workflows.md5.0 KB
03 SKILL.md 正文
Classification
Use this sub-skill for ultrasound scan-plane classification tasks in
Attention-Gated Networks. It covers Sononet, Sononet2, Sononet Grid Attention,
FeedForwardClassifier, AggregatedClassifier, the HDF5 ultrasound loader,
classification training/testing scripts, and attention overlay export.
Read first
- Read api-reference.md when you need exact model names, wrapper behavior, config fields, aggregation modes, or class and function signatures.
- Read data-layout.md before preparing the ultrasound HDF5 file or debugging loader/sampler failures.
- Read workflows.md for training, testing, checkpoint evaluation, model inspection, and safe attention-overlay export.
- Read troubleshooting.md when CUDA, torchsample, Visdom, sampler, HDF5, or overlay failures appear.
- Run run_classifier.py for skill-owned training and testing commands that replace the source repo's root entry points.
- Run export_attention_overlay.py to replace the source repo's hard-coded attention visualization script with a parameterized, skill-owned helper.
- For fast environment validation, run the root helper
../../scripts/check_env.py --repo-root /path/to/Attention-Gated-Networks --mode classification.
When to use this sub-skill
Use this route when the user asks to:
- train or test ultrasound scan-plane classification models;
- choose between
sononet,sononet2, andsononet_grid_attention; - configure
aggregated_classifier, deep supervision, or attention aggregation; - inspect classifier outputs, class counts, losses, or scikit-learn metrics;
- prepare or validate the
usHDF5 dataset layout; - export compatibility-score attention maps or overlay PNGs;
- debug classification-specific CUDA, Visdom, sampler, HDF5, or checkpoint issues.
Route 3D segmentation, NIfTI validation, and multi-attention U-Net feature-map
exports to ../segmentation/SKILL.md instead.
Quick workflow
-
Install the repository with CUDA-enabled PyTorch and the legacy
torchsampledependency. Then run:python ../../scripts/check_env.py --repo-root /path/to/Attention-Gated-Networks --mode classification -
Prepare an ultrasound HDF5 file with
x_train,p_train,x_val,p_val,x_test,p_test, andlabel_names. See data-layout.md. -
Copy a Sononet config and replace its dataset path. The source configs use
model.output_nc=14,input_nc=1,tensor_dim='2D', andgpu_ids=[0]. -
Train with the bundled replacement when real data is available:
Relative config paths are resolved from the explicit --repo-root; relative
data_path values are resolved from the config file's parent. The HDF5 data
file and any checkpoint/weights must already exist outside this skill. Bundled
runners and check_env.py --config ... reject missing or private /vol/...
paths before constructing a dataset.
python scripts/run_classifier.py --repo-root /path/to/Attention-Gated-Networks --config path/to/config.json --mode train
-
Evaluate a checkpoint with the bundled replacement:
python scripts/run_classifier.py --repo-root /path/to/Attention-Gated-Networks --config path/to/config.json --mode test -
For attention models, use
model_type='sononet_grid_attention'and read workflows.md before choosingaggregation_modeandaggregation. -
Export a safe synthetic overlay, or adapt the command for a real 2D input:
python scripts/export_attention_overlay.py \ --repo-root /path/to/Attention-Gated-Networks \ --config configs/config_sononet_grid_att_8.json \ --output-dir /tmp/ag-net-attention
Key decisions
- CUDA is required for the unmodified wrappers because the model and tensor
paths call
.cuda(). - The stock ultrasound configs assume 14 classes. Do not reuse them unchanged for a different HDF5 label set.
AggregatedClassifieris for multiple-output attention models. Plain Sononet classifiers useFeedForwardClassifier.- Synthetic smoke checks prove wiring only; they do not replace training on the real ultrasound HDF5 file or evaluating a real checkpoint.
- The original attention visualization script hard-codes private paths. Use the bundled helper or parameterize your own script rather than running it as-is.
The source train_classifaction.py contains a 10-hour sleep after the final
epoch's updates. It is retained in the source checkout for provenance; use the
bundled runner when a bounded run without that hold is required.
Expected outputs
Training writes checkpoints and logs below the configured checkpoint directory
and experiment name. Testing writes accumulated metrics and a test_result.pkl
inside the model save directory. The bundled attention helper writes overlay
PNGs and .npy arrays to the requested output directory.
04 同仓库更多 Skills
obsidian-clipper-template-creator
Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.
obsidian-clipper-template-creator
Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.
python-api
Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP/mAP semantics, and source-style import diagnostics.
file-evaluation
Folder-based PASCAL VOC AP/mAP evaluation from ground-truth and detection text files.
object-detection-metrics
Guides legacy Object-Detection-Metrics PASCAL VOC AP/mAP evaluation from detection text folders and direct Python API classes.
nx-workspace-patterns
Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.