File size: 2,095 Bytes
0d6672b
 
 
 
 
 
 
 
 
 
3e46f55
d86fbda
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cca14cf
d86fbda
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
67
68
69
70
71
72
73
74
75
---
pipeline_tag: image-classification
tags:
- model_hub_mixin
- pytorch_model_hub_mixin
- pytorch
- OCT
- classification
- retinal-imaging
---

## RetFiner-UrFound
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 [vit.py](https://github.com/ronnief1/RetFiner/blob/main/RetFiner/vit.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 vit import vit_base_patch16

class RetFiner(nn.Module, PyTorchModelHubMixin):
    """RetFiner: Fine-tuned ViT models for retinal image analysis"""
    
    def __init__(self, model_name: str = "RetFiner-UrFound", num_classes: int = 0, **kwargs):
        super().__init__()
        
        self.model = vit_base_patch16(
            img_size=224,
            num_classes=num_classes,
            drop_path_rate=0.1,
            global_pool=False,
            use_proj=False,
            **kwargs
        )
 
        self.config = {
            "num_classes": num_classes,
            **kwargs
        }

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

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

## 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}, 
}
```