Upload 6 files
Browse files- .gitattributes +0 -1
- README.md +95 -0
- config.json +54 -0
- example.jpg +0 -0
- preprocessor_config.json +22 -0
- pytorch_model.bin +3 -0
.gitattributes
CHANGED
@@ -25,7 +25,6 @@
|
|
25 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
*.wasm filter=lfs diff=lfs merge=lfs -text
|
|
|
25 |
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
|
|
28 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
*.wasm filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
tags:
|
4 |
+
- image-classification
|
5 |
+
- vision
|
6 |
+
- fundus
|
7 |
+
- glaucoma
|
8 |
+
- REFUGE
|
9 |
+
widget:
|
10 |
+
- src: >-
|
11 |
+
https://huggingface.co/pamixsun/swinv2_tiny_for_glaucoma_classification/resolve/main/example.jpg
|
12 |
+
example_title: fundus image
|
13 |
+
---
|
14 |
+
# Model Card for Model ID
|
15 |
+
|
16 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
17 |
+
|
18 |
+
This model utilizes a Swin Transformer architecture and has undergone supervised fine-tuning on retinal fundus images from the [REFUGE challenge dataset](https://refuge.grand-challenge.org/).
|
19 |
+
It is specialized in automated analysis of retinal fundus photographs for glaucoma detection.
|
20 |
+
By extracting hierarchical visual features from input fundus images in a cross-scale manner, the model is able to effectively categorize each image as either glaucoma or non-glaucoma. Extensive experiments demonstrate that this model architecture achieves state-of-the-art performance on the REFUGE benchmark for fundus image-based glaucoma classification.
|
21 |
+
To obtain optimal predictions, it is recommended to provide this model with standardized retinal fundus photographs captured using typical fundus imaging protocols.
|
22 |
+
|
23 |
+
## Model Details
|
24 |
+
|
25 |
+
### Model Description
|
26 |
+
|
27 |
+
<!-- Provide a longer summary of what this model is. -->
|
28 |
+
|
29 |
+
- **Developed by:** [Xu Sun](https://pamixsun.github.io)
|
30 |
+
- **Shared by:** [Xu Sun](https://pamixsun.github.io)
|
31 |
+
- **Model type:** Image classification
|
32 |
+
- **License:** Apache-2.0
|
33 |
+
|
34 |
+
## Uses
|
35 |
+
|
36 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
37 |
+
|
38 |
+
The pretrained model provides glaucoma classification functionality solely based on analysis of retinal fundus images.
|
39 |
+
You may directly utilize the raw model without modification to categorize fundus images as either glaucoma or non-glaucoma.
|
40 |
+
This model is specialized in extracting discriminative features from fundus images to identify glaucoma manifestations.
|
41 |
+
However, to achieve optimal performance, it is highly recommended to fine-tune the model on a representative fundus image dataset prior to deployment in real-world applications.
|
42 |
+
|
43 |
+
## Bias, Risks, and Limitations
|
44 |
+
|
45 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
46 |
+
|
47 |
+
The model is specialized in analyzing retinal fundus images, and is trained exclusively on fundus image datasets to classify images as glaucoma or non-glaucoma.
|
48 |
+
Therefore, to obtain accurate predictions, it is crucial to only input fundus images when using this model.
|
49 |
+
Feeding other types of images may lead to meaningless results.
|
50 |
+
In summary, this model expects fundus images as input for glaucoma classification.
|
51 |
+
For the best performance, please adhere strictly to this input specification.
|
52 |
+
|
53 |
+
## How to Get Started with the Model
|
54 |
+
|
55 |
+
Use the code below to get started with the model.
|
56 |
+
|
57 |
+
```python
|
58 |
+
import cv2
|
59 |
+
import torch
|
60 |
+
|
61 |
+
from transformers import AutoImageProcessor, Swinv2ForImageClassification
|
62 |
+
|
63 |
+
image = cv2.imread('./example.jpg')
|
64 |
+
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
65 |
+
|
66 |
+
processor = AutoImageProcessor.from_pretrained("pamixsun/swinv2_tiny_for_glaucoma_classification")
|
67 |
+
model = Swinv2ForImageClassification.from_pretrained("pamixsun/swinv2_tiny_for_glaucoma_classification")
|
68 |
+
|
69 |
+
inputs = processor(image, return_tensors="pt")
|
70 |
+
|
71 |
+
with torch.no_grad():
|
72 |
+
logits = model(**inputs).logits
|
73 |
+
|
74 |
+
# model predicts either glaucoma or non-glaucoma.
|
75 |
+
predicted_label = logits.argmax(-1).item()
|
76 |
+
print(model.config.id2label[predicted_label])
|
77 |
+
|
78 |
+
```
|
79 |
+
|
80 |
+
## Citation [optional]
|
81 |
+
|
82 |
+
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
83 |
+
|
84 |
+
**BibTeX:**
|
85 |
+
|
86 |
+
[More Information Needed]
|
87 |
+
|
88 |
+
**APA:**
|
89 |
+
|
90 |
+
[More Information Needed]
|
91 |
+
|
92 |
+
|
93 |
+
## Model Card Contact
|
94 |
+
|
95 |
config.json
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "pamixsun/swinv2_tiny_for_glaucoma_classification",
|
3 |
+
"architectures": [
|
4 |
+
"Swinv2ForImageClassification"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.0,
|
7 |
+
"depths": [
|
8 |
+
2,
|
9 |
+
2,
|
10 |
+
6,
|
11 |
+
2
|
12 |
+
],
|
13 |
+
"drop_path_rate": 0.1,
|
14 |
+
"embed_dim": 96,
|
15 |
+
"encoder_stride": 32,
|
16 |
+
"hidden_act": "gelu",
|
17 |
+
"hidden_dropout_prob": 0.0,
|
18 |
+
"hidden_size": 768,
|
19 |
+
"id2label": {
|
20 |
+
"0": "Non-glaucoma",
|
21 |
+
"1": "Glaucoma"
|
22 |
+
},
|
23 |
+
"image_size": 512,
|
24 |
+
"initializer_range": 0.02,
|
25 |
+
"label2id": {
|
26 |
+
"Glaucoma": "1",
|
27 |
+
"Non-glaucoma": "0"
|
28 |
+
},
|
29 |
+
"layer_norm_eps": 1e-05,
|
30 |
+
"mlp_ratio": 4.0,
|
31 |
+
"model_type": "swinv2",
|
32 |
+
"num_channels": 3,
|
33 |
+
"num_heads": [
|
34 |
+
3,
|
35 |
+
6,
|
36 |
+
12,
|
37 |
+
24
|
38 |
+
],
|
39 |
+
"num_layers": 4,
|
40 |
+
"patch_size": 4,
|
41 |
+
"path_norm": true,
|
42 |
+
"pretrained_window_sizes": [
|
43 |
+
0,
|
44 |
+
0,
|
45 |
+
0,
|
46 |
+
0
|
47 |
+
],
|
48 |
+
"problem_type": "single_label_classification",
|
49 |
+
"qkv_bias": true,
|
50 |
+
"torch_dtype": "float32",
|
51 |
+
"transformers_version": "4.28.0",
|
52 |
+
"use_absolute_embeddings": false,
|
53 |
+
"window_size": 8
|
54 |
+
}
|
example.jpg
ADDED
![]() |
preprocessor_config.json
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"do_normalize": true,
|
3 |
+
"do_rescale": true,
|
4 |
+
"do_resize": true,
|
5 |
+
"image_mean": [
|
6 |
+
0.485,
|
7 |
+
0.456,
|
8 |
+
0.406
|
9 |
+
],
|
10 |
+
"image_processor_type": "ViTImageProcessor",
|
11 |
+
"image_std": [
|
12 |
+
0.229,
|
13 |
+
0.224,
|
14 |
+
0.225
|
15 |
+
],
|
16 |
+
"resample": 3,
|
17 |
+
"rescale_factor": 0.00392156862745098,
|
18 |
+
"size": {
|
19 |
+
"height": 512,
|
20 |
+
"width": 512
|
21 |
+
}
|
22 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:95cfbbc74cee50346361f456d2a43293ac15c91d575e53999ba268659ab271ea
|
3 |
+
size 110405153
|