Spaces:
Sleeping
Sleeping
change path
Browse files- pages/Upload_and_Predict.py +8 -8
- requirements.txt +1 -0
pages/Upload_and_Predict.py
CHANGED
@@ -6,6 +6,7 @@ import numpy as np
|
|
6 |
import pandas as pd
|
7 |
from collections import defaultdict
|
8 |
import os
|
|
|
9 |
|
10 |
# Title
|
11 |
st.markdown("<h2 style='color: #2E86C1;'>📷 Upload & Predict</h2>", unsafe_allow_html=True)
|
@@ -55,20 +56,19 @@ The tool also shows **sample images from the test set** for each class. You can
|
|
55 |
# DR class names
|
56 |
class_names = ['No DR', 'Mild', 'Moderate', 'Severe', 'Proliferative DR']
|
57 |
|
58 |
-
# Load sample images from CSV with proper label mapping
|
59 |
@st.cache_data
|
60 |
-
def load_sample_images_from_csv(
|
61 |
-
|
62 |
samples = defaultdict(list)
|
63 |
|
64 |
for i in range(5):
|
65 |
class_name = class_names[i]
|
66 |
-
class_samples =
|
67 |
-
for
|
68 |
-
img_path =
|
69 |
-
if os.path.exists(img_path):
|
70 |
samples[class_name].append(img_path)
|
71 |
-
|
72 |
return samples
|
73 |
|
74 |
# Load pretrained model
|
|
|
6 |
import pandas as pd
|
7 |
from collections import defaultdict
|
8 |
import os
|
9 |
+
from datasets import load_dataset
|
10 |
|
11 |
# Title
|
12 |
st.markdown("<h2 style='color: #2E86C1;'>📷 Upload & Predict</h2>", unsafe_allow_html=True)
|
|
|
56 |
# DR class names
|
57 |
class_names = ['No DR', 'Mild', 'Moderate', 'Severe', 'Proliferative DR']
|
58 |
|
|
|
59 |
@st.cache_data
|
60 |
+
def load_sample_images_from_csv():
|
61 |
+
dataset = load_dataset("Ci-Dave/test_labels.csv", split="test")
|
62 |
samples = defaultdict(list)
|
63 |
|
64 |
for i in range(5):
|
65 |
class_name = class_names[i]
|
66 |
+
class_samples = dataset.filter(lambda example: example['label'] == i)[:5]
|
67 |
+
for example in class_samples:
|
68 |
+
img_path = example['new_path'] # Ensure this column exists or adjust accordingly
|
69 |
+
if os.path.exists(img_path): # Optional: skip if not local
|
70 |
samples[class_name].append(img_path)
|
71 |
+
|
72 |
return samples
|
73 |
|
74 |
# Load pretrained model
|
requirements.txt
CHANGED
@@ -9,3 +9,4 @@ torch
|
|
9 |
torchvision
|
10 |
scikit-learn
|
11 |
fpdf
|
|
|
|
9 |
torchvision
|
10 |
scikit-learn
|
11 |
fpdf
|
12 |
+
datasets
|