Classification

From VectorSpaceLab/AREX-Skill · View interactive version

Classification is an AI agent skill from the GitHub repository VectorSpaceLab/AREX-Skill. Guides Attention-Gated Networks ultrasound classification workflows, including Sononet training, evaluation, HDF5 data layout, and attention overlays.

How to use this skill

Skill file

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

model names, wrapper behavior, config fields, aggregation modes, or class and

function signatures.

ultrasound HDF5 file or debugging loader/sampler failures.

checkpoint evaluation, model inspection, and safe attention-overlay export.

torchsample, Visdom, sampler, HDF5, or overlay failures appear.

and testing commands that replace the source repo's root entry points.

replace the source repo's hard-coded attention visualization script with a

parameterized, skill-owned 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:

issues.

Route 3D segmentation, NIfTI validation, and multi-attention U-Net feature-map

exports to ../segmentation/SKILL.md instead.

Quick workflow

  1. Install the repository with CUDA-enabled PyTorch and the legacy

torchsample dependency. Then run:

```bash

python ../../scripts/check_env.py --repo-root /path/to/Attention-Gated-Networks --mode classification

```

  1. Prepare an ultrasound HDF5 file with x_train, p_train, x_val, p_val,

x_test, p_test, and label_names. See data-layout.md.

  1. Copy a Sononet config and replace its dataset path. The source configs use

model.output_nc=14, input_nc=1, tensor_dim='2D', and gpu_ids=[0].

  1. 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.

```bash

python scripts/run_classifier.py --repo-root /path/to/Attention-Gated-Networks --config path/to/config.json --mode train

```

  1. Evaluate a checkpoint with the bundled replacement:

```bash

python scripts/run_classifier.py --repo-root /path/to/Attention-Gated-Networks --config path/to/config.json --mode test

```

  1. For attention models, use model_type='sononet_grid_attention' and read

workflows.md before choosing aggregation_mode and

aggregation.

  1. Export a safe synthetic overlay, or adapt the command for a real 2D input:

```bash

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

paths call .cuda().

for a different HDF5 label set.

Sononet classifiers use FeedForwardClassifier.

real ultrasound HDF5 file or evaluating a real checkpoint.

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.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.