--- license: cc-by-nc-4.0 library_name: pytorch pipeline_tag: keypoint-detection tags: - medical-imaging - cephalometry - cephalometric-landmark-detection - self-supervised-learning - x-ray - simclr - barlow-twins - byol - moco - simsiam - swav - dino - resnet - vit --- # CephSSL: In-Domain Self-Supervised Pretraining for Cephalometric Landmark Detection Pretrained weights and evaluation files for the paper **"In-Domain Self-Supervised Pretraining for Cephalometric Landmark Detection"** (Kheliel *et al.*, under review at IEEE Access). **Code:** [github.com/hanizmo/CephSSL](https://github.com/hanizmo/CephSSL) (pretraining, fine-tuning, calibrated evaluation, cascade, demo) > Research use only. These models are not validated for clinical use. ## At a glance | | | |---|---| | Unlabeled pretraining corpus | 11,953 lateral craniofacial radiographs (grayscale, 224 px) | | SSL objectives × encoders | 7 × 5 = **35 pretrained encoders** (SimCLR, Barlow Twins, BYOL, MoCo v2, SimSiam, SwAV, DINO × ResNet-18/34/50, ViT-S/16, ViT-B/16) | | Fine-tuning dataset | 895 AAOF Legacy Collection cephalograms, 19 landmarks, per-image mm calibration | | Best AAOF detector | SimCLR–ResNet-18, test MRE **4.86 mm** (135 test images) | | Transfer dataset | ISBI 2015 cephalometric dataset (400 images, called CEPHA400 in the paper), 19 landmarks | | Five-stage cascade | MRE **1.89 ± 0.07 mm**, SDR@2mm 67.8 ± 1.2 % over ten random 300/100 splits | ## What is in this repository ``` encoders//.safetensors 35 SSL-pretrained encoders (backbone only, 1-channel input) aaof_detector/simclr_resnet18_aaof.pth selected AAOF 19-landmark heatmap detector (4.86 mm) cepha400_cascade/ cascade of the best split (seed 1005) stageB_768.pth full image, 768x960 stageD_predictedcrop.pth crop around Stage B's predictions specialist_LXX.pth the 11 per-landmark specialists kept by the gate splits/aaof_split.csv AAOF 626 / 134 / 135 split (file names only) splits/cepha400_random_splits.csv the ten random 300/100 CEPHA400 splits (seeds 1000-1009) calibration/aaof_pixel_spacing.csv per-image AAOF pixel spacing (mm/px) from the calibration fiducials results/ per-image AAOF test predictions and the paper's result tables configs//*.yaml the 35 pretraining configurations ``` `` is one of `simclr`, `barlow_twins`, `byol`, `moco_v2`, `simsiam`, `swav`, `dino`; `` is one of `resnet18`, `resnet34`, `resnet50`, `vit_s16`, `vit_b16`. **No images or landmark annotations are distributed here.** Download the AAOF Craniofacial Growth Legacy Collection and the ISBI 2015 dataset from their providers (see *Data access*). ## Quick start: load an SSL encoder All encoders take **single-channel** images normalized with mean 0.449 and std 0.226. ```python import torch, torchvision, timm from huggingface_hub import hf_hub_download from safetensors.torch import load_file REPO = "hanizmo/CephSSL" # ResNet (here SimCLR ResNet-18); use resnet34 / resnet50 the same way path = hf_hub_download(REPO, "encoders/simclr/resnet18.safetensors") resnet = torchvision.models.resnet18(weights=None) resnet.conv1 = torch.nn.Conv2d(1, 64, kernel_size=7, stride=2, padding=3, bias=False) resnet.fc = torch.nn.Identity() resnet.load_state_dict({k.removeprefix("backbone."): v for k, v in load_file(path).items()}) features = resnet(torch.randn(1, 1, 640, 640)) # (1, 512) # ViT (here SimCLR ViT-S/16); use "vit_base_patch16_224" for vit_b16 path = hf_hub_download(REPO, "encoders/simclr/vit_s16.safetensors") vit = timm.create_model("vit_small_patch16_224", pretrained=False, in_chans=1, num_classes=0) vit.load_state_dict({k.removeprefix("backbone.model."): v for k, v in load_file(path).items()}) features = vit(torch.randn(1, 1, 224, 224)) # (1, 384) ``` The AAOF detector and the cascade files are PyTorch checkpoints (`torch.load(..., weights_only=True)`) with a `model` state dict plus metadata (`img_size`, `heatmap_size`; for specialists `landmark_name`, `patch_px`, `keep`). The detector architecture (encoder + U-Net-style heatmap decoder, soft-argmax decoding) and the cascade inference script are in the [code repository](https://github.com/hanizmo/CephSSL) (`cascade/predict.py image.jpg` downloads these weights and predicts the 19 landmarks). ## Benchmarks ### AAOF fine-tuning: test MRE (mm), 135 test images | Method | ResNet-18 | ResNet-34 | ResNet-50 | ViT-S/16 | ViT-B/16 | |---|---|---|---|---|---| | SimCLR | **4.86** | 5.02 | 5.00 | 6.02 | 5.71 | | Barlow Twins | 4.97 | 5.20 | 4.92 | 6.67 | 5.70 | | BYOL | 5.67 | 5.10 | 5.07 | 6.36 | 5.58 | | MoCo v2 | 5.00 | 5.53 | 5.21 | 6.90 | 5.28 | | SimSiam | 4.93 | 6.53 | 5.49 | 7.77 | 7.54 | | SwAV | 5.79 | 8.11 | 6.83 | 14.34 | 15.93 | | DINO | 5.21 † | 5.18 † | 5.47 † | 9.93 | 7.53 | ResNets are fine-tuned at 640 px and ViTs at 224 px. † DINO ResNet pretraining diverged early (epochs 9–27); the released checkpoints are the last ones before divergence (epochs 8, 9 and 25). The best configurations are not statistically distinguishable (see the paper). AAOF images are about 800 px wide (0.25–0.44 mm/px), so millimeter errors are not comparable with the 0.1 mm/px ISBI images. ### CEPHA400 cascade | Stage | Input | MRE (mm), mean ± std over 10 splits | Best split (seed 1005) | |---|---|---|---| | A | Full image, 640×640 | 2.48 ± 0.09 | 2.38 | | B | Full image, 768×960 | 2.17 ± 0.07 | 2.11 | | C | Crop around ground-truth landmarks (training step only) | 2.00 ± 0.08 | 1.88 | | D | Crop around Stage B predictions | 1.93 ± 0.07 | 1.81 | | E | D + gated per-landmark specialists | **1.89 ± 0.07** | 1.77 | The released cascade is the best of the ten splits. CEPHA400 has no separate validation split, so epochs, specialist patch sizes and the keep/discard gate were selected on the test images; the numbers are therefore optimistic. The split is random (300/100) and uses the senior annotator's labels, so it is not comparable with the official ISBI 2015 partition. ## Files | File | Content | |---|---| | `splits/aaof_split.csv` | `image_name, split`. Files sorted by name, first 70 % train, next 15 % val, last 15 % test | | `splits/cepha400_random_splits.csv` | `run_idx, split_seed, split, filename` for the ten splits | | `calibration/aaof_pixel_spacing.csv` | Per-image mm/px. `used_in_paper_evaluation` = the value used for val/test errors; `fiducial_pairs_mean` = mean over the fiducial pairs for training images | | `results/aaof_simclr_test_predictions.csv` | Ground-truth and predicted landmark pixels, pixel spacing and error per landmark, SimCLR encoders | | `results/tab_*.csv`, `cepha400_ten_splits_summary.csv` | The paper's result tables | ## Important notes - **Pretraining–evaluation overlap.** The unlabeled pretraining corpus contains the AAOF and ISBI images used for evaluation (without their labels). Landmark annotations were never used during pretraining. - **Single seed.** Each of the 35 configurations was pretrained and fine-tuned once. - The pretraining corpus includes privately collected clinical radiographs, which are not distributed. ## Data access - AAOF Craniofacial Growth Legacy Collection: https://www.aaoflegacycollection.org - ISBI 2015 Grand Challenge (cephalometric X-ray): obtain from the challenge organizers. ## License Weights and files: **CC BY-NC 4.0** (non-commercial use, attribution required). ## Citation ```bibtex @article{kheliel2026cephssl, title = {In-Domain Self-Supervised Pretraining for Cephalometric Landmark Detection}, author = {Kheliel, Hani and others}, journal = {IEEE Access}, note = {under review}, year = {2026} } ```