File size: 1,934 Bytes
66b979e
 
 
 
 
c91704d
 
c0382a2
66b979e
 
d00dd2d
 
 
 
c91704d
65468ce
25f3720
85bc6a7
 
 
 
 
65468ce
d00dd2d
 
d01bc54
c8144a7
 
 
 
 
d00dd2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a6a235
c8144a7
c91704d
 
 
 
0a6a235
c91704d
 
 
 
 
 
 
 
0a6a235
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
pipeline_tag: image-classification
tags:
- model_hub_mixin
- pytorch_model_hub_mixin
- OCT
- classification
- retinal-imaging
---

## RetFiner-VisionFM
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).

Project page: [RetFiner](https://github.com/ronnief1/RetFiner)

### Required Libraries
This model requires specific Python libraries:
```bash
torch==2.4.1+cu118
timm==0.4.12
torchvision==0.19.1+cu118
```

To use the model, please download the ViT implementation from [visionfm_hf.py](https://github.com/ronnief1/RetFiner/blob/main/RetFiner/visionfm_hf.py)

Note: if you are using this for downstream inference, adjust the num_classes based on the target dataset.

```python
import torch
import torch.nn as nn
from huggingface_hub import PyTorchModelHubMixin
from visionfm_hf import VisionTransformer

class RetFiner(nn.Module, PyTorchModelHubMixin):
    """RetFiner: Fine-tuned ViT models for retinal image analysis"""
    
    def __init__(self, model_name: str = "RetFiner-VisionFM", num_classes: int = 2, **kwargs):
        super().__init__()
        
        self.model = VisionTransformer(return_all_tokens=True, qkv_bias=True)
        
        self.config = {
            **kwargs
        }

    def forward(self, x):
        return self.model(x)

model = RetFiner.from_pretrained('ronnief1/RetFiner-VisionFM')
```

## Citation

Please cite the original paper if you use this model:

```python
@misc{fecso2025retfinervisionlanguagerefinementscheme,
      title={RetFiner: A Vision-Language Refinement Scheme for Retinal Foundation Models}, 
      author={Ronald Fecso and José Morano and Ursula Schmidt-Erfurth and Hrvoje Bogunović},
      year={2025},
      eprint={2506.22149},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2506.22149}, 
}
```