SimNorth: contrastive self-supervised learning for ultrasound frames with hypersphere light-house anchors
Project description
SimNorth
Contrastive self-supervised representation learning for ultrasound frames.
SimNorth maps frames onto the unit hypersphere with three objectives:
- Alignment — two augmented views of the same frame are pulled together.
- Uniformity — randomly paired views are pushed apart with a rank-based weighting, so the most-similar (likely true-negative) random pairs are penalized the most.
- North / light house — a set of fixed anchor points ("light houses") on the sphere attract their nearest embeddings, organizing the learned manifold around well-separated anchors.
Built on PyTorch Lightning 2.x with MLflow experiment tracking.
Install
pip install -e .
# or
pip install -r requirements.txt
Data format
A CSV or Parquet table with one row per frame and a column of image paths
(default img_path), resolved relative to --mount_point. Frames are read with
SimpleITK; single-channel frames are promoted to 3 channels.
Usage
Optionally pre-compute well-separated light house anchors:
python pretrain_lighthouse.py --n_lights 64 --emb_dim 128 --out lights.pkl
Train:
python train.py \
--csv_train train.parquet --csv_valid valid.parquet --csv_test test.parquet \
--mount_point /data/frames \
--base_encoder efficientnet_b0 --emb_dim 128 --hidden_dim 64 --n_lights 64 \
--batch_size 256 --epochs 200 --lr 1e-4 \
--lights lights.pkl \
--tracking_uri file:./mlruns --experiment_name SimNorth --run_name effnet_b0
If --lights is omitted, anchors are initialized uniformly at random.
Inspect runs:
mlflow ui --backend-store-uri ./mlruns
Package layout
simnorth/
├── nets/
│ ├── simnorth.py # SimNorth, ProjectionHead, GaussianNoise
│ └── lighthouse.py # LightHouse anchor optimizer
├── data/
│ ├── dataset.py # USDataset, USDataModule
│ └── transforms.py # paired augmentation transforms
└── callbacks/
└── image_logger.py # logs augmented-view grids to MLflow
train.py # training entrypoint (MLflow)
pretrain_lighthouse.py # optional anchor pre-optimization
Provenance
Extracted and modernized from the us-famli-pl research codebase
(nets/contrastive.py, contrastive_learning.py). Compared to the original:
- Upgraded from
pytorch_lightningto thelightning2.x API. - Switched experiment logging from Neptune to MLflow.
SimNorthtakes explicit hyperparameters instead of anargsnamespace.- Fixed a copy-paste bug in the north loss where the second view's nearest
index was taken from the first view (
z_1_nnow uses thez_1index).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simnorth-0.1.0.tar.gz.
File metadata
- Download URL: simnorth-0.1.0.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
083b3cf48978b3f509f7e833f6718da322bdf24fac736fe83ad3b5bd0476dd71
|
|
| MD5 |
9e13c09f97774864d31f9492ab627a33
|
|
| BLAKE2b-256 |
c49a8b46a316cccad810e5ff640f23406d9ea2f1e1e2f16efc6d9d94e701dd07
|
Provenance
The following attestation bundles were made for simnorth-0.1.0.tar.gz:
Publisher:
python-publish.yml on ImageMindAnalytics/SimNorth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simnorth-0.1.0.tar.gz -
Subject digest:
083b3cf48978b3f509f7e833f6718da322bdf24fac736fe83ad3b5bd0476dd71 - Sigstore transparency entry: 1695972157
- Sigstore integration time:
-
Permalink:
ImageMindAnalytics/SimNorth@c2bf6819591a7490bd29dd1253809ed1c6b47501 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/ImageMindAnalytics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c2bf6819591a7490bd29dd1253809ed1c6b47501 -
Trigger Event:
release
-
Statement type:
File details
Details for the file simnorth-0.1.0-py3-none-any.whl.
File metadata
- Download URL: simnorth-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b40fbb3875fc2c4f0e0356ff9c9a06ccccb0f5e7c17ddb1df765db57bdd45a2
|
|
| MD5 |
50476539d0f2fb040b8ba55c547c52f4
|
|
| BLAKE2b-256 |
6ab0665cf7f451c2a636cab4e75c357fb705a263b2cc425419ded3d73e1f8341
|
Provenance
The following attestation bundles were made for simnorth-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on ImageMindAnalytics/SimNorth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simnorth-0.1.0-py3-none-any.whl -
Subject digest:
9b40fbb3875fc2c4f0e0356ff9c9a06ccccb0f5e7c17ddb1df765db57bdd45a2 - Sigstore transparency entry: 1695972224
- Sigstore integration time:
-
Permalink:
ImageMindAnalytics/SimNorth@c2bf6819591a7490bd29dd1253809ed1c6b47501 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/ImageMindAnalytics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@c2bf6819591a7490bd29dd1253809ed1c6b47501 -
Trigger Event:
release
-
Statement type: