Downloads · 30 days
17
18% of all-time downloads
vselvarajijay/vjepa2-echonet-ef
vjepa2-echonet-ef is a video classification model from vselvarajijay. Use it for the video classification task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as cc-by-nc-4.0.
Research / triage-aid only. Not a medical device. Not for clinical use.
Downloads · 30 days
17
18% of all-time downloads
All-time downloads
96
Public
Repo size
326 KB
Likes
0
Public
Click a slice to open those files.
.png414 KB · 95%
From the Hugging Face model README
Research / triage-aid only. Not a medical device. Not for clinical use.
A frozen V-JEPA 2 ViT-L video encoder paired with a linear (Ridge) regression head, trained to predict left-ventricular ejection fraction (EF) from apical four-chamber echocardiographic videos.
The headline finding is that a frozen, generic video foundation model — V-JEPA 2 trained on natural internet video, never tuned on echo — produces representations strong enough to support clinically-meaningful HFrEF screening when paired with a 1024-d → 1 linear head. No fine-tuning of the encoder.
| Base encoder | facebook/vjepa2-vitl-fpc64-256 (V-JEPA 2 ViT-L, 326M params, frozen) |
| Head | Linear(1024 → 1) fitted by Ridge regression with α tuned on the validation split |
| Trainable parameters | 1,025 (1024 weights + 1 bias) |
| Input | Video clip; 64 frames at 256×256, replicated to 3 channels for grayscale |
| Pre-pool aggregation | 3 evenly-spaced clips per video → V-JEPA encoder → mean over (clip × token) → 1024-d vector |
| Output | Continuous left-ventricular ejection fraction (EF) prediction in % |
| Framework | PyTorch + HuggingFace Transformers (transformers.models.vjepa2.VJEPA2Model) |
| License | CC-BY-NC 4.0 (inherits from V-JEPA 2 base; downstream data use also gated by the EchoNet-Dynamic agreement) |
EchoNet-Dynamic, Stanford/Cedars-Sinai (Ouyang et al., Nature 2020):
EchoNet-Dynamic is released for research use under its own data use agreement; this model's downstream use inherits those constraints.
last_hidden_state, mean-pool over tokens.alpha ∈ {0.01, 0.1, 1, 3, 10, 30, 100, 300, 1000} selected by minimising MAE on the 1,288-row validation split.torch.nn.Linear(1024, 1) for inference parity with PyTorch-native heads.The entire head training takes seconds because it operates in embedding space, not pixel space.
| Metric | Value |
|---|---|
| MAE (EF percentage points) | 5.443 |
| RMSE | 7.093 |
| R² (EF regression) | 0.663 |
| AUROC, screening EF<40 | 0.955 |
| AUPRC, screening EF<40 | 0.840 |
| Prevalence, EF<40 | 0.125 |
| AUROC, screening EF<50 | 0.934 |
| AUPRC, screening EF<50 | 0.853 |
| Prevalence, EF<50 | 0.223 |
For context, the published EchoNet end-to-end 3D-CNN specialist (Ouyang et al., Nature 2020) achieves MAE ≈ 4.1 on the same test set. This model is within 1.3 EF points of that specialist while training only a 1,025-parameter linear head on top of frozen general-purpose video features.

Left panel: HFrEF screening (true label EF<40), AUROC 0.955. Right panel: any reduced EF (true label EF<50), AUROC 0.934. Operating points are the val-tuned cutoffs (45.83 and 53.17 respectively) applied to the TEST split.

Each point is one TEST video, coloured by clinical class. The dashed line is y = x (perfect prediction). Two patterns are visible: (i) strong correlation along the diagonal, confirming the regression signal; (ii) red dots clustered above the diagonal in the actual-EF<30 range — these are HFrEF cases the model predicts too high (the off-by-two failure mode). MAE on TEST is 5.44.

Bin actual EF in 8-percent-wide buckets; plot the mean predicted EF per bucket against the bucket centre, with n annotations for bucket counts. The model is well-calibrated near the population mean (40–60% bin centres) and regresses to the mean at both extremes — over-predicting in the very-low-EF range (predicts ~30 when truth ≈ 14) and under-predicting at high EFs. This Ridge-regression-to-mean bias is the reason the val-tuned screening cutoff (45.83 for EF<40) is higher than the clinical threshold (40), not lower.
The screening rule is flag iff predicted_EF < cutoff. The val-tuned cutoff is the value at which target_sensitivity fraction of HFrEF cases in the validation set fall below the cutoff (i.e. the target_sensitivity-quantile of the positive-class predicted-EF distribution on VAL).
| Operating point | Cutoff (predicted EF) | Sensitivity | Specificity | TP | FP | FN | TN |
|---|---|---|---|---|---|---|---|
| Naive | 40.00 | 0.519 | 0.992 | 83 | 9 | 77 | 1108 |
| Val-tuned (target sens 0.85) | 45.83 | 0.775 | 0.957 | 124 | 48 | 36 | 1069 |
| Operating point | Cutoff (predicted EF) | Sensitivity | Specificity | TP | FP | FN | TN |
|---|---|---|---|---|---|---|---|
| Naive | 50.00 | 0.751 | 0.940 | 214 | 60 | 71 | 932 |
| Val-tuned (target sens 0.85) | 53.17 | 0.874 | 0.837 | 249 | 162 | 36 | 830 |
Val→test sensitivity gap. The val-tuned cutoff is calibrated to hit a target sensitivity on VAL, but TEST sensitivity is a noisy estimate of that target. For HFrEF (rare class, 161 positives in VAL) the realised TEST sens is 0.775 vs target 0.85 — a ~7.5 pp gap consistent with sampling variance in the rare class. For EF<50 (more positives, more stable threshold) the realised TEST sens is 0.874, slightly above target. Operating points should be re-tuned per deployment population.
Predicted
HFrEF HFmrEF HFpEF
True HFrEF 83 61 16
HFmrEF 8 62 55
HFpEF 1 59 932
Per-class accuracy: HFrEF 52%, HFmrEF 50%, HFpEF 94%. Most errors are off-by-one (adjacent class), which is the clinically benign failure mode.
The EchoNet-Dynamic dataset does not include detailed demographic metadata in the public release. The model has not been evaluated for bias across age, sex, race/ethnicity, body habitus, or scanning operator. Any deployment in a population whose distribution differs from the EchoNet cohort would require independent validation.
EF is used in real clinical pathways to decide on guideline-directed medical therapy for heart failure. A miscalibrated model could plausibly cause harm if naively deployed. The intended use of this artefact is to support method development and reproducible benchmarking — not to influence patient care.
import torch
from huggingface_hub import hf_hub_download
from safetensors.torch import load_file
from transformers import AutoModel, AutoVideoProcessor
REPO_ID = "vselvarajijay/vjepa2-echonet-ef"
BASE_MODEL = "facebook/vjepa2-vitl-fpc64-256"
# 1. Load V-JEPA 2 frozen encoder from HuggingFace
processor = AutoVideoProcessor.from_pretrained(BASE_MODEL)
encoder = AutoModel.from_pretrained(BASE_MODEL, dtype=torch.float16).eval()
# 2. Pull the trained Ridge head from this repo
head_path = hf_hub_download(repo_id=REPO_ID, filename="head.safetensors")
head = torch.nn.Linear(1024, 1)
head.load_state_dict(load_file(head_path))
head.eval()
# 3. Encode a video clip and predict EF
# `frames` must be a numpy array shape (T=64, H=256, W=256, C=3), uint8.
# For grayscale echo, replicate the single channel to 3 channels.
# See `inference_example.py` in this repo for full clip-sampling + multi-clip averaging.
inputs = processor(videos=list(frames), return_tensors="pt")
with torch.inference_mode():
hidden = encoder(**inputs).last_hidden_state # (1, N_tokens, 1024)
embedding = hidden.float().mean(dim=1).squeeze(0) # (1024,)
ef_pred = head(embedding).item() # float, EF in %
# Reduced-EF screening (HFrEF) at the val-tuned cutoff:
print(f"EF: {ef_pred:.2f}% Reduced-EF flag: {ef_pred < 45.83}")
The snippet above pulls just the head from this repo. For an end-to-end script that decodes a .avi/.mp4 directly and averages multiple clips, see inference_example.py.
If you use this model, cite both the V-JEPA 2 base and the EchoNet-Dynamic dataset:
@article{ouyang2020video,
title={Video-based AI for beat-to-beat assessment of cardiac function},
author={Ouyang, David and He, Bryan and Ghorbani, Amirata and Yuan, Neal and
Ebinger, Joseph and Langlotz, Curtis P and Heidenreich, Paul A and
Harrington, Robert A and Liang, David H and Ashley, Euan A and Zou, James Y},
journal={Nature},
volume={580},
pages={252--256},
year={2020}
}
@misc{assran2025vjepa2,
title={V-JEPA 2: Self-Supervised Video Models Enable Understanding, Prediction, and Planning},
author={Assran, Mahmoud and Bardes, Adrien and others},
year={2025},
publisher={Meta AI}
}
(1 - target)-quantile with target-quantile of positive predictions). Tuned operating points populated: EF<40 @ cutoff 45.83 → Sens 0.775, Spec 0.957; EF<50 @ cutoff 53.17 → Sens 0.874, Spec 0.837.figures/) generated by app.figures.clips_per_video from 3 to 6. Result: marginally worse (MAE 5.487 vs 5.443) — within run-to-run noise. Mean-pooling more clips at the embedding level does not improve signal because the dominant embedding axes are EF-irrelevant appearance variance. 3-clip remains canonical. Future clip-count scaling will need concat or attention pooling, not averaging.