Update README.md
Browse files
README.md
CHANGED
|
@@ -8,9 +8,10 @@ tags:
|
|
| 8 |
- retinal-imaging
|
| 9 |
---
|
| 10 |
|
| 11 |
-
|
| 12 |
-
-
|
| 13 |
-
|
|
|
|
| 14 |
|
| 15 |
### Required Libraries
|
| 16 |
This model requires specific Python libraries:
|
|
@@ -20,13 +21,32 @@ timm==0.4.12
|
|
| 20 |
torchvision==0.19.1+cu118
|
| 21 |
```
|
| 22 |
|
|
|
|
|
|
|
| 23 |
Note: if you are using this for downstream inference, adjust the num_classes based on the target dataset.
|
| 24 |
|
| 25 |
```python
|
| 26 |
import torch
|
| 27 |
import torch.nn as nn
|
| 28 |
from huggingface_hub import PyTorchModelHubMixin
|
| 29 |
-
from
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
```
|
| 31 |
|
| 32 |
## Citation
|
|
|
|
| 8 |
- retinal-imaging
|
| 9 |
---
|
| 10 |
|
| 11 |
+
## RetFiner-VisionFM
|
| 12 |
+
This repo contains the weights of RetFiner-VisionFM from the paper [RetFiner: A Vision-Language Refinement Scheme for Retinal Foundation Models](https://arxiv.org/abs/2506.22149).
|
| 13 |
+
|
| 14 |
+
Project page: [RetFiner](https://github.com/ronnief1/RetFiner)
|
| 15 |
|
| 16 |
### Required Libraries
|
| 17 |
This model requires specific Python libraries:
|
|
|
|
| 21 |
torchvision==0.19.1+cu118
|
| 22 |
```
|
| 23 |
|
| 24 |
+
To use the model, please download the ViT implementation from [visionfm_hf.py](https://github.com/ronnief1/RetFiner/blob/main/RetFiner/visionfm_hf.py)
|
| 25 |
+
|
| 26 |
Note: if you are using this for downstream inference, adjust the num_classes based on the target dataset.
|
| 27 |
|
| 28 |
```python
|
| 29 |
import torch
|
| 30 |
import torch.nn as nn
|
| 31 |
from huggingface_hub import PyTorchModelHubMixin
|
| 32 |
+
from visionfm_hf import VisionTransformer
|
| 33 |
+
|
| 34 |
+
class RetFiner(nn.Module, PyTorchModelHubMixin):
|
| 35 |
+
"""RetFiner: Fine-tuned ViT models for retinal image analysis"""
|
| 36 |
+
|
| 37 |
+
def __init__(self, model_name: str = "RetFiner-VisionFM", num_classes: int = 2, **kwargs):
|
| 38 |
+
super().__init__()
|
| 39 |
+
|
| 40 |
+
self.model = VisionTransformer(return_all_tokens=True, qkv_bias=True)
|
| 41 |
+
|
| 42 |
+
self.config = {
|
| 43 |
+
**kwargs
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
def forward(self, x):
|
| 47 |
+
return self.model(x)
|
| 48 |
+
|
| 49 |
+
model = RetFiner.from_pretrained('ronnief1/RetFiner-VisionFM')
|
| 50 |
```
|
| 51 |
|
| 52 |
## Citation
|