RETFOUND / README.md
Monish BV
update README.md
0c2968a
---
license: cc-by-nc-4.0
language:
- en
tags:
- retinal-imaging
- oct
- foundation-model
- pytorch
- mae
---
# RETFound OCT — MAE checkpoint (`.pth`)
This repository hosts **`RETFound_oct.pth`**: the full **masked autoencoder (MAE)** ViT-Large checkpoint used as the **encoder** in workflows that load RETFound with `torch.load` (custom ViT backbones, e.g. the RetinaPainter trainer). It is **not** the Hugging Face Transformers bundle (`model.safetensors` + `AutoModel`). Official RETFound code and context: [rmaphoh/RETFound_MAE](https://github.com/rmaphoh/RETFound_MAE).
For **Transformers** / `AutoModel` / image-feature pipelines on the same research line, see [**iszt/RETFound_mae_natureOCT**](https://huggingface.co/iszt/RETFound_mae_natureOCT).
## Access (gated)
This model uses **gated user access** with **automatic approval**.
1. Sign in at [huggingface.co](https://huggingface.co).
2. Open this model page and **accept** the access terms (contact details may be collected per Hub policy).
3. Create a **read** token: [Settings → Access tokens](https://huggingface.co/settings/tokens).
4. Authenticate locally: `huggingface-cli login` or set the environment variable **`HF_TOKEN`**.
Until you complete step 2 for your account, programmatic downloads may return an access error.
## Files
| File | Description |
|------|-------------|
| `RETFound_oct.pth` | Full MAE checkpoint (encoder + decoder weights in one file). Load with PyTorch; downstream code often keeps only the ViT encoder weights. |
## Download (Python)
```python
from huggingface_hub import hf_hub_download
path = hf_hub_download(
repo_id="monish563/RETFOUND",
filename="RETFound_oct.pth",
)
print(path)
```
Requires `huggingface_hub` and a logged-in session (or `HF_TOKEN`) after gated access is accepted.
### Hugging Face CLI (alternative)
```bash
huggingface-cli download monish563/RETFOUND RETFound_oct.pth --local-dir ~/.cache/retina_painter
```
Use the same folder layout as above if your tool expects `~/.cache/retina_painter/RETFound_oct.pth`.
## RetinaPainter
In **RetinaPainter** RETFound modes, the trainer pulls this file via `trainer/src/retfound_model.py` into **`~/.cache/retina_painter/RETFound_oct.pth`**. From the RetinaPainter repo root run **`python setup_retfound.py`** (interactive) or **`python setup_retfound.py --token YOUR_HF_TOKEN`** after accepting gated access on this page.
## License
**[CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/)** — non-commercial use with attribution. **Commercial use** is not permitted under this license unless you have separate permission from the rights holders.
## Citation
If you use these weights or the RETFound methodology, cite the original paper:
> Zhou, Y., et al. A foundation model for generalizable disease detection from retinal images. *Nature* **622**, 156–163 (2023). [https://doi.org/10.1038/s41586-023-06555-x](https://doi.org/10.1038/s41586-023-06555-x)
BibTeX:
```bibtex
@article{zhou2023foundation,
title={A foundation model for generalizable disease detection from retinal images},
author={Zhou, Yukun and Chia, Mark A and Wagner, Siegfried K and Ayhan, Murat S and Williamson, Dominic J and Struyven, Robbert R and Liu, Timing and Xu, Moucheng and Lozano, Mateo G and Woodward-Court, Peter and others},
journal={Nature},
volume={622},
number={7981},
pages={156--163},
year={2023},
publisher={Nature Publishing Group UK London}
}
```
## Disclaimer
These weights are for **research and engineering** (e.g. feature extraction, transfer learning). They are **not** validated for clinical decision-making and must not be used as a medical device without appropriate study, oversight, and regulatory compliance where applicable.