Decoder24 commited on
Commit
c1039f0
·
verified ·
1 Parent(s): a080b32

Upload folder using huggingface_hub

Browse files
.history/.streamlit/config_20251011123620.toml ADDED
File without changes
.history/.streamlit/config_20251011123628.toml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ [server]
2
+ headless = true
3
+ enableCORS = false
4
+ port = 8501
.history/main/app_20251011123647.py ADDED
File without changes
.history/main/app_20251011123657.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ os.makedirs(os.path.expanduser("~/.streamlit"), exist_ok=True)
3
+
4
+ import streamlit as st
5
+ from transformers import ViTFeatureExtractor, ViTForImageClassification
6
+ from PIL import Image
7
+ import torch
8
+
9
+ st.set_page_config(page_title="Cataract Detection with ViT", layout="wide")
10
+ st.title("👁️ Cataract Detection using Vision Transformer (ViT)")
11
+
12
+ uploaded_file = st.file_uploader("Upload an eye image (JPG/PNG)", type=["jpg", "jpeg", "png"])
13
+ if uploaded_file:
14
+ image = Image.open(uploaded_file).convert("RGB")
15
+ st.image(image, caption="Uploaded Image", use_column_width=True)
16
+
17
+ model_name = "Decoder24/Cataract-ViT"
18
+ model = ViTForImageClassification.from_pretrained(model_name)
19
+ extractor = ViTFeatureExtractor.from_pretrained(model_name)
20
+
21
+ inputs = extractor(images=image, return_tensors="pt")
22
+ outputs = model(**inputs)
23
+ preds = outputs.logits.softmax(dim=-1)
24
+ label = preds.argmax(dim=-1).item()
25
+
26
+ st.success(f"Predicted class: {model.config.id2label[label]}")
.history/requirements_20251011123708.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ torch
2
+ torchvision
3
+ torchaudio
4
+ timm
5
+ scikit-learn
6
+ opencv-python
7
+ matplotlib
8
+ seaborn
9
+ albumentations
10
+ wandb
11
+ streamlit
.history/requirements_20251011123712.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ torch
2
+ torchvision
3
+ torchaudio
4
+ timm
5
+ scikit-learn
6
+ opencv-python
7
+ matplotlib
8
+ seaborn
9
+ albumentations
10
+ wandb
11
+ streamlit
.history/requirements_20251011123720.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ torch
2
+ torchvision
3
+ torchaudio
4
+ timm
5
+ scikit-learn
6
+ opencv-python
7
+ matplotlib
8
+ seaborn
9
+ albumentations
10
+ wandb
11
+ streamlit
12
+ transformers
.history/requirements_20251011123723.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ torch
2
+ torchvision
3
+ torchaudio
4
+ timm
5
+ scikit-learn
6
+ opencv-python
7
+ matplotlib
8
+ seaborn
9
+ albumentations
10
+ wandb
11
+ streamlit
12
+ transformers
13
+ pillow
.streamlit/config.toml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ [server]
2
+ headless = true
3
+ enableCORS = false
4
+ port = 8501
main/app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ os.makedirs(os.path.expanduser("~/.streamlit"), exist_ok=True)
3
+
4
+ import streamlit as st
5
+ from transformers import ViTFeatureExtractor, ViTForImageClassification
6
+ from PIL import Image
7
+ import torch
8
+
9
+ st.set_page_config(page_title="Cataract Detection with ViT", layout="wide")
10
+ st.title("👁️ Cataract Detection using Vision Transformer (ViT)")
11
+
12
+ uploaded_file = st.file_uploader("Upload an eye image (JPG/PNG)", type=["jpg", "jpeg", "png"])
13
+ if uploaded_file:
14
+ image = Image.open(uploaded_file).convert("RGB")
15
+ st.image(image, caption="Uploaded Image", use_column_width=True)
16
+
17
+ model_name = "Decoder24/Cataract-ViT"
18
+ model = ViTForImageClassification.from_pretrained(model_name)
19
+ extractor = ViTFeatureExtractor.from_pretrained(model_name)
20
+
21
+ inputs = extractor(images=image, return_tensors="pt")
22
+ outputs = model(**inputs)
23
+ preds = outputs.logits.softmax(dim=-1)
24
+ label = preds.argmax(dim=-1).item()
25
+
26
+ st.success(f"Predicted class: {model.config.id2label[label]}")
requirements.txt CHANGED
@@ -8,3 +8,6 @@ matplotlib
8
  seaborn
9
  albumentations
10
  wandb
 
 
 
 
8
  seaborn
9
  albumentations
10
  wandb
11
+ streamlit
12
+ transformers
13
+ pillow