File size: 2,259 Bytes
876379a 163457f 6b822d1 163457f 7199eee 876379a 4bf53ba 876379a 61fe5d4 d74eba5 f3a53d5 092b5ac f3a53d5 1efa64f 7199eee 1efa64f 61fe5d4 6b822d1 e38f17b d3b4693 e38f17b 4ee9cef f5afa94 4ee9cef |
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 |
---
tags:
- image-classification
- pytorch
- medical
- colon
metrics:
- accuracy: 0.93
---
# Vision Transformer fine-tuned on kvasir_v2 for colonoscopy classification
## Demo
### Drag the following images to the widget to test the model
- ![](https://i.imgur.com/2ykziCJ_d.webp?maxwidth=224&fidelity=grand)
- ![](https://i.imgur.com/NfWPHkj_d.webp?maxwidth=224&fidelity=grand)
- ![](https://i.imgur.com/C3RexVQ_d.webp?maxwidth=224&fidelity=grand)
- ![](https://i.imgur.com/qcCYpN9_d.webp?maxwidth=224&fidelity=grand)
## Training
You can find the code [here](https://github.com/qanastek/HugsVision/blob/main/recipes/kvasir_v2/binary_classification/Kvasir_v2_Image_Classifier.ipynb)
## Metrics
```
precision recall f1-score support
dyed-lifted-polyps 0.95 0.93 0.94 60
dyed-resection-margins 0.97 0.95 0.96 64
esophagitis 0.93 0.79 0.85 67
normal-cecum 1.00 0.98 0.99 54
normal-pylorus 0.95 1.00 0.97 57
normal-z-line 0.82 0.93 0.87 67
polyps 0.92 0.92 0.92 52
ulcerative-colitis 0.93 0.95 0.94 59
accuracy 0.93 480
macro avg 0.93 0.93 0.93 480
weighted avg 0.93 0.93 0.93 480
```
## How to use
```py
from transformers import ViTFeatureExtractor, ViTForImageClassification
from hugsvision.inference.VisionClassifierInference import VisionClassifierInference
path = "mrm8488/vit-base-patch16-224_finetuned-kvasirv2-colonoscopy"
classifier = VisionClassifierInference(
feature_extractor = ViTFeatureExtractor.from_pretrained(path),
model = ViTForImageClassification.from_pretrained(path),
)
img = "Your image path"
label = classifier.predict(img_path=img)
print("Predicted class:", label)
```
> Disclaimer: This model was trained for research only
> Created by [Manuel Romero/@mrm8488](https://twitter.com/mrm8488) | [LinkedIn](https://www.linkedin.com/in/manuel-romero-cs/)
> Made with <span style="color: #e25555;">♥</span> in Spain |