File size: 3,008 Bytes
76f7e50
 
4bee0c2
 
 
 
 
 
 
 
 
 
76f7e50
4bee0c2
 
 
 
d43bae2
 
 
 
4bee0c2
 
 
 
 
 
 
 
 
2800753
4bee0c2
 
 
 
 
 
06073a5
3884f9a
4bee0c2
 
 
 
 
f4c200f
 
 
4bee0c2
 
 
 
 
 
 
 
ec27734
4bee0c2
3d72fc8
4bee0c2
 
 
 
3d72fc8
 
4bee0c2
 
 
 
3d72fc8
 
 
 
 
 
 
 
 
 
 
4bee0c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
license: apache-2.0
tags:
- image-segmentation
- vision
- fundus
- optic disc
- optic cup
widget:
- src: >-
    https://huggingface.co/pamixsun/swinv2_tiny_for_glaucoma_classification/resolve/main/example.jpg
  example_title: fundus image
---
# Model Card for Model ID

<!-- Provide a quick summary of what the model is/does. -->

This SegFormer model has undergone specialized fine-tuning on the [REFUGE challenge dataset](https://refuge.grand-challenge.org/), 
a public benchmark for semantic segmentation of anatomical structures in retinal fundus images. 
The fine-tuning enables expert-level segmentation of the optic disc and optic cup, two critical structures for ophthalmological diagnosis.


## Model Details

### Model Description

<!-- Provide a longer summary of what this model is. -->

- **Developed by:** [Xu Sun](https://pamixsun.github.io)
- **Shared by:** [Xu Sun](https://pamixsun.github.io)
- **Model type:** Image segmentation
- **License:** Apache-2.0

## Uses

<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->

This pretrained model enables semantic segmentation of key anatomical structures, namely, the optic disc and optic cup, in retinal fundus images. 
It takes fundus images as input and outputs the segmentation results.

## Bias, Risks, and Limitations

<!-- This section is meant to convey both technical and sociotechnical limitations. -->

The model has undergone specialized training and fine-tuning exclusively using retinal fundus images, 
with the objective to perform semantic segmentation of anatomical structures including the optic disc and optic cup. 
Therefore, in order to derive optimal segmentation performance, it is imperative to ensure that only fundus images are entered as inputs to this model.

## How to Get Started with the Model

Use the code below to get started with the model.

```python
import cv2
import torch
import numpy as np

from transformers import AutoImageProcessor, SegformerForSemanticSegmentation

image = cv2.imread('./example.jpg')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

processor = AutoImageProcessor.from_pretrained("pamixsun/segformer_for_optic_disc_cup_segmentation")
model = SegformerForSemanticSegmentation.from_pretrained("pamixsun/segformer_for_optic_disc_cup_segmentation")

inputs = processor(image, return_tensors="pt")

with torch.no_grad():
    outputs = self.seg_model(**inputs)
    logits = outputs.logits.cpu()

upsampled_logits = nn.functional.interpolate(
    logits,
    size=image.shape[:2],
    mode="bilinear",
    align_corners=False,
)

pred_disc_cup = upsampled_logits.argmax(dim=1)[0].numpy().astype(np.uint8)

```

## Citation [optional]

<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->

**BibTeX:**

[More Information Needed]

**APA:**

[More Information Needed]


## Model Card Contact

- pamixsun@gmail.com