Spaces:
Build error
Build error
File size: 48,447 Bytes
07629a7 | 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Facility Management System</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
:root {
--primary-color: #2563eb; /* Royal Blue */
--secondary-color: #4b5563; /* Dark Gray */
--success-color: #059669; /* Emerald */
--warning-color: #d97706; /* Dark Amber */
--danger-color: #dc2626; /* Red */
--background-color: #1e293b; /* Dark Blue Gray */
--card-background: #334155; /* Lighter Blue Gray */
--sidebar-background: #0f172a; /* Darkest Blue */
--text-primary: #f8fafc; /* Almost White */
--text-secondary: #cbd5e1; /* Light Gray */
--input-background: #475569; /* Medium Gray Blue */
--border-color: #64748b; /* Border Gray */
--hover-color: #1d4ed8; /* Darker Blue */
--border-radius: 0.75rem;
}
body {
font-family: 'Inter', sans-serif;
background-color: var(--background-color);
color: var(--text-primary);
line-height: 1.6;
}
.navbar {
background-color: var(--card-background);
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
padding: 1rem 0;
}
.navbar-brand {
font-weight: 700;
color: var(--primary-color);
}
.main-container {
max-width: 1400px;
margin: 2rem auto;
padding: 0 1rem;
}
.sidebar {
background-color: var(--sidebar-background);
border-radius: var(--border-radius);
padding: 1.5rem;
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}
.form-control {
background-color: #d2dae8;
color: var(--text-primary);
border-radius: 0.5rem;
border: 1px solid var(--border-color);
padding: 0.75rem;
transition: all 0.3s ease;
}
.form-control:focus {
background-color: var(--input-background);
color: var(--text-primary);
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}
.btn {
padding: 0.75rem 1.5rem;
border-radius: 0.5rem;
font-weight: 600;
transition: all 0.3s ease;
}
.btn-primary {
background-color: var(--primary-color);
border: none;
}
.btn-primary:hover {
background-color: var(--hover-color);
transform: translateY(-1px);
}
.facility-card {
background-color: var(--card-background);
border-radius: var(--border-radius);
border: none;
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
margin-bottom: 1.5rem;
overflow: hidden;
}
.facility-card .card-header {
background-color: var(--sidebar-background);
color: var(--text-primary);
padding: 1rem;
font-weight: 600;
border-bottom: none;
}
.facility-card .card-body {
padding: 1.5rem;
}
.upload-section {
background-color: var(--card-background);
border: 2px dashed var(--border-color);
border-radius: 0.5rem;
padding: 1.5rem;
text-align: center;
transition: all 0.3s ease;
}
.upload-section:hover {
border-color: var(--primary-color);
}
.grade-container {
background-color: var(--card-background);
border-radius: var(--border-radius);
padding: 2rem;
text-align: center;
margin-top: 2rem;
}
.grade-display {
font-size: 3rem;
font-weight: 700;
margin: 1rem 0;
color: var(--primary-color);
}
.stats-card {
background-color: var(--card-background);
border-radius: var(--border-radius);
padding: 1.5rem;
margin-bottom: 1rem;
}
.stats-value {
font-size: 1.5rem;
font-weight: 700;
color: var(--primary-color);
}
/* Add more modern styling for tables */
.table {
background-color: var(--card-background);
border-radius: var(--border-radius);
overflow: hidden;
color: var(--text-primary);
}
.table thead th {
background-color: var(--sidebar-background);
border-bottom: 2px solid #e2e8f0;
color: var(--text-secondary);
font-weight: 600;
text-transform: uppercase;
font-size: 0.875rem;
border-bottom-color: #475569;
}
/* Toast notifications */
.toast {
position: fixed;
top: 1rem;
right: 1rem;
padding: 1rem 1.5rem;
border-radius: 0.5rem;
background-color: var(--card-background);
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
z-index: 1000;
color: var(--text-primary);
}
/* Loading animation */
.loading-spinner {
width: 2.5rem;
height: 2.5rem;
border: 3px solid #f3f3f3;
border-top: 3px solid var(--primary-color);
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.container {
background-color: var(--card-background);
border-radius: var(--border-radius);
padding: 20px;
margin-top: 20px;
}
input[type="text"], textarea {
background-color: #cbd5e1;
color: var(--text-primary);
border: 3px solid #141111;
}
button {
background-color: #4a4a4a;
color: #ffffff;
border: none;
padding: 8px 16px;
border-radius: 4px;
}
button:hover {
background-color: #5a5a5a;
}
.card {
background-color: var(--card-background);
border: 1px solid var(--border-color);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
color: var(--text-primary);
}
.card-header {
background-color: var(--sidebar-background);
color: white;
border-bottom: none;
font-weight: 600;
}
.card-body {
background-color: var(--card-background);
color: var(--text-primary);
}
/* Update input styles */
input[type="number"] {
background-color: var(--input-background);
color: var(--text-primary);
border-color: #475569;
}
input[type="number"]:focus {
background-color: var(--input-background);
color: var(--text-primary);
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}
/* Update button styles to match theme */
button {
background-color: var(--primary-color);
color: var(--text-primary);
border: none;
padding: 8px 16px;
border-radius: var(--border-radius);
transition: all 0.3s ease;
}
button:hover {
background-color: var(--hover-color);
transform: translateY(-1px);
}
/* Update input group styling */
.input-group-text {
background-color: var(--input-background);
color: var(--text-secondary);
border: 1px solid var(--border-color);
}
/* Update verification result styling */
.uploaded-image {
background-color: var(--card-background);
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
padding: 1rem;
margin-bottom: 1rem;
}
.img-thumbnail {
background-color: var(--input-background);
border-color: #475569;
}
/* Update form label color */
.form-label {
color: var(--text-primary);
font-weight: 500;
}
/* Add styles for grade colors with better visibility */
.grade-a { color: #34d399; } /* Light Green */
.grade-b { color: #60a5fa; } /* Light Blue */
.grade-c { color: #fbbf24; } /* Light Yellow */
.grade-d { color: #fb923c; } /* Light Orange */
.grade-f { color: #f87171; } /* Light Red */
/* Update table borders */
.table-bordered > :not(caption) > * {
border-color: #475569;
}
.table-hover tbody tr:hover {
background-color: var(--input-background);
}
/* Add these styles for the facility cards */
.facility-type-cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1.5rem;
margin-bottom: 2rem;
}
.facility-type-card {
background-color: var(--card-background);
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
padding: 1.5rem;
transition: all 0.3s ease;
}
.facility-type-card:hover {
transform: translateY(-2px);
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.facility-type-card h3 {
color: var(--text-primary);
margin-bottom: 1rem;
font-size: 1.25rem;
}
.facility-type-card .icon {
font-size: 2rem;
margin-bottom: 1rem;
color: var(--primary-color);
}
.model-info {
color: var(--text-secondary);
font-size: 0.875rem;
margin-bottom: 1rem;
padding: 0.5rem;
background-color: var(--input-background);
border-radius: var(--border-radius);
text-align: center;
}
/* Add/update these styles */
.upload-grid {
display: flex;
flex-direction: column;
gap: 1.5rem;
width: 100%;
max-width: 800px;
margin: 0 auto;
}
.upload-card {
background-color: var(--card-background);
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
padding: 1.5rem;
width: 100%;
}
.results-grid {
display: flex;
flex-direction: column;
gap: 1.5rem;
width: 100%;
}
.result-card {
background-color: var(--card-background);
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
padding: 1.5rem;
width: 100%;
}
.detections-list {
margin-top: 1rem;
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
overflow: hidden;
}
.detection-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.75rem 1rem;
border-bottom: 1px solid var(--border-color);
}
.detection-item:last-child {
border-bottom: none;
}
/* Add these styles for improved object detection UI */
.detection-section {
background-color: var(--card-background);
border-radius: var(--border-radius);
padding: 2rem;
margin-bottom: 2rem;
}
.detection-header {
text-align: center;
margin-bottom: 2rem;
color: var(--text-primary);
}
.detection-header h2 {
font-size: 2rem;
margin-bottom: 1rem;
}
.upload-grid {
display: flex;
flex-direction: column;
gap: 2rem;
}
.upload-card {
background-color: var(--sidebar-background);
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
padding: 2rem;
transition: all 0.3s ease;
}
.upload-card:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.upload-card h3 {
color: var(--text-primary);
font-size: 1.5rem;
margin-bottom: 1rem;
display: flex;
align-items: center;
gap: 0.5rem;
}
.upload-card h3 i {
color: var(--primary-color);
}
.custom-file-upload {
background-color: var(--input-background);
border: 2px dashed var(--border-color);
border-radius: var(--border-radius);
padding: 2rem;
text-align: center;
cursor: pointer;
transition: all 0.3s ease;
display: block;
margin-bottom: 1rem;
}
.custom-file-upload:hover {
border-color: var(--primary-color);
background-color: rgba(99, 102, 241, 0.1);
}
.custom-file-upload i {
font-size: 2rem;
color: var(--primary-color);
margin-bottom: 1rem;
display: block;
}
.detection-results {
background-color: var(--card-background);
border-radius: var(--border-radius);
padding: 1.5rem;
margin-top: 2rem;
}
.detection-results h4 {
color: var(--text-primary);
margin-bottom: 1rem;
padding-bottom: 0.5rem;
border-bottom: 1px solid var(--border-color);
}
.table {
margin-bottom: 0;
}
.table thead th {
background-color: var(--input-background);
color: var(--text-primary);
font-weight: 600;
padding: 1rem;
}
.table tbody td {
padding: 1rem;
color: var(--text-secondary);
}
.confidence-badge {
background-color: var(--primary-color);
color: white;
padding: 0.25rem 0.75rem;
border-radius: 9999px;
font-size: 0.875rem;
}
#detect-all {
background-color: var(--primary-color);
color: white;
padding: 1rem 2rem;
font-size: 1.1rem;
font-weight: 600;
margin-top: 2rem;
transition: all 0.3s ease;
}
#detect-all:hover {
background-color: var(--hover-color);
transform: translateY(-2px);
}
.loading {
text-align: center;
padding: 2rem;
}
.loading-spinner {
margin: 0 auto 1rem;
}
.stats-panel {
background-color: var(--sidebar-background);
border-radius: var(--border-radius);
padding: 2rem;
margin-top: 2rem;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1.5rem;
}
.stats-item {
text-align: center;
padding: 1.5rem;
background-color: var(--card-background);
border-radius: var(--border-radius);
}
.stats-value {
font-size: 2rem;
font-weight: 700;
color: var(--primary-color);
display: block;
margin-top: 0.5rem;
}
</style>
</head>
<body>
<div class="container mt-5">
<h1 class="text-center mb-4">Facility Management System</h1>
<div class="row">
<!-- Sidebar -->
<div class="col-md-4 sidebar">
<h4>Input Form</h4>
<form id="facility-form">
<div class="mb-3">
<label for="num_students" class="form-label">Number of Students:</label>
<input type="number" id="num_students" class="form-control" required>
</div>
<div class="mb-3">
<label for="num_divisions" class="form-label">Number of Divisions:</label>
<input type="number" id="num_divisions" class="form-control" required>
</div>
<div class="mb-3">
<label for="num_courses" class="form-label">Number of Courses:</label>
<input type="number" id="num_courses" class="form-control" required>
</div>
<div class="mb-3">
<label for="course_duration" class="form-label">Course Duration (Years):</label>
<input type="number" id="course_duration" class="form-control" required>
</div>
<button type="submit" class="btn btn-primary w-100">Calculate</button>
</form>
</div>
<!-- Facilities Section -->
<div class="col-md-8">
<div id="facilities-section">
{% for facility in facilities %}
<div class="card">
<div class="card-header">{{ facility }}</div>
<div class="card-body">
<!-- Facility Requirements -->
<div class="card-body">
<!-- Facility Requirements -->
<h5>Requirements:</h5>
<div class="input-group mb-3">
<input
type="text"
id="requirement-{{ facility | replace(' ', '_') | lower }}"
class="form-control text-center"
value="0"
readonly>
<span class="input-group-text">/</span>
<input
type="number"
id="actual-{{ facility | replace(' ', '_') | lower }}"
class="form-control text-center"
placeholder="Enter Actual Count">
</div>
</div>
<!-- Upload Images -->
<h5 class="mt-4">Upload Images:</h5>
<form enctype="multipart/form-data">
<div class="input-group">
<input type="file" class="form-control" id="files-{{ facility | replace(' ', '_') | lower }}" name="images" multiple>
<button type="button" class="btn btn-success upload-btn" data-facility="{{ facility | replace(' ', '_') | lower }}">Verify Images</button>
</div>
<div id="verification-result-{{ facility | replace(' ', '_') | lower }}" class="mt-3">
<!-- Uploaded images and verification results will be displayed here -->
</div>
</form>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
<div class="container">
<div class="header">
<h1>Object Detection</h1>
</div>
<div class="toast" id="toast"></div>
<div class="debug-panel" id="debug-panel">
<div class="debug-content"></div>
</div>
<div class="main-content">
<div class="detection-section">
<div class="detection-header">
<h2>Object Detection</h2>
<p>Upload images for each facility to detect and count objects</p>
</div>
<form id="upload-form">
<div class="upload-grid">
<!-- Classroom Section -->
<div class="upload-card">
<h3><i class="fas fa-chalkboard"></i> Classroom</h3>
<label class="custom-file-upload">
<input type="file" id="image-classroom" name="image_classroom" accept="image/*" style="display: none;">
<i class="fas fa-cloud-upload-alt"></i>
<span>Drop classroom image here or click to upload</span>
</label>
<p id="file-name-classroom" class="file-name"></p>
<div class="detection-results">
<h4>Detected Objects</h4>
<table class="table">
<thead>
<tr>
<th>Object</th>
<th>Confidence</th>
<th>Count</th>
</tr>
</thead>
<tbody id="classroom-detections"></tbody>
</table>
</div>
</div>
<!-- Chemical Lab Section -->
<div class="upload-card">
<h3><i class="fas fa-flask"></i> Chemical Lab</h3>
<label class="custom-file-upload">
<input type="file" id="image-chemical-lab" name="image_chemical_lab" accept="image/*" style="display: none;">
<i class="fas fa-cloud-upload-alt"></i>
<span>Drop lab image here or click to upload</span>
</label>
<p id="file-name-chemical-lab" class="file-name"></p>
<div class="detection-results">
<h4>Detected Objects</h4>
<table class="table">
<thead>
<tr>
<th>Object</th>
<th>Confidence</th>
<th>Count</th>
</tr>
</thead>
<tbody id="chemical-lab-detections"></tbody>
</table>
</div>
</div>
<!-- Mechanical Workshop Section -->
<div class="upload-card">
<h3><i class="fas fa-tools"></i> Mechanical Workshop</h3>
<label class="custom-file-upload">
<input type="file" id="image-mechanical-workshop" name="image_mechanical_workshop" accept="image/*" style="display: none;">
<i class="fas fa-cloud-upload-alt"></i>
<span>Drop workshop image here or click to upload</span>
</label>
<p id="file-name-mechanical-workshop" class="file-name"></p>
<div class="detection-results">
<h4>Detected Objects</h4>
<table class="table">
<thead>
<tr>
<th>Object</th>
<th>Confidence</th>
<th>Count</th>
</tr>
</thead>
<tbody id="mechanical-workshop-detections"></tbody>
</table>
</div>
</div>
<!-- Computer Lab Section -->
<div class="upload-card">
<h3><i class="fas fa-desktop"></i> Computer Lab</h3>
<label class="custom-file-upload">
<input type="file" id="image-computer-lab" name="image_computer_lab" accept="image/*" style="display: none;">
<i class="fas fa-cloud-upload-alt"></i>
<span>Drop computer lab image here or click to upload</span>
</label>
<p id="file-name-computer-lab" class="file-name"></p>
<div class="detection-results">
<h4>Detected Objects</h4>
<table class="table">
<thead>
<tr>
<th>Object</th>
<th>Confidence</th>
<th>Count</th>
</tr>
</thead>
<tbody id="computer-lab-detections"></tbody>
</table>
</div>
</div>
<!-- CCTV Section -->
<div class="upload-card">
<h3><i class="fas fa-video"></i> CCTV Detection</h3>
<label class="custom-file-upload">
<input type="file" id="image-cctv" name="image_cctv" accept="image/*" style="display: none;">
<i class="fas fa-cloud-upload-alt"></i>
<span>Drop CCTV image here or click to upload</span>
</label>
<p id="file-name-cctv" class="file-name"></p>
<div class="detection-results">
<h4>Detected Objects</h4>
<table class="table">
<thead>
<tr>
<th>Object</th>
<th>Confidence</th>
<th>Count</th>
</tr>
</thead>
<tbody id="cctv-detections"></tbody>
</table>
</div>
</div>
<!-- Notice Board Section -->
<div class="upload-card">
<h3><i class="fas fa-clipboard"></i> Notice Board Detection</h3>
<label class="custom-file-upload">
<input type="file" id="image-notice-board" name="image_notice_board" accept="image/*" style="display: none;">
<i class="fas fa-cloud-upload-alt"></i>
<span>Drop notice board image here or click to upload</span>
</label>
<p id="file-name-notice-board" class="file-name"></p>
<div class="detection-results">
<h4>Detected Objects</h4>
<table class="table">
<thead>
<tr>
<th>Object</th>
<th>Confidence</th>
<th>Count</th>
</tr>
</thead>
<tbody id="notice-board-detections"></tbody>
</table>
</div>
</div>
<!-- Bench Section -->
<div class="upload-card">
<h3><i class="fas fa-chair"></i> Bench Detection</h3>
<label class="custom-file-upload">
<input type="file" id="image-bench" name="image_bench" accept="image/*" style="display: none;">
<i class="fas fa-cloud-upload-alt"></i>
<span>Drop bench image here or click to upload</span>
</label>
<p id="file-name-bench" class="file-name"></p>
<div class="detection-results">
<h4>Detected Objects</h4>
<table class="table">
<thead>
<tr>
<th>Object</th>
<th>Confidence</th>
<th>Count</th>
</tr>
</thead>
<tbody id="bench-detections"></tbody>
</table>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary w-100" id="detect-all">
<i class="fas fa-search"></i>
Detect Objects in All Images
</button>
</form>
</div>
<div class="error-message" id="error-message"></div>
<div class="loading" id="loading">
<div class="loading-spinner"></div>
<p>Analyzing image...</p>
</div>
<div class="stats-panel" id="stats-panel" style="display: none;">
<h3>Analysis Summary</h3>
<div class="stats-grid">
<div class="stats-item">
<span>Total Objects Detected</span>
<span id="total-detections" class="stats-value">0</span>
</div>
<div class="stats-item">
<span>Processing Duration</span>
<span id="processing-time" class="stats-value">0ms</span>
</div>
</div>
</div>
<div class="image-container">
<div id="result">
<img id="result-image" alt="Detection result">
<div class="detection-count" id="detection-count" style="display: none;"></div>
</div>
</div>
</div>
<div class="sidebar">
<h2 class="detections-title">Detected Objects</h2>
<div id="detections"></div>
</div>
</div>
<div class="card mt-5">
<div class="card-header">
Deficiency Table
</div>
<div class="card-body">
<table class="table table-bordered table-hover text-center" id="deficiency-table">
<thead class="table-primary">
<tr>
<th>Facility Name</th>
<th>Required Count</th>
<th>Actual Count</th>
<th>Number of Images Verified</th>
<th>Status</th>
</tr>
</thead>
<tbody id="deficiency-table-body">
<!-- Dynamic rows will be added here -->
</tbody>
</table>
</div>
</div>
<div class="grade-display-section text-center mt-4">
<h3>Your Grade:</h3>
<div id="grade-display" class="grade-display"></div>
</div>
<div class="text-center mt-4">
<h3>Download Reports</h3>
<button id="download-pdf" class="btn btn-primary">Download PDF Report</button>
<button id="download-excel" class="btn btn-success">Download Excel Report</button>
</div>
<script>
$('#facility-form').on('submit', function (e) {
e.preventDefault();
const data = {
num_students: $('#num_students').val(),
num_divisions: $('#num_divisions').val(),
num_courses: $('#num_courses').val(),
course_duration: $('#course_duration').val(),
};
$.ajax({
url: '/calculate',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(data),
success: function (response) {
for (const [facility, value] of Object.entries(response)) {
const facilityId = facility.replace(/ /g, '_').toLowerCase();
$(`#requirement-${facilityId}`).val(value);
// Optionally, clear or prefill the "Actual Count" input box
$(`#actual-${facilityId}`).val('');
}
},
error: function () {
alert('Failed to calculate facilities. Please try again.');
}
});
});
// Capture "Actual Count" values for further processing
function getActualCounts() {
const actualCounts = {};
$('.card').each(function () {
const facility = $(this).find('.card-header').text().trim();
const facilityId = facility.replace(/ /g, '_').toLowerCase();
const actualCount = $(`#actual-${facilityId}`).val();
actualCounts[facility] = actualCount ? parseInt(actualCount, 10) : 0;
});
console.log(actualCounts);
// Perform additional processing with `actualCounts` as needed
}
// Handle Multiple File Upload
$('.upload-btn').on('click', function () {
const facility = $(this).data('facility');
const fileInput = $(`#files-${facility}`)[0];
const files = fileInput.files;
if (files.length === 0) {
alert('Please select at least one image.');
return;
}
const formData = new FormData();
Array.from(files).forEach((file) => {
formData.append('images', file);
});
$.ajax({
url: `/upload/${facility.replace(/_/g, ' ')}`,
type: 'POST',
processData: false,
contentType: false,
data: formData,
success: function (response) {
let resultsHtml = '';
response.forEach((result, index) => {
const fileReader = new FileReader();
// Render each image
fileReader.onload = function (e) {
resultsHtml += `
<div class="uploaded-image">
<img src="${e.target.result}" alt="Uploaded Image" class="img-thumbnail" style="max-width: 200px;">
<p class="text-center mt-2">
<strong>Label:</strong> ${result.label}<br>
<strong>Confidence:</strong> ${result.confidence.toFixed(2)}
</p>
<p class="text-center ${result.confidence >= 0.8 ? 'text-success' : 'text-danger'}">
${result.confidence >= 0.8 ? 'Verified' : 'Not Verified'}
</p>
</div>
`;
// Update the results section for the facility after all images are processed
if (index === response.length - 1) {
$(`#verification-result-${facility}`).html(resultsHtml);
}
};
// Read the file to get its data URL
fileReader.readAsDataURL(files[index]);
});
},
error: function () {
$(`#verification-result-${facility}`).html(`
<div class="alert alert-danger">Failed to verify images.</div>
`);
}
});
});
// Handle Answer Submission
$('.submit-answers').on('click', function () {
const facility = $(this).data('facility');
const answers = [];
$(this).closest('.question-form').find('.answer-box').each(function () {
answers.push({
question: $(this).data('question'),
answer: $(this).val()
});
});
$.ajax({
url: '/submit_answers',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({ facility: facility, answers: answers }),
success: function (response) {
alert(response.message);
},
error: function () {
alert('Failed to submit answers.');
}
});
});
const loadingDiv = document.getElementById('loading');
const errorMessage = document.getElementById('error-message');
const form = document.getElementById('upload-form');
const detectButton = form.querySelector('button[type="submit"]');
const imageInputs = {
classroom: document.getElementById('image-classroom'),
chemical_lab: document.getElementById('image-chemical-lab'),
mechanical_workshop: document.getElementById('image-mechanical-workshop'),
computer_lab: document.getElementById('image-computer-lab'),
cctv: document.getElementById('image-cctv'),
notice_board: document.getElementById('image-notice-board'),
bench: document.getElementById('image-bench')
};
// Handle file selection for each input
Object.entries(imageInputs).forEach(([key, input]) => {
input.addEventListener('change', (e) => {
const file = e.target.files[0];
const fileNameElement = document.getElementById(`file-name-${key.replace('_', '-')}`);
if (file) {
fileNameElement.textContent = `Selected: ${file.name}`;
updateDetectButton();
} else {
fileNameElement.textContent = '';
}
// Clear previous results when new file is selected
clearResults();
});
});
function clearResults() {
const resultContainer = document.getElementById('result');
resultContainer.innerHTML = '<img id="result-image" alt="Detection result" style="display: none;">';
document.getElementById('stats-panel').style.display = 'none';
errorMessage.style.display = 'none';
}
function updateDetectButton() {
const allFilesSelected = Object.values(imageInputs).every(input => input.files.length > 0);
detectButton.disabled = !allFilesSelected;
}
form.addEventListener('submit', async (e) => {
e.preventDefault();
const formData = new FormData();
let allFilesValid = true;
// Clear previous results
clearResults();
Object.entries(imageInputs).forEach(([key, input]) => {
const file = input.files[0];
if (!file) {
showToast(`Please select an image for ${key.replace('_', ' ')}`, 'error');
allFilesValid = false;
return;
}
formData.append(`image_${key}`, file);
});
if (!allFilesValid) return;
const startTime = performance.now();
loadingDiv.style.display = 'block';
detectButton.disabled = true;
errorMessage.style.display = 'none';
try {
const response = await fetch('/detect', {
method: 'POST',
body: formData
});
const data = await response.json();
if (data.success) {
const processingTime = Math.round(performance.now() - startTime);
displayResults(data.results, processingTime);
} else {
errorMessage.textContent = data.error || 'Error processing images';
errorMessage.style.display = 'block';
showToast(data.error || 'Error processing images', 'error');
}
} catch (error) {
errorMessage.textContent = 'Network error or server not responding';
errorMessage.style.display = 'block';
showToast('Network error or server not responding', 'error');
console.error('Error:', error);
} finally {
loadingDiv.style.display = 'none';
detectButton.disabled = false;
}
});
function displayResults(results, processingTime) {
const resultContainer = document.getElementById('result');
resultContainer.innerHTML = '<div class="results-grid"></div>';
const grid = resultContainer.querySelector('.results-grid');
let totalDetections = 0;
Object.entries(results).forEach(([environment, data]) => {
const card = document.createElement('div');
card.className = 'result-card';
// Format the environment name for display
const envName = environment.split('_')
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
card.innerHTML = `
<h3>${envName}</h3>
<img src="${data.image}" alt="${environment}" style="width: 100%">
<div class="detections-count">${data.detections.length} objects detected</div>
<div class="detections-list">
${data.detections.map(det => `
<div class="detection-item">
<span>${det.class}</span>
<span class="confidence-badge">${(det.confidence * 100).toFixed(1)}%</span>
</div>
`).join('')}
</div>
`;
grid.appendChild(card);
totalDetections += data.detections.length;
});
// Update stats panel
document.getElementById('total-detections').textContent = totalDetections;
document.getElementById('processing-time').textContent = `${processingTime}ms`;
document.getElementById('stats-panel').style.display = 'block';
showToast(`Processing completed in ${processingTime}ms`);
}
function showToast(message, type = 'success') {
const toast = document.getElementById('toast');
toast.textContent = message;
toast.className = `toast ${type}`;
toast.style.display = 'block';
setTimeout(() => {
toast.style.display = 'none';
}, 3000);
}
function debugLog(message) {
const debugPanel = document.getElementById('debug-panel');
const content = debugPanel.querySelector('.debug-content');
const timestamp = new Date().toLocaleTimeString();
content.innerHTML += `[${timestamp}] ${message}<br>`;
content.scrollTop = content.scrollHeight;
}
// Handle window resize
let resizeTimeout;
window.addEventListener('resize', () => {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(() => {
const highlightBoxes = document.querySelectorAll('.highlight-box');
const labels = document.querySelectorAll('.detection-label');
highlightBoxes.forEach(box => box.style.display = 'none');
labels.forEach(label => label.style.display = 'none');
}, 250);
});
// Add debug panel toggle
document.addEventListener('keypress', (e) => {
if (e.key === 'd') {
const debugPanel = document.getElementById('debug-panel');
debugPanel.classList.toggle('show');
}
});
function updateDeficiencyTableAndGrade() {
const tableBody = $('#deficiency-table-body');
tableBody.empty(); // Clear existing rows
let totalDeficiencies = 0;
let totalVerifiedImages = 0;
const totalFacilities = $('.card').length;
$('.card').each(function () {
const facilityName = $(this).find('.card-header').text().trim();
const facilityId = facilityName.replace(/ /g, '_').toLowerCase();
const requiredCount = parseInt($(`#requirement-${facilityId}`).val(), 10) || 0;
const actualCount = parseInt($(`#actual-${facilityId}`).val(), 10) || 0;
// Count verified images
const verifiedImages = $(`#verification-result-${facilityId} .uploaded-image .text-success`).length;
totalVerifiedImages += verifiedImages;
// Determine deficiency
const deficiency = requiredCount > actualCount;
if (deficiency) totalDeficiencies++;
const status = deficiency
? `<span class="text-danger">✘ Deficiency</span>`
: `<span class="text-success">✔ No Deficiency</span>`;
// Add a new row to the table
tableBody.append(`
<tr>
<td>${facilityName}</td>
<td>${requiredCount}</td>
<td>${actualCount}</td>
<td>${verifiedImages}</td>
<td>${status}</td>
</tr>
`);
});
// Calculate grade
const grade = calculateGrade(totalDeficiencies, totalVerifiedImages, totalFacilities);
// Update grade display
const gradeDisplay = $('#grade-display');
gradeDisplay
.removeClass('grade-a grade-b grade-c grade-d grade-f')
.addClass(`grade-${grade.toLowerCase()}`)
.text(grade);
}
function calculateGrade(totalDeficiencies, totalVerifiedImages, totalFacilities) {
const deficiencyRate = totalDeficiencies / totalFacilities;
const verificationBonus = totalVerifiedImages / totalFacilities;
if (deficiencyRate <= 0.1 && verificationBonus >= 0.8) return 'A';
if (deficiencyRate <= 0.2 && verificationBonus >= 0.6) return 'B';
if (deficiencyRate <= 0.3 && verificationBonus >= 0.4) return 'C';
if (deficiencyRate <= 0.4 && verificationBonus >= 0.2) return 'D';
return 'F';
}
// Attach event listeners
$('#facility-form').on('submit', function (e) {
e.preventDefault();
updateDeficiencyTableAndGrade();
});
$('.form-control').on('input', function () {
updateDeficiencyTableAndGrade();
});
$('.upload-btn').on('click', function () {
setTimeout(() => {
updateDeficiencyTableAndGrade();
}, 1000); // Allow time for verification results to render
});
// Handle PDF download
$('#download-pdf').on('click', function () {
window.location.href = '/download_report';
});
// Handle Excel download
$('#download-excel').on('click', function () {
window.location.href = '/download_excel';
});
// Add FontAwesome for icons
document.head.innerHTML += '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">';
</script>
</body>
</html>
|