This repository contains the 4th place solution for the CSV 2026 Challenge: Carotid Plaque Segmentation and Vulnerability Assessment in Ultrasound.
The CSV 2026 challenge requires jointly solving two tasks on carotid plaque ultrasound images with a single unified model:
- Segmentation: Segment carotid plaque and vascular structures from two-view (longitudinal and transverse) US images.
- Classification: Classify plaque vulnerability (low-risk: RADS 2 vs. high-risk: RADS 3–4) following the International Plaque-RADS Guidelines.
The following specs describe the environment used for training. Other configurations may work as long as the requirements are satisfied.
- OS: Ubuntu 22.04.5 LTS
- CPU: Intel Core i7-7700 @ 3.60GHz (8 cores)
- RAM: 62GB
- GPU: NVIDIA GeForce RTX 2080 Ti (11GB)
- CUDA: 13.0 (Driver: 580.126.09)
- Python: 3.10.12
- Create and activate a virtual environment named
magnet(Python 3.10.12). You can use either the standardvenvorconda.
Option A — Using venv:
# create the venv (ensure Python 3.10.12 is available as `python3.10`)
python3.10 -m venv magnet
# activate the virtual environment
source magnet/bin/activateOption B — Using conda:
# create and activate conda env (requires conda/miniconda/Anaconda)
conda create -n magnet python=3.10.12 -y
conda activate magnet- Install requirements:
pip install -r requirements.txtThe dataset is a large-scale carotid ultrasound collection containing 1,500 paired cases, each consisting of longitudinal and transverse B-mode images.
Split
| Split | Cases | Labeled |
|---|---|---|
| Train | 1,000 | 200 (20%) |
| Validation | 200 | - |
| Test | 300 | - |
Folder Structure
train/
├── images/ # 001.h5, 002.h5, ...
│ └── *.h5
│ ├── long_image # [512, 512, 1] — longitudinal B-mode
│ └── trans_image # [512, 512, 1] — transverse B-mode
├── labels/ # 001_label.h5, 002_label.h5, ...
│ └── *_label.h5
│ ├── long_mask # [512, 512] — longitudinal segmentation mask
│ ├── trans_mask # [512, 512] — transverse segmentation mask
│ └── label # 0: low-risk (RADS 2), 1: high-risk (RADS 3–4)
└── train.txt # list of training file names
The global settings are managed within the DEFAULT_CFG dictionary in train.py. Below are the key categories:
Data & Paths
data_root: Path to your training dataset (default: ./CSV2026_Dataset_Train).split_json: Path to the 4-fold cross-validation split file.n_folds: Total number of folds for cross-validation.checkpoint_dir_prefix: Prefix for the directories where model weights and logs are saved.
Architecture & Optimization
convnext_model: Backbone variant (default: convnext_nano).img_size: Input image dimensions.encoder_freeze_epochs: Duration of initial encoder freeze.early_stopping_patience: Threshold for early termination.pretrained_encoder: IfTrue, load pretrained weights for the ConvNeXt backbone (viatimm, typically ImageNet-pretrained). Note: the custom shallowstemand segmentation/classification heads are initialized separately and not replaced by the backbone pretrained weights.
Mean Teacher (Semi-Supervised Learning)
use_mean_teacher: Enables the semi-supervised consistencyema_alpha: The decay rate for the Teacher model update.consistency_weight: Scale for the consistency loss.consistency_rampup_epochs: Period to scale up consistency loss.consistency_confidence_threshold: Minimum confidence for segmentation consistency.consistency_cls_confidence_threshold: Minimum confidence for classification consistency.
You can train the model using one of three options below.
To train the model, run this command:
# 1) Train a single fold (e.g. fold 0)
python train.py --fold 0
# 2) Train a specific range (e.g. folds 1, 2, 3 | end_fold is exclusive)
python train.py --start_fold 1 --end_fold 4
# 3) Full 4-Fold Cross-Validation
python train.pyInference can be performed via Python CLI or Docker.
A. Via Python CLI
# Example
python inference.py \
--data-root ./CSV2026_Dataset_Val \
--model-path ./checkpoints_convnext_unet/kfold_summary/fold_0/best_st_fold0_model.pth \
--output-dir ./preds \
--resize-target 512 \
--gpu 0 \
--cls-threshold 0.8Arguments
--data-root: Path to dataset.--model-path: Path to the trained.pthcheckpoint--output-dir: Directory to save{patient_id}_pred.h5--resize-target: Target resolution for model input.--gpu: GPU device id--cls-threshold: Classification threshold for high-risk
B. Docker Inference Guide
- Load a trained checkpoint inside the container, run inference on
DATA_ROOT/images/*.h5files, and save outputs toOUTPUT_DIR.
Execution flow summary
- Container starts and runs
inference.py(entrypoint) inference.pyiterates overDATA_ROOT/images/*.h5and reads each file- Build the model via
models/Model.pyand load weights fromMODEL_PATH - Run inference per case and produce
{case_name}_pred.h5containing keyslong_mask,trans_mask, andcls, then save toOUTPUT_DIR
Quick run example
docker run --gpus all --rm \
-v /path/to/local/images:/data/images \
-v /path/to/local/output:/output \
-v /path/to/local/weights:/workspace/weights \
-e MODEL_PATH=/workspace/weights/my_checkpoint.pth \
-e RESIZE_TARGET=512 \
-e GPU=0 \
yws0322/csv2026-lpsib-solutionOptions / volumes / environment variables
-
-v /path/to/local/images:/data/images: Mount host folder with input.h5files to the container pathDATA_ROOT/images(e.g./data/images). Each.h5should containlong_imgandtrans_imgkeys. -
-v /path/to/local/output:/output: Mount host output directory to the containerOUTPUT_DIR. The container will write{case_name}_pred.h5files here. -
-v /path/to/local/weights:/workspace/weights: Mount a host folder containing checkpoint(s) (.pth) into the container (e.g./workspace/weights/best.pth). -
-e MODEL_PATH=/workspace/weights/my_checkpoint.pth: Path to the checkpoint inside the container (default:/workspace/weights/best.pth). -
-e RESIZE_TARGET=256: Integer target size to resize model input. -
-e GPU=0: Device id string mapped toCUDA_VISIBLE_DEVICESinside the container. -
--gpus all: Allocate GPUs to the container (requires NVIDIA Docker). -
Enter container and run inference manually:
docker exec -it container_name /bin/bash
python inference.pyOur method achieved 4th place on the official test leaderboard of the CSV 2026 Challenge.
| Model | F1 | Segmentation | Time(ms) |
|---|---|---|---|
| MAGNET | 68.03 | 60.25 | 98.52 |
