Spaces:
Sleeping
Sleeping
AdityaAdaki
commited on
Commit
Β·
ee13964
1
Parent(s):
a4e5d97
Added Streamlit app for infrastructure grading and verification
Browse files- app2.py +558 -0
- requirements.txt +6 -0
app2.py
ADDED
|
@@ -0,0 +1,558 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import cv2
|
| 3 |
+
import numpy as np
|
| 4 |
+
from PIL import Image
|
| 5 |
+
from io import BytesIO
|
| 6 |
+
from cvzone.ClassificationModule import Classifier
|
| 7 |
+
import pandas as pd
|
| 8 |
+
|
| 9 |
+
# Set page configuration
|
| 10 |
+
st.set_page_config(page_title="Infrastructure Grading & Facility Verification", page_icon="π", layout="wide")
|
| 11 |
+
|
| 12 |
+
# Initialize session state variables if they don't exist
|
| 13 |
+
if 'total_score' not in st.session_state:
|
| 14 |
+
st.session_state.total_score = 0
|
| 15 |
+
if 'facility_results' not in st.session_state:
|
| 16 |
+
st.session_state.facility_results = []
|
| 17 |
+
if 'deficiencies' not in st.session_state:
|
| 18 |
+
st.session_state.deficiencies = []
|
| 19 |
+
if 'verified_facilities' not in st.session_state:
|
| 20 |
+
st.session_state.verified_facilities = set()
|
| 21 |
+
if 'facility_status' not in st.session_state:
|
| 22 |
+
st.session_state.facility_status = {}
|
| 23 |
+
|
| 24 |
+
# Streamlit app title with subheader
|
| 25 |
+
st.title("π Infrastructure Grading & Facility Verification System")
|
| 26 |
+
|
| 27 |
+
# Create tabs
|
| 28 |
+
tab1, tab2, tab3, tab4 = st.tabs(["π College Info", "π’ Facility Verification", "π Results", "β Help"])
|
| 29 |
+
|
| 30 |
+
# Define models dictionary
|
| 31 |
+
models = {
|
| 32 |
+
"Restroom Model": ('Models/Restroom model/keras_model.h5',
|
| 33 |
+
'Models/Restroom model/labels.txt'),
|
| 34 |
+
"Dispenser Model": ('Models/Dispenser model/keras_model.h5',
|
| 35 |
+
'Models/Dispenser model/labels.txt'),
|
| 36 |
+
"Safety Equipment Model": ('Models/safety equipment model/keras_model.h5',
|
| 37 |
+
'Models/safety equipment model/labels.txt'),
|
| 38 |
+
"Computer Lab Model": ('Models/computer lab model/keras_model.h5',
|
| 39 |
+
'Models/computer lab model/labels.txt'),
|
| 40 |
+
"Server Room Model": ('Models/Server Room model/keras_model.h5',
|
| 41 |
+
'Models/Server Room model/labels.txt'),
|
| 42 |
+
"Lab Equipment Model": ('Models/lab equipment model/keras_model.h5',
|
| 43 |
+
'Models/lab equipment model/labels.txt'),
|
| 44 |
+
"Sports Equipment Model": ('Models/sports equipment model/keras_model.h5',
|
| 45 |
+
'Models/sports equipment model/labels.txt'),
|
| 46 |
+
"Bicycle Stand Model": ('Models/bicycle stand model/keras_model.h5',
|
| 47 |
+
'Models/bicycle stand model/labels.txt'),
|
| 48 |
+
"Medical Room Model": ('Models/Medical Room Model/keras_model.h5',
|
| 49 |
+
'Models/Medical Room Model/labels.txt'),
|
| 50 |
+
"Workshop/Mechanical Lab Model": ('Models/workshop model/keras_model.h5',
|
| 51 |
+
'Models/workshop model/labels.txt'),
|
| 52 |
+
"Bus/Transport Model": ('Models/bus transport model/keras_model.h5',
|
| 53 |
+
'Models/bus transport model/labels.txt'),
|
| 54 |
+
"COVID-19 Protocol Model": ('Models/COVID-19 protocol model/keras_model.h5',
|
| 55 |
+
'Models/COVID-19 protocol model/labels.txt'),
|
| 56 |
+
"Canteen Model": ('Models/canteen model/keras_model.h5',
|
| 57 |
+
'Models/canteen model/labels.txt'),
|
| 58 |
+
"CCTV Model": ('Models/CCTV model/keras_model.h5',
|
| 59 |
+
'Models/CCTV model/labels.txt'),
|
| 60 |
+
"Classroom Model": ('Models/classroom model/keras_model.h5',
|
| 61 |
+
'Models/classroom model/labels.txt'),
|
| 62 |
+
"Elearning Model": ('Models/elearning model/keras_model.h5',
|
| 63 |
+
'Models/elearning model/labels.txt'),
|
| 64 |
+
"Faculty Cabin Model": ('Models/faculty cabin model/keras_model.h5',
|
| 65 |
+
'Models/faculty cabin model/labels.txt'),
|
| 66 |
+
"Fire Extinguisher Model": ('Models/fire extinguisher model/keras_model.h5',
|
| 67 |
+
'Models/fire extinguisher model/labels.txt'),
|
| 68 |
+
"Generator Model": ('Models/generator model/keras_model.h5',
|
| 69 |
+
'Models/generator model/labels.txt'),
|
| 70 |
+
"Ground Model": ('Models/ground model (1)/keras_model.h5',
|
| 71 |
+
'Models/ground model (1)/labels.txt'),
|
| 72 |
+
"Laptop Model": ('Models/laptop model/keras_model.h5',
|
| 73 |
+
'Models/laptop model/labels.txt'),
|
| 74 |
+
"Library Model": ('Models/library model/keras_model.h5',
|
| 75 |
+
'Models/library model/labels.txt'),
|
| 76 |
+
"Parking Model": ('Models/parking model/keras_model.h5',
|
| 77 |
+
'Models/parking model/labels.txt'),
|
| 78 |
+
"Pothole Model": ('Models/pothole model/keras_model.h5',
|
| 79 |
+
'Models/pothole model/labels.txt'),
|
| 80 |
+
"Seminar Hall Model": ('Models/seminar hall model/keras_model.h5',
|
| 81 |
+
'Models/seminar hall model/labels.txt'),
|
| 82 |
+
"TPO Model": ('Models/tpo model/keras_model.h5',
|
| 83 |
+
'Models/tpo model/labels.txt'),
|
| 84 |
+
"Audi Model": ('Models/Audi model/keras_model.h5',
|
| 85 |
+
'Models/Audi model/labels.txt'),
|
| 86 |
+
"Conference Halls Model": ('Models/conference halls model/keras_model.h5',
|
| 87 |
+
'Models/conference halls model/labels.txt'),
|
| 88 |
+
"Drawing Halls Model": ('Models/Drawing halls model/keras_model.h5',
|
| 89 |
+
'Models/Drawing halls model/labels.txt'),
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
# Function to handle input and image upload
|
| 93 |
+
def input_and_upload(label, min_value, default_value, model_name, model_path, labels_path):
|
| 94 |
+
col1, col2 = st.columns(2)
|
| 95 |
+
with col1:
|
| 96 |
+
if isinstance(default_value, int):
|
| 97 |
+
user_value = st.number_input(f"Number of {label}", min_value=min_value, value=int(default_value), step=1)
|
| 98 |
+
else:
|
| 99 |
+
user_value = st.number_input(f"Number of {label}", min_value=float(min_value), value=float(default_value), step=0.1)
|
| 100 |
+
with col2:
|
| 101 |
+
uploaded_files = st.file_uploader(f"Upload images for {label} (max {int(user_value)})",
|
| 102 |
+
type=["jpg", "jpeg", "png"],
|
| 103 |
+
accept_multiple_files=True)
|
| 104 |
+
|
| 105 |
+
# Limit the number of processed files to user_value
|
| 106 |
+
uploaded_files = uploaded_files[:int(user_value)] if uploaded_files else []
|
| 107 |
+
|
| 108 |
+
score = 0
|
| 109 |
+
if uploaded_files:
|
| 110 |
+
score = classify_image(model_path, labels_path, uploaded_files, model_name)
|
| 111 |
+
|
| 112 |
+
# Update the facility status immediately after classification
|
| 113 |
+
if label not in st.session_state.verified_facilities and score > 0:
|
| 114 |
+
st.session_state.verified_facilities.add(label)
|
| 115 |
+
st.session_state.total_score = sum(
|
| 116 |
+
data["Score"]
|
| 117 |
+
for data in st.session_state.facility_status.values()
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
return user_value, score
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
# Function to classify image
|
| 124 |
+
def classify_image(model_path, labels_path, uploaded_files, model_name):
|
| 125 |
+
try:
|
| 126 |
+
classifier = Classifier(model_path, labels_path)
|
| 127 |
+
class_names = open(labels_path).read().splitlines()
|
| 128 |
+
except FileNotFoundError:
|
| 129 |
+
st.error(f"Model files for {model_name} not found. Please check the model path.")
|
| 130 |
+
return 0
|
| 131 |
+
except Exception as e:
|
| 132 |
+
st.error(f"Error loading model {model_name}: {str(e)}")
|
| 133 |
+
return 0
|
| 134 |
+
|
| 135 |
+
score = 0
|
| 136 |
+
|
| 137 |
+
# Create a grid layout for images
|
| 138 |
+
cols = st.columns(3) # Adjust the number of columns as needed
|
| 139 |
+
|
| 140 |
+
for idx, uploaded_file in enumerate(uploaded_files):
|
| 141 |
+
try:
|
| 142 |
+
img = Image.open(BytesIO(uploaded_file.read()))
|
| 143 |
+
img_array = np.array(img)
|
| 144 |
+
|
| 145 |
+
# Convert to BGR if the image is RGB
|
| 146 |
+
if img_array.shape[-1] == 3:
|
| 147 |
+
img_array = cv2.cvtColor(img_array, cv2.COLOR_RGB2BGR)
|
| 148 |
+
|
| 149 |
+
# Resize for prediction (but don't display this resized version)
|
| 150 |
+
img_resized = cv2.resize(img_array, (224, 224))
|
| 151 |
+
|
| 152 |
+
prediction = classifier.getPrediction(img_resized)
|
| 153 |
+
class_id = prediction[1]
|
| 154 |
+
class_name = class_names[class_id] if class_id < len(class_names) else "Unknown"
|
| 155 |
+
|
| 156 |
+
# Display image and results in a compact format
|
| 157 |
+
with cols[idx % 3]:
|
| 158 |
+
st.image(img, use_column_width=True)
|
| 159 |
+
if "no" in class_name.lower() or "not" in class_name.lower():
|
| 160 |
+
st.warning(f"{model_name} not verified.")
|
| 161 |
+
else:
|
| 162 |
+
st.success(f"{model_name} is verified.")
|
| 163 |
+
score += 10
|
| 164 |
+
|
| 165 |
+
except Exception as e:
|
| 166 |
+
st.error(f"An error occurred: {e}")
|
| 167 |
+
|
| 168 |
+
return score
|
| 169 |
+
|
| 170 |
+
# Grade calculation function
|
| 171 |
+
def calculate_grade(total_score, max_score):
|
| 172 |
+
percentage = (total_score / max_score) * 100
|
| 173 |
+
if percentage >= 80:
|
| 174 |
+
return "A"
|
| 175 |
+
elif percentage >= 60:
|
| 176 |
+
return "B"
|
| 177 |
+
elif percentage >= 40:
|
| 178 |
+
return "C"
|
| 179 |
+
else:
|
| 180 |
+
return "D"
|
| 181 |
+
|
| 182 |
+
with tab1:
|
| 183 |
+
st.markdown("### College Information")
|
| 184 |
+
st.markdown("Enter the basic information about the college below:")
|
| 185 |
+
|
| 186 |
+
# Create columns for a more compact layout
|
| 187 |
+
col1, col2 = st.columns(2)
|
| 188 |
+
|
| 189 |
+
with col1:
|
| 190 |
+
num_divisions = st.number_input("Number of Divisions", min_value=1, value=1, help="Total number of divisions across all years")
|
| 191 |
+
num_courses = st.number_input("Number of Courses", min_value=1, value=1, help="Total number of distinct courses offered")
|
| 192 |
+
|
| 193 |
+
with col2:
|
| 194 |
+
num_students = st.number_input("Total Students", min_value=1, value=100, help="Total number of students enrolled")
|
| 195 |
+
course_duration = st.number_input("Course Duration (years)", min_value=1, value=4, help="Average duration of courses in years")
|
| 196 |
+
|
| 197 |
+
# Calculations
|
| 198 |
+
classroom_requirement = num_divisions * course_duration * 0.5
|
| 199 |
+
|
| 200 |
+
# Lab logic based on student intake
|
| 201 |
+
if num_students <= 600:
|
| 202 |
+
first_year_labs = 4
|
| 203 |
+
else:
|
| 204 |
+
first_year_labs = 4 + (num_students - 600) // 150
|
| 205 |
+
|
| 206 |
+
if num_students <= 180 * num_courses:
|
| 207 |
+
labs_other_years = 2 * num_courses * (course_duration - 1)
|
| 208 |
+
else:
|
| 209 |
+
extra_students_per_course = (num_students - 180 * num_courses) // 50
|
| 210 |
+
labs_other_years = 2 * num_courses * (course_duration - 1) + extra_students_per_course
|
| 211 |
+
|
| 212 |
+
total_labs = first_year_labs + labs_other_years
|
| 213 |
+
|
| 214 |
+
# Other facility requirements
|
| 215 |
+
workshop_requirement = 1 + (num_students - 600) // 600 if num_students > 600 else 1
|
| 216 |
+
cad_centre_requirement = 1 + (num_students - 600) // 600 if num_students > 600 else 1
|
| 217 |
+
computer_centre_requirement = 1 + (num_students - 600) // 600 if num_students > 600 else 1
|
| 218 |
+
seminar_hall_requirement = 1
|
| 219 |
+
library_requirement = 1
|
| 220 |
+
language_lab_requirement = 1
|
| 221 |
+
pc_requirement = max(20, num_students // 10)
|
| 222 |
+
|
| 223 |
+
st.markdown("### π Calculated Facility Requirements")
|
| 224 |
+
|
| 225 |
+
# Create three columns for a more compact display of requirements
|
| 226 |
+
col1, col2, col3 = st.columns(3)
|
| 227 |
+
|
| 228 |
+
with col1:
|
| 229 |
+
st.metric("Classrooms", f"{classroom_requirement:.1f}")
|
| 230 |
+
st.metric("Total Labs", f"{total_labs}")
|
| 231 |
+
st.metric("Workshops", f"{workshop_requirement}")
|
| 232 |
+
|
| 233 |
+
with col2:
|
| 234 |
+
st.metric("CAD Centres", f"{cad_centre_requirement}")
|
| 235 |
+
st.metric("Computer Centres", f"{computer_centre_requirement}")
|
| 236 |
+
st.metric("Seminar Halls", f"{seminar_hall_requirement}")
|
| 237 |
+
|
| 238 |
+
with col3:
|
| 239 |
+
st.metric("Libraries", f"{library_requirement}")
|
| 240 |
+
st.metric("Language Labs", f"{language_lab_requirement}")
|
| 241 |
+
st.metric("PC/Laptops", f"{pc_requirement}")
|
| 242 |
+
|
| 243 |
+
st.info("βΉ These calculations are based on standard educational infrastructure guidelines.")
|
| 244 |
+
|
| 245 |
+
# Input fields and image upload for each facility
|
| 246 |
+
facilities = [
|
| 247 |
+
("Classrooms", classroom_requirement, "Classroom Model"),
|
| 248 |
+
("Computer Labs", computer_centre_requirement, "Computer Lab Model"), #Done
|
| 249 |
+
("Workshops", workshop_requirement, "Workshop/Mechanical Lab Model"), # Done
|
| 250 |
+
("Drawing Halls", cad_centre_requirement, "Drawing Halls Model"), # Done
|
| 251 |
+
("Seminar Halls", seminar_hall_requirement, "Seminar Hall Model"), # Done
|
| 252 |
+
("Conference Halls", 1, "Conference Halls Model"), # done
|
| 253 |
+
("Auditorium", 1, "Audi Model"),
|
| 254 |
+
("Faculty Cabins", 1, "Faculty Cabin Model"),
|
| 255 |
+
("Security/CCTV", 1, "CCTV Model"),
|
| 256 |
+
("House Keeping", 1, "Safety Equipment Model"), # to be done / store rooms can be done but not added yet
|
| 257 |
+
("Restrooms", 1, "Restroom Model"), # Done
|
| 258 |
+
("Canteens", 1, "Canteen Model"),
|
| 259 |
+
("Server Room", 1, "Server Room Model"), # Done
|
| 260 |
+
("First Aid/Medical Room", 1, "Medical Room Model"), # done
|
| 261 |
+
("Gym/Sports Facilities", 1, "Sports Equipment Model"), # done
|
| 262 |
+
("Language Labs", language_lab_requirement, "Computer Lab Model"), #done
|
| 263 |
+
("Water Coolers/Dispensers", 1, "Dispenser Model"), # done
|
| 264 |
+
("Generators", 1, "Generator Model"),
|
| 265 |
+
("TPO Office", 1, "TPO Model"),
|
| 266 |
+
# Other supporting facilities
|
| 267 |
+
("Libraries", library_requirement, "Library Model"),
|
| 268 |
+
("PCs/Laptops", pc_requirement, "Laptop Model"),
|
| 269 |
+
("Bicycle Stands", 1, "Bicycle Stand Model"),
|
| 270 |
+
("Bus/Transport Facilities", 1, "Bus/Transport Model"),
|
| 271 |
+
("COVID-19 Protocol Measures", 1, "COVID-19 Protocol Model"),
|
| 272 |
+
("E-learning Facilities", 1, "Elearning Model"),
|
| 273 |
+
("Fire Extinguishers", 1, "Fire Extinguisher Model"),
|
| 274 |
+
("Grounds/Playgrounds", 1, "Ground Model"),
|
| 275 |
+
("Parking Areas", 1, "Parking Model"),
|
| 276 |
+
("Road Condition (Potholes)", 1, "Pothole Model"),
|
| 277 |
+
]
|
| 278 |
+
|
| 279 |
+
with tab2:
|
| 280 |
+
st.markdown("### Facility Verification")
|
| 281 |
+
st.markdown("Upload images for each facility to verify their existence and compliance.")
|
| 282 |
+
|
| 283 |
+
# Reset scores and results when starting verification
|
| 284 |
+
if st.button("π Reset Verification"):
|
| 285 |
+
# Reset all session state variables
|
| 286 |
+
st.session_state.total_score = 0
|
| 287 |
+
st.session_state.facility_results = []
|
| 288 |
+
st.session_state.deficiencies = []
|
| 289 |
+
st.session_state.verified_facilities = set()
|
| 290 |
+
st.session_state.facility_status = {}
|
| 291 |
+
# Add a rerun to refresh the page
|
| 292 |
+
st.rerun()
|
| 293 |
+
|
| 294 |
+
# Create subtabs for different facility categories
|
| 295 |
+
facility_tabs = st.tabs(["π« Academic", "π¬ Labs & Workshops", "π Support Facilities", "π₯ Essential Services"])
|
| 296 |
+
|
| 297 |
+
# Define facility categories
|
| 298 |
+
academic_facilities = [
|
| 299 |
+
f for f in facilities
|
| 300 |
+
if any(name in f[0] for name in ["Classroom", "Faculty", "Drawing", "Seminar", "Conference", "Auditorium"])
|
| 301 |
+
]
|
| 302 |
+
|
| 303 |
+
lab_facilities = [
|
| 304 |
+
f for f in facilities
|
| 305 |
+
if any(name in f[0] for name in ["Computer Lab", "Workshop", "Language Lab", "Server"])
|
| 306 |
+
]
|
| 307 |
+
|
| 308 |
+
support_facilities = [
|
| 309 |
+
f for f in facilities
|
| 310 |
+
if any(name in f[0] for name in ["Library", "TPO", "E-learning", "Sport", "Ground"])
|
| 311 |
+
]
|
| 312 |
+
|
| 313 |
+
essential_facilities = [
|
| 314 |
+
f for f in facilities
|
| 315 |
+
if any(name in f[0] for name in ["Restroom", "Security", "CCTV", "Medical", "Water", "Fire", "Generator"])
|
| 316 |
+
]
|
| 317 |
+
|
| 318 |
+
# Process facilities in each tab
|
| 319 |
+
with facility_tabs[0]: # Academic Facilities
|
| 320 |
+
for facility, requirement, model_name in academic_facilities:
|
| 321 |
+
st.markdown(f"#### {facility}")
|
| 322 |
+
user_value, score = input_and_upload(facility, 0, requirement, model_name, *models[model_name])
|
| 323 |
+
|
| 324 |
+
# Update facility status
|
| 325 |
+
st.session_state.facility_status[facility] = {
|
| 326 |
+
"Verified": int(user_value),
|
| 327 |
+
"Required": int(requirement),
|
| 328 |
+
"Score": score,
|
| 329 |
+
"Status": "β
Met" if user_value >= requirement and score > 0 else "β Not Met"
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
# Only add score if not already verified
|
| 333 |
+
if facility not in st.session_state.verified_facilities and score > 0:
|
| 334 |
+
st.session_state.total_score += score
|
| 335 |
+
st.session_state.verified_facilities.add(facility)
|
| 336 |
+
|
| 337 |
+
if user_value < requirement:
|
| 338 |
+
st.session_state.deficiencies.append(f"{facility} requires {int(requirement - user_value)} more.")
|
| 339 |
+
st.markdown("---")
|
| 340 |
+
|
| 341 |
+
with facility_tabs[1]: # Labs & Workshops
|
| 342 |
+
for facility, requirement, model_name in lab_facilities:
|
| 343 |
+
st.markdown(f"#### {facility}")
|
| 344 |
+
user_value, score = input_and_upload(facility, 0, requirement, model_name, *models[model_name])
|
| 345 |
+
|
| 346 |
+
# Update facility status
|
| 347 |
+
st.session_state.facility_status[facility] = {
|
| 348 |
+
"Verified": int(user_value),
|
| 349 |
+
"Required": int(requirement),
|
| 350 |
+
"Score": score,
|
| 351 |
+
"Status": "β
Met" if user_value >= requirement and score > 0 else "β Not Met"
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
# Only add score if not already verified
|
| 355 |
+
if facility not in st.session_state.verified_facilities and score > 0:
|
| 356 |
+
st.session_state.total_score += score
|
| 357 |
+
st.session_state.verified_facilities.add(facility)
|
| 358 |
+
|
| 359 |
+
if user_value < requirement:
|
| 360 |
+
st.session_state.deficiencies.append(f"{facility} requires {int(requirement - user_value)} more.")
|
| 361 |
+
st.markdown("---")
|
| 362 |
+
|
| 363 |
+
with facility_tabs[2]: # Support Facilities
|
| 364 |
+
for facility, requirement, model_name in support_facilities:
|
| 365 |
+
st.markdown(f"#### {facility}")
|
| 366 |
+
user_value, score = input_and_upload(facility, 0, requirement, model_name, *models[model_name])
|
| 367 |
+
|
| 368 |
+
# Update facility status
|
| 369 |
+
st.session_state.facility_status[facility] = {
|
| 370 |
+
"Verified": int(user_value),
|
| 371 |
+
"Required": int(requirement),
|
| 372 |
+
"Score": score,
|
| 373 |
+
"Status": "β
Met" if user_value >= requirement and score > 0 else "β Not Met"
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
# Only add score if not already verified
|
| 377 |
+
if facility not in st.session_state.verified_facilities and score > 0:
|
| 378 |
+
st.session_state.total_score += score
|
| 379 |
+
st.session_state.verified_facilities.add(facility)
|
| 380 |
+
|
| 381 |
+
if user_value < requirement:
|
| 382 |
+
st.session_state.deficiencies.append(f"{facility} requires {int(requirement - user_value)} more.")
|
| 383 |
+
st.markdown("---")
|
| 384 |
+
|
| 385 |
+
with facility_tabs[3]: # Essential Services
|
| 386 |
+
for facility, requirement, model_name in essential_facilities:
|
| 387 |
+
st.markdown(f"#### {facility}")
|
| 388 |
+
user_value, score = input_and_upload(facility, 0, requirement, model_name, *models[model_name])
|
| 389 |
+
|
| 390 |
+
# Update facility status
|
| 391 |
+
st.session_state.facility_status[facility] = {
|
| 392 |
+
"Verified": int(user_value),
|
| 393 |
+
"Required": int(requirement),
|
| 394 |
+
"Score": score,
|
| 395 |
+
"Status": "β
Met" if user_value >= requirement and score > 0 else "β Not Met"
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
# Only add score if not already verified
|
| 399 |
+
if facility not in st.session_state.verified_facilities and score > 0:
|
| 400 |
+
st.session_state.total_score += score
|
| 401 |
+
st.session_state.verified_facilities.add(facility)
|
| 402 |
+
|
| 403 |
+
if user_value < requirement:
|
| 404 |
+
st.session_state.deficiencies.append(f"{facility} requires {int(requirement - user_value)} more.")
|
| 405 |
+
st.markdown("---")
|
| 406 |
+
|
| 407 |
+
with tab3:
|
| 408 |
+
st.markdown("### π Results Summary")
|
| 409 |
+
|
| 410 |
+
# Calculate max possible score and verification progress
|
| 411 |
+
max_score = len(facilities) * 10
|
| 412 |
+
verified_count = len(st.session_state.verified_facilities)
|
| 413 |
+
verification_progress = (verified_count / len(facilities)) * 100
|
| 414 |
+
|
| 415 |
+
# Calculate grade based on total score
|
| 416 |
+
current_grade = calculate_grade(st.session_state.total_score, max_score)
|
| 417 |
+
|
| 418 |
+
# Create three columns for key metrics
|
| 419 |
+
col1, col2, col3 = st.columns(3)
|
| 420 |
+
|
| 421 |
+
with col1:
|
| 422 |
+
st.markdown("#### Grade")
|
| 423 |
+
st.markdown(f"<h2 style='text-align: center; color: {'green' if current_grade == 'A' else 'orange' if current_grade == 'B' else 'red'};'>{current_grade}</h2>", unsafe_allow_html=True)
|
| 424 |
+
|
| 425 |
+
with col2:
|
| 426 |
+
st.markdown("#### Score")
|
| 427 |
+
st.markdown(f"<h2 style='text-align: center;'>{st.session_state.total_score}/{max_score}</h2>", unsafe_allow_html=True)
|
| 428 |
+
st.progress(st.session_state.total_score / max_score)
|
| 429 |
+
|
| 430 |
+
with col3:
|
| 431 |
+
st.markdown("#### Verification Progress")
|
| 432 |
+
st.markdown(f"<h2 style='text-align: center;'>{verification_progress:.1f}%</h2>", unsafe_allow_html=True)
|
| 433 |
+
st.progress(verification_progress / 100)
|
| 434 |
+
|
| 435 |
+
# Display facility status metrics
|
| 436 |
+
if st.session_state.facility_status:
|
| 437 |
+
st.markdown("### π Facility Status Overview")
|
| 438 |
+
|
| 439 |
+
# Calculate metrics
|
| 440 |
+
total_facilities = len(st.session_state.facility_status)
|
| 441 |
+
compliant_facilities = sum(1 for data in st.session_state.facility_status.values() if data["Status"] == "β
Met")
|
| 442 |
+
non_compliant_facilities = total_facilities - compliant_facilities
|
| 443 |
+
|
| 444 |
+
# Display metrics in columns
|
| 445 |
+
metric_col1, metric_col2, metric_col3 = st.columns(3)
|
| 446 |
+
with metric_col1:
|
| 447 |
+
st.metric("Total Facilities", total_facilities)
|
| 448 |
+
with metric_col2:
|
| 449 |
+
st.metric("Compliant", compliant_facilities, delta=f"{(compliant_facilities/total_facilities)*100:.1f}%")
|
| 450 |
+
with metric_col3:
|
| 451 |
+
st.metric("Non-Compliant", non_compliant_facilities, delta=f"-{(non_compliant_facilities/total_facilities)*100:.1f}%")
|
| 452 |
+
|
| 453 |
+
# Create tabs for different views of the results
|
| 454 |
+
results_tab1, results_tab2 = st.tabs(["π Summary Table", "β οΈ Deficiencies"])
|
| 455 |
+
|
| 456 |
+
with results_tab1:
|
| 457 |
+
# Create DataFrame from facility_status
|
| 458 |
+
summary_data = [
|
| 459 |
+
{
|
| 460 |
+
"Facility": facility,
|
| 461 |
+
"Verified": data["Verified"],
|
| 462 |
+
"Required": data["Required"],
|
| 463 |
+
"Score": data["Score"],
|
| 464 |
+
"Status": data["Status"]
|
| 465 |
+
}
|
| 466 |
+
for facility, data in st.session_state.facility_status.items()
|
| 467 |
+
]
|
| 468 |
+
|
| 469 |
+
summary_df = pd.DataFrame(summary_data)
|
| 470 |
+
summary_df = summary_df[["Facility", "Verified", "Required", "Score", "Status"]]
|
| 471 |
+
|
| 472 |
+
# Add color coding to the dataframe
|
| 473 |
+
st.dataframe(
|
| 474 |
+
summary_df.style
|
| 475 |
+
.set_properties(**{
|
| 476 |
+
'background-color': 'white',
|
| 477 |
+
'color': 'black',
|
| 478 |
+
'border-color': 'lightgrey',
|
| 479 |
+
'text-align': 'center'
|
| 480 |
+
})
|
| 481 |
+
.apply(lambda x: ['background-color: #e6ffe6' if v == 'β
Met' else 'background-color: #ffe6e6' for v in x], subset=['Status'])
|
| 482 |
+
.format({'Score': '{:.0f}'})
|
| 483 |
+
)
|
| 484 |
+
|
| 485 |
+
with results_tab2:
|
| 486 |
+
# Display deficiencies with better formatting
|
| 487 |
+
current_deficiencies = [
|
| 488 |
+
(facility, data['Required'] - data['Verified'], data['Score'])
|
| 489 |
+
for facility, data in st.session_state.facility_status.items()
|
| 490 |
+
if data['Verified'] < data['Required'] or data['Score'] == 0
|
| 491 |
+
]
|
| 492 |
+
|
| 493 |
+
if current_deficiencies:
|
| 494 |
+
st.markdown("#### π¨ Areas Needing Improvement")
|
| 495 |
+
for facility, shortage, score in current_deficiencies:
|
| 496 |
+
if score == 0:
|
| 497 |
+
st.error(f"**{facility}**: Needs verification with proper images")
|
| 498 |
+
else:
|
| 499 |
+
st.error(f"**{facility}**: Requires {shortage} more unit{'s' if shortage > 1 else ''}")
|
| 500 |
+
|
| 501 |
+
# Add recommendations
|
| 502 |
+
st.markdown("#### π‘ Recommendations")
|
| 503 |
+
st.info("""
|
| 504 |
+
To improve your grade:
|
| 505 |
+
1. Focus on addressing critical deficiencies first
|
| 506 |
+
2. Prioritize essential facilities
|
| 507 |
+
3. Document improvements with clear photographs
|
| 508 |
+
4. Ensure all verifications are complete
|
| 509 |
+
""")
|
| 510 |
+
else:
|
| 511 |
+
st.success("π Congratulations! All required facilities are met and verified.")
|
| 512 |
+
|
| 513 |
+
else:
|
| 514 |
+
# Show empty state
|
| 515 |
+
st.info("π No facilities have been verified yet. Please complete the verification process in the Facility Verification tab.")
|
| 516 |
+
st.markdown("""
|
| 517 |
+
#### Getting Started:
|
| 518 |
+
1. Go to the Facility Verification tab
|
| 519 |
+
2. Upload images for each facility
|
| 520 |
+
3. Complete the verification process
|
| 521 |
+
4. Return here to view your results
|
| 522 |
+
""")
|
| 523 |
+
|
| 524 |
+
with tab4:
|
| 525 |
+
st.markdown("### How to Use This System")
|
| 526 |
+
st.write("""
|
| 527 |
+
1. **College Information Tab**
|
| 528 |
+
- Enter basic college details
|
| 529 |
+
- View calculated facility requirements
|
| 530 |
+
|
| 531 |
+
2. **Facility Verification Tab**
|
| 532 |
+
- Navigate through facility categories
|
| 533 |
+
- Upload images for verification
|
| 534 |
+
- Get instant verification results
|
| 535 |
+
|
| 536 |
+
3. **Results Tab**
|
| 537 |
+
- View overall grade and score
|
| 538 |
+
- Check facility verification summary
|
| 539 |
+
- Review any deficiencies
|
| 540 |
+
""")
|
| 541 |
+
|
| 542 |
+
st.markdown("### Grading Criteria")
|
| 543 |
+
st.write("""
|
| 544 |
+
**Grade A:** β₯ 80% (Excellent infrastructure and verification)
|
| 545 |
+
**Grade B:** β₯ 60% (Good infrastructure with minor improvements needed)
|
| 546 |
+
**Grade C:** β₯ 40% (Basic infrastructure present but needs significant improvements)
|
| 547 |
+
**Grade D:** < 40% (Major infrastructure improvements required)
|
| 548 |
+
""")
|
| 549 |
+
|
| 550 |
+
st.markdown("### Note")
|
| 551 |
+
st.info("This system uses machine learning models to verify facilities from uploaded images. Ensure that the images clearly show the relevant facility for accurate verification.")
|
| 552 |
+
|
| 553 |
+
st.markdown("### Disclaimer")
|
| 554 |
+
st.warning("This tool is for assessment purposes only. The final evaluation and accreditation of educational institutions should be conducted by authorized bodies following official guidelines and on-site inspections.")
|
| 555 |
+
|
| 556 |
+
# Footer
|
| 557 |
+
st.markdown("---")
|
| 558 |
+
st.markdown("Developed for educational infrastructure assessment purposes. For support or inquiries, please contact the system administrator.")
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
cv2
|
| 3 |
+
Pillow
|
| 4 |
+
numpy
|
| 5 |
+
pandas
|
| 6 |
+
cvzone
|