Spaces:
Sleeping
Sleeping
fixed path to work in huggingface
Browse files- pages/Dataset.py +2 -2
- pages/Model_Evaluation.py +2 -2
- pages/Upload_and_Predict.py +2 -2
pages/Dataset.py
CHANGED
@@ -44,8 +44,8 @@ with tab2:
|
|
44 |
st.markdown("### 📊 Training Data Class Distribution")
|
45 |
|
46 |
# CSV path and image folder path (adjust as needed)
|
47 |
-
CSV_PATH =
|
48 |
-
IMG_FOLDER =
|
49 |
|
50 |
# Load CSV
|
51 |
df = pd.read_csv(CSV_PATH)
|
|
|
44 |
st.markdown("### 📊 Training Data Class Distribution")
|
45 |
|
46 |
# CSV path and image folder path (adjust as needed)
|
47 |
+
CSV_PATH = "./dataset/DR_grading.csv"
|
48 |
+
IMG_FOLDER = "./dataset/images" # Folder where all images are stored
|
49 |
|
50 |
# Load CSV
|
51 |
df = pd.read_csv(CSV_PATH)
|
pages/Model_Evaluation.py
CHANGED
@@ -105,12 +105,12 @@ def load_test_data(csv_path):
|
|
105 |
def load_model():
|
106 |
model = models.densenet121(pretrained=False)
|
107 |
model.classifier = nn.Linear(model.classifier.in_features, len(class_names))
|
108 |
-
model.load_state_dict(torch.load(
|
109 |
model.eval()
|
110 |
return model
|
111 |
|
112 |
# ---- Main UI Buttons ----
|
113 |
-
csv_path =
|
114 |
model = load_model()
|
115 |
test_loader = load_test_data(csv_path)
|
116 |
|
|
|
105 |
def load_model():
|
106 |
model = models.densenet121(pretrained=False)
|
107 |
model.classifier = nn.Linear(model.classifier.in_features, len(class_names))
|
108 |
+
model.load_state_dict(torch.load("./Model/Pretrained_Densenet-121.pth", map_location=torch.device('cpu')))
|
109 |
model.eval()
|
110 |
return model
|
111 |
|
112 |
# ---- Main UI Buttons ----
|
113 |
+
csv_path = "./splits/test_labels.csv"
|
114 |
model = load_model()
|
115 |
test_loader = load_test_data(csv_path)
|
116 |
|
pages/Upload_and_Predict.py
CHANGED
@@ -57,7 +57,7 @@ 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(csv_path=
|
61 |
df = pd.read_csv(csv_path)
|
62 |
samples = defaultdict(list)
|
63 |
|
@@ -76,7 +76,7 @@ def load_sample_images_from_csv(csv_path=r'D:\DR_Classification\splits\test_labe
|
|
76 |
def load_model():
|
77 |
model = models.densenet121(pretrained=False)
|
78 |
model.classifier = torch.nn.Linear(model.classifier.in_features, len(class_names))
|
79 |
-
model.load_state_dict(torch.load("Model/Pretrained_Densenet-121.pth", map_location='cpu'))
|
80 |
model.eval()
|
81 |
return model
|
82 |
|
|
|
57 |
|
58 |
# Load sample images from CSV with proper label mapping
|
59 |
@st.cache_data
|
60 |
+
def load_sample_images_from_csv(csv_path='./splits/test_labels.csv'):
|
61 |
df = pd.read_csv(csv_path)
|
62 |
samples = defaultdict(list)
|
63 |
|
|
|
76 |
def load_model():
|
77 |
model = models.densenet121(pretrained=False)
|
78 |
model.classifier = torch.nn.Linear(model.classifier.in_features, len(class_names))
|
79 |
+
model.load_state_dict(torch.load("./Model/Pretrained_Densenet-121.pth", map_location='cpu'))
|
80 |
model.eval()
|
81 |
return model
|
82 |
|