|
Download weights/README.md from zirongliu/RetRep: direct link, hf CLI and curl.
- Browser
- Download file 3.22 kB
-
https://huggingface.co/zirongliu/RetRep/resolve/main/weights/README.md
- Command line
-
hf download hf://zirongliu/RetRep/weights/README.md
-
curl -L -o README.md https://huggingface.co/zirongliu/RetRep/resolve/main/weights/README.md
3.22 kB
| # RetRep — Retinal Foundation Models Repository | |
| A unified Python package for retinal/ophthalmology foundation models with a timm-compatible API. | |
| Create, extract features, and fine-tune 16+ pretrained vision models for fundus, OCT, and retinal image analysis. | |
| ## Quick Start | |
| ```python | |
| import torch | |
| from retrep import create_model, list_models | |
| # List all available models | |
| print(list_models()) | |
| # Feature extraction with RETFound (auto-downloads weights from HuggingFace) | |
| model = create_model('retfound_dinov2_meh', pretrained=True, hf_token='YOUR_HF_TOKEN') | |
| features = model(torch.randn(1, 3, 518, 518)) | |
| print(features.shape) # torch.Size([1, 1024]) | |
| ``` | |
| ## Weight Auto-Download | |
| RetRep automatically downloads model weights from HuggingFace Hub when needed: | |
| 1. **Local `weights/` directory** — checked first (for development) | |
| 2. **HF cache** (`~/.cache/retrep/weights/`) — checked second | |
| 3. **HuggingFace Hub** — auto-downloaded if not found locally | |
| ```python | |
| from retrep import get_weight_path | |
| # Get weight path (auto-downloads if needed) | |
| path = get_weight_path("retfound_dinov2_meh") | |
| print(path) # /home/user/.cache/retrep/weights/retfound_dinov2_meh.pth | |
| ``` | |
| ## Model Registry | |
| | Model Name | Type | Backbone | Input Size | Output Dim | Weight Source | | |
| |---|---|---|---|---|---| | |
| | `retfound_mae_natureCFP` | MAE | ViT-L/16 | 224x224 | 1024 | [HF](https://huggingface.co/YukunZhou/RETFound_mae_natureCFP) (gated) | | |
| | `retfound_mae_natureOCT` | MAE | ViT-L/16 | 224x224 | 1024 | [HF](https://huggingface.co/YukunZhou/RETFound_mae_natureOCT) (gated) | | |
| | `retfound_mae_meh` | MAE | ViT-L/16 | 224x224 | 1024 | [HF](https://huggingface.co/YukunZhou/RETFound_mae_meh) (gated) | | |
| | `retfound_mae_shanghai` | MAE | ViT-L/16 | 224x224 | 1024 | [HF](https://huggingface.co/YukunZhou/RETFound_mae_shanghai) (gated) | | |
| | `retfound_dinov2_meh` | DINOv2 | ViT-L/14 | 518x518 | 1024 | Auto-download from HF | | |
| | `retfound_dinov2_shanghai` | DINOv2 | ViT-L/14 | 518x518 | 1024 | Auto-download from HF | | |
| | `urfound` | MAE | ViT-B/16 | 224x224 | 768 | Auto-download from HF | | |
| | `flair` | CLIP | SigLIP-B/16 | 224x224 | 512 | Auto-download from HF | | |
| | `eyeclip` | CLIP | ViT-B/32 | 224x224 | 768 | Auto-download from HF | | |
| | `ret_clip` | CLIP | ViT-B/16 | 224x224 | 768 | Auto-download from HF | | |
| | `vision_fm` | Self-supervised | ViT-B/16 | 224x224 | 768 | Auto-download from HF | | |
| | `eyecare_gpt` | SigLIP | SigLIP-So400m | 384x384 | 1152 | Auto-download from HF | | |
| | `reti_zero` | CLIP+LoRA | ViT-L/16 | 224x224 | 512 | Auto-download from HF | | |
| | `keepfit` | CLIP | ResNet-50 | 512x512 | 512 | Auto-download from HF | | |
| | `vision_unite` | Multimodal | EVA02-B/14 + CLIP | 224x224 | 768 | Auto-download from HF | | |
| | `deepdr_llm` | Multimodal | ViT-B/16 | 224x224 | 768 | No pretrained weights | | |
| ## Installation | |
| ```bash | |
| pip install -e . | |
| # Optional: for CLIP-style models (EyeCLIP, FLAIR, RET-CLIP) | |
| pip install -e ".[clip]" | |
| ``` | |
| ## Uploading Weights to HuggingFace | |
| ```bash | |
| # Set your HF token | |
| export HF_TOKEN=hf_xxxxx | |
| # Upload all weights | |
| python scripts/upload_weights_to_hf.py | |
| # Upload a single file | |
| python scripts/upload_weights_to_hf.py --file retfound_dinov2_meh.pth | |
| ``` | |
| ## License | |
| MIT — see [LICENSE](../LICENSE) | |