Spaces:
Runtime error
Runtime error
File size: 43,787 Bytes
df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 621557a 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 c6f3046 7ef21d4 df64439 7ef21d4 621557a 7ef21d4 bd20c53 7ef21d4 df64439 bd20c53 df64439 bd20c53 df64439 bd20c53 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 bd20c53 df64439 7ef21d4 df64439 7ef21d4 df64439 7ef21d4 df64439 621557a df64439 | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Undertone Classification Dashboard</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
<style>
:root {
--primary: #1d4ed8;
--primary-light: #3b82f6;
--primary-pale: #eff6ff;
--dark-text: #0f172a;
--muted-text: #64748b;
--border: rgba(29, 78, 216, 0.15);
--card-bg: #ffffff;
--cool-color: #818cf8;
--neutral-color: #fb923c;
--warm-color: #f59e0b;
}
body {
background: linear-gradient(160deg, #eff6ff 0%, #f8fafc 60%, #e0f2fe 100%);
color: var(--dark-text);
font-family: 'Inter', sans-serif;
min-height: 100vh;
}
/* ββ Cards ββ */
.glass-card {
background: var(--card-bg);
border: 1px solid var(--border);
border-radius: 24px;
box-shadow: 0 4px 24px rgba(29, 78, 216, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
}
/* ββ Buttons ββ */
.btn-gradient-primary {
background: linear-gradient(135deg, #2563eb, #1d4ed8);
color: #fff;
border: none;
border-radius: 12px;
transition: .25s;
}
.btn-gradient-success {
background: linear-gradient(135deg, #0ea5e9, #0284c7);
color: #fff;
border: none;
border-radius: 12px;
transition: .25s;
}
.btn-gradient-primary:hover,
.btn-gradient-success:hover {
transform: translateY(-2px);
color: #fff;
box-shadow: 0 8px 24px rgba(29, 78, 216, .3);
}
/* ββ Video ββ */
#video {
border-radius: 14px;
width: 100%;
background: #000;
border: 2px solid var(--border);
}
/* ββ Nav tabs (pill style) ββ */
.nav-tabs {
border-bottom: none;
background: #f1f5f9;
border-radius: 12px;
padding: 4px;
gap: 4px;
display: flex;
}
.nav-tabs .nav-link {
color: var(--muted-text);
border: none;
font-weight: 600;
padding: 9px 18px;
border-radius: 9px;
flex: 1;
text-align: center;
transition: .2s;
}
.nav-tabs .nav-link.active {
background: #fff;
color: var(--primary);
box-shadow: 0 2px 8px rgba(29, 78, 216, .12);
}
.nav-tabs .nav-link:not(.active):hover {
color: var(--primary);
background: rgba(255, 255, 255, .5);
}
/* ββ Drag-drop zone ββ */
.drop-zone {
border: 2px dashed #cbd5e1;
border-radius: 16px;
padding: 28px 16px;
text-align: center;
cursor: pointer;
transition: .2s;
background: #f8fafc;
position: relative;
}
.drop-zone:hover,
.drop-zone.drag-over {
border-color: var(--primary-light);
background: var(--primary-pale);
}
.drop-zone input[type=file] {
position: absolute;
inset: 0;
opacity: 0;
cursor: pointer;
width: 100%;
height: 100%;
}
.drop-zone-icon {
font-size: 2rem;
color: #93c5fd;
margin-bottom: 8px;
}
.drop-zone-text {
font-size: .82rem;
font-weight: 600;
color: var(--muted-text);
}
.drop-zone-sub {
font-size: .72rem;
color: #94a3b8;
}
/* ββ File preview ββ */
#filePreviewWrap {
display: none;
margin-top: 12px;
position: relative;
border-radius: 12px;
overflow: hidden;
}
#filePreview {
width: 100%;
max-height: 180px;
object-fit: cover;
border-radius: 12px;
display: block;
}
.preview-remove {
position: absolute;
top: 8px;
right: 8px;
background: rgba(0, 0, 0, .55);
color: #fff;
border: none;
border-radius: 50%;
width: 28px;
height: 28px;
font-size: .75rem;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
.preview-name {
font-size: .72rem;
color: var(--muted-text);
margin-top: 6px;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* ββ Form control ββ */
.form-control {
background: #f8fafc;
border: 1px solid #cbd5e1;
color: var(--dark-text);
}
.form-control:focus {
border-color: var(--primary-light);
box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}
/* ββ Section headings ββ */
h1,
h5 {
color: var(--dark-text);
}
.text-primary {
color: var(--primary) !important;
}
.text-secondary {
color: var(--muted-text) !important;
}
.text-muted {
color: #94a3b8 !important;
}
/* ββ Spinner ββ */
.loading-overlay {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.spinner-border {
width: 3rem;
height: 3rem;
color: var(--primary);
}
/* ββ Undertone badge ββ */
.undertone-badge {
display: inline-flex;
align-items: center;
gap: 10px;
padding: 10px 22px;
border-radius: 50px;
font-size: 1.4rem;
font-weight: 800;
letter-spacing: .03em;
animation: fadeUp .5s ease both;
}
.badge-cool {
background: linear-gradient(135deg, #312e81, #4338ca);
color: #c7d2fe;
box-shadow: 0 0 28px rgba(99, 102, 241, .3);
}
.badge-neutral {
background: linear-gradient(135deg, #7c2d12, #c2410c);
color: #fed7aa;
box-shadow: 0 0 28px rgba(251, 146, 60, .3);
}
.badge-warm {
background: linear-gradient(135deg, #78350f, #d97706);
color: #fef3c7;
box-shadow: 0 0 28px rgba(245, 158, 11, .3);
}
.swatch {
width: 22px;
height: 22px;
border-radius: 50%;
border: 2px solid rgba(255, 255, 255, .4);
}
/* ββ Image comparison panel ββ */
.img-pair {
display: flex;
gap: 16px;
align-items: flex-start;
}
.img-slot {
display: flex;
flex-direction: column;
align-items: center;
gap: 6px;
flex: 1;
}
.img-slot-label {
font-size: .65rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: .08em;
color: var(--muted-text);
}
.img-thumb {
width: 100%;
aspect-ratio: 1 / 1;
object-fit: cover;
border-radius: 14px;
border: 3px solid #fff;
box-shadow: 0 0 0 3px var(--ring-color, #3b82f6), 0 4px 16px rgba(59, 130, 246, .2);
transition: box-shadow .4s;
}
.crop-preview {
width: 110px;
height: 110px;
border-radius: 50%;
object-fit: cover;
border: 4px solid #fff;
box-shadow: 0 0 0 4px var(--ring-color, #3b82f6), 0 4px 20px rgba(59, 130, 246, .25);
transition: box-shadow .4s;
}
/* ββ Agreement pill ββ */
.agree-pill {
display: inline-flex;
align-items: center;
gap: 6px;
font-size: .78rem;
font-weight: 700;
padding: 4px 14px;
border-radius: 50px;
text-transform: uppercase;
letter-spacing: .05em;
}
.agree-yes {
background: #f0fdf4;
color: #16a34a;
border: 1px solid #bbf7d0;
}
.agree-no {
background: #fef2f2;
color: #dc2626;
border: 1px solid #fecaca;
}
/* ββ Radial ring ββ */
.ring-wrap {
position: relative;
width: 80px;
height: 80px;
flex-shrink: 0;
}
.ring-wrap svg {
transform: rotate(-90deg);
}
.ring-bg {
fill: none;
stroke: #e2e8f0;
stroke-width: 7;
}
.ring-fill {
fill: none;
stroke-width: 7;
stroke-linecap: round;
transition: stroke-dashoffset 1s ease;
}
.ring-label {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-weight: 800;
font-size: .85rem;
color: var(--dark-text);
}
.ring-sub {
font-size: .6rem;
font-weight: 500;
color: var(--muted-text);
margin-top: 1px;
}
/* ββ Model score blocks ββ */
.model-block {
border-radius: 16px;
padding: 16px 18px;
background: #f8fafc;
border: 1px solid #e2e8f0;
}
.model-title {
font-size: .7rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: .1em;
color: var(--primary);
margin-bottom: 12px;
}
.bar-track {
height: 8px;
background: #e2e8f0;
border-radius: 4px;
overflow: hidden;
margin-top: 5px;
}
.bar-fill {
height: 100%;
border-radius: 4px;
transition: width 1s ease;
}
.bar-cool {
background: linear-gradient(90deg, #4f46e5, #818cf8);
}
.bar-neutral {
background: linear-gradient(90deg, #c2410c, #fb923c);
}
.bar-warm {
background: linear-gradient(90deg, #b45309, #f59e0b);
}
/* ββ Score label text ββ */
.score-row span:first-child {
color: var(--dark-text);
}
.score-row span:last-child {
color: var(--primary);
}
/* ββ Palette ββ */
.palette-title {
font-size: .7rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: .1em;
color: var(--primary);
margin-bottom: 10px;
}
.palette-chip {
width: 36px;
height: 36px;
border-radius: 50%;
border: 2px solid rgba(0, 0, 0, .1);
cursor: default;
transition: transform .2s;
position: relative;
}
.palette-chip:hover {
transform: scale(1.2);
z-index: 2;
}
.palette-chip[title]:hover::after {
content: attr(title);
position: absolute;
bottom: calc(100% + 6px);
left: 50%;
transform: translateX(-50%);
background: var(--dark-text);
color: #fff;
font-size: .65rem;
white-space: nowrap;
padding: 3px 8px;
border-radius: 6px;
pointer-events: none;
}
/* ββ Placeholder steps ββ */
.step-list {
list-style: none;
padding: 0;
margin: 0;
text-align: left;
}
.step-list li {
display: flex;
align-items: center;
gap: 10px;
font-size: .8rem;
color: var(--muted-text);
padding: 6px 0;
}
.step-num {
width: 22px;
height: 22px;
border-radius: 50%;
background: var(--primary-pale);
color: var(--primary);
font-size: .7rem;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
/* ββ Divider label ββ */
.section-divider {
display: flex;
align-items: center;
gap: 10px;
margin: 12px 0;
}
.section-divider span {
font-size: .65rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: .08em;
color: var(--muted-text);
white-space: nowrap;
}
.section-divider::before,
.section-divider::after {
content: '';
flex: 1;
height: 1px;
background: #e2e8f0;
}
/* ββ Score grid ββ */
.scores-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
}
/* ββ Lang toggle ββ */
.lang-toggle {
display: inline-flex;
border: 2px solid var(--border);
border-radius: 50px;
overflow: hidden;
gap: 0;
}
.lang-btn {
background: none;
border: none;
padding: 5px 14px;
font-size: .72rem;
font-weight: 700;
color: var(--muted-text);
cursor: pointer;
transition: .18s;
letter-spacing: .04em;
}
.lang-btn.active {
background: var(--primary);
color: #fff;
}
.lang-btn:not(.active):hover {
background: var(--primary-pale);
color: var(--primary);
}
/* ββ Animations ββ */
@keyframes fadeUp {
from {
opacity: 0;
transform: translateY(12px)
}
to {
opacity: 1;
transform: none
}
}
.result-anim {
animation: fadeUp .45s ease both;
}
.result-anim:nth-child(2) {
animation-delay: .08s
}
.result-anim:nth-child(3) {
animation-delay: .16s
}
.result-anim:nth-child(4) {
animation-delay: .24s
}
</style>
</head>
<body>
<div class="container py-5">
<header class="text-center mb-5" style="position:relative">
<div style="position:absolute;right:0;top:0;">
<div class="lang-toggle">
<button class="lang-btn" id="btnEN" onclick="setLang('en')">EN</button>
<button class="lang-btn active" id="btnID" onclick="setLang('id')">ID</button>
</div>
</div>
<h1 class="fw-bold mb-2"><i class="fas fa-microchip me-2 text-primary"></i><span data-i18n="title">Undertone
Classification Dashboard</span></h1>
<p class="text-secondary" data-i18n="subtitle">Artificial Intelligence System Powered by ResNet50 &
MobileNetV2</p>
</header>
<div class="row g-4">
<div class="col-lg-6">
<div class="glass-card p-4 h-100">
<h5 class="mb-1 fw-bold"><i class="fas fa-camera-retro me-2 text-primary"></i><span
data-i18n="inputTitle">Data Input Source</span></h5>
<p class="text-muted mb-3" style="font-size:.78rem" data-i18n="inputSubtitle">Upload a portrait or
use your live camera</p>
<ul class="nav nav-tabs mb-4" id="inputTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="gallery-tab" data-bs-toggle="tab"
data-bs-target="#galleryTab" type="button" role="tab">
<i class="fas fa-image me-2"></i><span data-i18n="tabUpload">Upload Image</span>
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="camera-tab" data-bs-toggle="tab" data-bs-target="#cameraTab"
type="button" role="tab">
<i class="fas fa-video me-2"></i><span data-i18n="tabCamera">Live Camera</span>
</button>
</li>
</ul>
<div class="tab-content" id="inputTabContent">
<div class="tab-pane fade show active" id="galleryTab" role="tabpanel">
<div class="drop-zone mb-1" id="dropZone">
<input type="file" id="fileInput" accept="image/*" onchange="onFileChange(event)">
<div class="drop-zone-icon"><i class="fas fa-cloud-upload-alt"></i></div>
<div class="drop-zone-text" data-i18n="dropText">Drag & drop or click to browse
</div>
<div class="drop-zone-sub mt-1" data-i18n="dropSub">JPG, PNG, WEBP • Portrait
recommended</div>
</div>
<div id="filePreviewWrap">
<img id="filePreview" src="" alt="Preview">
<button class="preview-remove" onclick="clearFile()" title="Remove"><i
class="fas fa-times"></i></button>
<div id="previewName" class="preview-name"></div>
</div>
<button id="btnGallery" onclick="uploadFile()"
class="btn btn-gradient-primary w-100 py-3 fw-bold mt-3">
<i class="fas fa-search me-2"></i><span data-i18n="btnAnalyze">Analyze Image</span>
</button>
</div>
<div class="tab-pane fade" id="cameraTab" role="tabpanel">
<div class="ratio ratio-4x3 mb-3 overflow-hidden rounded">
<video id="video" autoplay playsinline></video>
</div>
<button id="btnCamera" onclick="captureCamera()"
class="btn btn-gradient-success w-100 py-3 fw-bold">
<i class="fas fa-bolt me-2"></i><span data-i18n="btnCapture">CAPTURE &
PROCESS</span>
</button>
<canvas id="canvas" style="display:none;"></canvas>
</div>
</div>
</div>
</div>
<div class="col-lg-6" id="output-wrapper">
<div id="loadingSpinner" class="glass-card p-5 h-100 d-none loading-overlay">
<div class="spinner-border mb-3" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<h5 class="text-primary" data-i18n="loadingTitle">Processing Image...</h5>
<p class="text-muted small" data-i18n="loadingSub">Running Deep Learning Inference</p>
</div>
<div class="glass-card p-4 d-none" id="resultPanel">
<!-- β Hero: image comparison + badge -->
<div class="mb-4 result-anim">
<!-- Image pair -->
<div class="img-pair mb-3">
<div class="img-slot">
<span class="img-slot-label"><i class="fas fa-image me-1"></i>Original</span>
<img id="originalImg" class="img-thumb" src="" alt="Original image">
</div>
<div class="img-slot">
<span class="img-slot-label"><i class="fas fa-crop-alt me-1"></i>ROI Crop</span>
<img id="cropImg" class="img-thumb" src="" alt="Face ROI crop">
</div>
</div>
<!-- Badge row -->
<div class="d-flex flex-column align-items-start gap-2">
<p class="text-secondary small mb-0"
style="font-size:.72rem;letter-spacing:.08em;text-transform:uppercase"
data-i18n="undertoneLabel">Undertone Detected</p>
<div id="resBadge" class="undertone-badge mb-1">β</div>
<div id="agreepill" class="agree-pill agree-yes">
<i class="fas fa-check-circle"></i> <span id="agreeText">Models agree</span>
</div>
</div>
</div>
<!-- β‘ Model scores side by side -->
<div class="section-divider result-anim"><span><i class="fas fa-chart-bar me-1"></i><span
data-i18n="modelConfidence">Model Confidence</span></span></div>
<div class="scores-grid mb-3 result-anim">
<div class="model-block">
<div class="model-title"><i class="fas fa-brain me-1"></i>ResNet50</div>
<div id="resnetScores"></div>
</div>
<div class="model-block">
<div class="model-title"><i class="fas fa-microchip me-1"></i>MobileNetV2</div>
<div id="mobilenetScores"></div>
</div>
</div>
<!-- β’ Palette recommendation -->
<div class="section-divider result-anim"><span><i class="fas fa-palette me-1"></i><span
data-i18n="colourPalette">Colour Palette</span></span></div>
<div class="model-block result-anim" id="paletteBlock">
<div id="paletteChips" class="d-flex flex-wrap gap-2"></div>
<p id="paletteDesc" class="text-secondary mt-2 mb-0" style="font-size:.78rem"></p>
</div>
</div>
<div id="placeholder" class="glass-card p-4 h-100 d-flex align-items-center justify-content-center">
<div style="max-width:280px;text-align:center">
<div
style="width:64px;height:64px;border-radius:50%;background:var(--primary-pale);display:flex;align-items:center;justify-content:center;margin:0 auto 16px;">
<i class="fas fa-face-smile fa-xl text-primary"></i>
</div>
<h5 class="fw-bold mb-1" style="font-size:1rem" data-i18n="phTitle">Ready for Analysis</h5>
<p class="text-muted mb-4" style="font-size:.78rem" data-i18n="phDesc">Upload a clear portrait
photo or use your camera to detect your skin undertone.</p>
<ul class="step-list">
<li><span class="step-num">1</span><span data-i18n="step1">Choose Upload Image or Live
Camera tab</span></li>
<li><span class="step-num">2</span><span data-i18n="step2">Select or capture a front-facing
portrait</span></li>
<li><span class="step-num">3</span><span data-i18n="step3">Click Analyze β AI detects your
undertone</span></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<footer class="text-center py-4 mt-4 text-muted" style="font-size: 0.85rem;">
© 2026 Afina Putri Dzulqiyana & Dr. Herlawati, S.Si., M.M., M.Kom. All rights reserved.
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
const video = document.getElementById('video');
const canvas = document.getElementById('canvas');
// ββ i18n βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const TRANSLATIONS = {
en: {
title: 'Undertone Classification Dashboard',
subtitle: 'Artificial Intelligence System Powered by ResNet50 & MobileNetV2',
inputTitle: 'Data Input Source',
inputSubtitle: 'Upload a portrait or use your live camera',
tabUpload: 'Upload Image',
tabCamera: 'Live Camera',
dropText: 'Drag & drop or click to browse',
dropSub: 'JPG, PNG, WEBP β’ Portrait recommended',
btnAnalyze: 'Analyze Image',
btnCapture: 'Capture & Analyze',
loadingTitle: 'Processing Image...',
loadingSub: 'Running Deep Learning Inference',
undertoneLabel: 'Undertone Detected',
modelConfidence: 'Model Confidence',
colourPalette: 'Colour Palette',
phTitle: 'Ready for Analysis',
phDesc: 'Upload a clear portrait photo or use your camera to detect your skin undertone.',
step1: 'Choose Upload Image or Live Camera tab',
step2: 'Select or capture a front-facing portrait',
step3: 'Click Analyze β AI detects your undertone',
agreeYes: 'Both models agree',
agreeNo: (r, m) => `ResNet: ${r} Β· MobileNet: ${m}`,
alertNoFile: 'Select an image first',
alertServer: 'Server error',
},
id: {
title: 'Dashboard Klasifikasi Undertone',
subtitle: 'Sistem Kecerdasan Buatan Berbasis ResNet50 & MobileNetV2',
inputTitle: 'Sumber Data Input',
inputSubtitle: 'Unggah foto wajah atau gunakan kamera langsung',
tabUpload: 'Unggah Gambar',
tabCamera: 'Kamera Langsung',
dropText: 'Seret & lepas atau klik untuk memilih',
dropSub: 'JPG, PNG, WEBP β’ Disarankan foto wajah',
btnAnalyze: 'Analisis Gambar',
btnCapture: 'Tangkap & Analisis',
loadingTitle: 'Memproses Gambar...',
loadingSub: 'Menjalankan Inferensi Deep Learning',
undertoneLabel: 'Undertone Terdeteksi',
modelConfidence: 'Kepercayaan Model',
colourPalette: 'Palet Warna',
phTitle: 'Siap untuk Analisis',
phDesc: 'Unggah foto wajah yang jelas atau gunakan kamera untuk mendeteksi undertone kulit Anda.',
step1: 'Pilih tab Unggah Gambar atau Kamera Langsung',
step2: 'Pilih atau ambil foto wajah menghadap ke depan',
step3: 'Klik Analisis β AI mendeteksi undertone Anda',
agreeYes: 'Kedua model setuju',
agreeNo: (r, m) => `ResNet: ${r} Β· MobileNet: ${m}`,
alertNoFile: 'Pilih gambar terlebih dahulu',
alertServer: 'Kesalahan server',
}
};
let currentLang = 'id';
function setLang(lang) {
currentLang = lang;
const t = TRANSLATIONS[lang];
document.querySelectorAll('[data-i18n]').forEach(el => {
const key = el.getAttribute('data-i18n');
if (t[key] && typeof t[key] === 'string') el.textContent = t[key];
});
document.getElementById('btnEN').classList.toggle('active', lang === 'en');
document.getElementById('btnID').classList.toggle('active', lang === 'id');
document.documentElement.lang = lang === 'id' ? 'id' : 'en';
const pDesc = document.getElementById('paletteDesc');
if (pDesc && pDesc.dataset.palette) {
pDesc.textContent = PALETTES[pDesc.dataset.palette].desc[lang];
}
}
// ββ Palette data per undertone ββββββββββββββββββββββββββββββββββββββ
const PALETTES = {
cool: {
swatch: '#818cf8',
ringColor: '#6366f1',
label: 'Cool',
colors: [
{ hex: '#7c3aed', name: 'Violet' },
{ hex: '#2563eb', name: 'Royal Blue' },
{ hex: '#0e7490', name: 'Teal' },
{ hex: '#be185d', name: 'Fuchsia' },
{ hex: '#374151', name: 'Charcoal' },
{ hex: '#e0e7ff', name: 'Lavender' },
{ hex: '#f0fdf4', name: 'Mint White' },
{ hex: '#c7d2fe', name: 'Periwinkle' },
],
desc: {
en: 'Cool undertones suit jewel tones, icy blues, purples & true whites. Avoid yellow-based oranges.',
id: 'Undertone cool (dingin) cocok dengan warna permata, biru es, ungu & putih bersih. Hindari warna oranye berbasis kuning.'
}
},
neutral: {
swatch: '#fb923c',
ringColor: '#f97316',
label: 'Neutral',
colors: [
{ hex: '#92400e', name: 'Caramel' },
{ hex: '#b45309', name: 'Amber' },
{ hex: '#4f46e5', name: 'Indigo' },
{ hex: '#065f46', name: 'Forest Green' },
{ hex: '#be123c', name: 'Rose Red' },
{ hex: '#d4a27f', name: 'Nude Beige' },
{ hex: '#6b7280', name: 'Cool Grey' },
{ hex: '#fef3c7', name: 'Cream' },
],
desc: {
en: 'Neutral undertones are the most versatile β warm & cool tones both work. Earthy nudes and balanced jewels shine.',
id: 'Undertone netral adalah yang paling serbaguna β warna hangat & dingin sama-sama cocok. Warna nude bumi dan permata seimbang terlihat bersinar.'
}
},
warm: {
swatch: '#f59e0b',
ringColor: '#d97706',
label: 'Warm',
colors: [
{ hex: '#b45309', name: 'Golden Brown' },
{ hex: '#c2410c', name: 'Burnt Orange' },
{ hex: '#a16207', name: 'Mustard' },
{ hex: '#166534', name: 'Olive Green' },
{ hex: '#7c2d12', name: 'Terracotta' },
{ hex: '#fde68a', name: 'Warm Yellow' },
{ hex: '#fca5a5', name: 'Peach' },
{ hex: '#f9a8d4', name: 'Coral Pink' },
],
desc: {
en: 'Warm undertones glow in earthy oranges, golds, browns & warm greens. Avoid icy or ashy tones.',
id: 'Undertone warm (hangat) bercahaya dalam warna oranye bumi, emas, cokelat & hijau hangat. Hindari warna es atau keabuan.'
}
}
};
// ββ Drag-drop ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
const dropZone = document.getElementById('dropZone');
dropZone.addEventListener('dragover', e => { e.preventDefault(); dropZone.classList.add('drag-over'); });
dropZone.addEventListener('dragleave', () => dropZone.classList.remove('drag-over'));
dropZone.addEventListener('drop', e => { e.preventDefault(); dropZone.classList.remove('drag-over'); if (e.dataTransfer.files[0]) { document.getElementById('fileInput').files = e.dataTransfer.files; onFileChange({ target: { files: e.dataTransfer.files } }); } });
function onFileChange(e) {
const file = e.target.files[0];
if (!file) return;
const wrap = document.getElementById('filePreviewWrap');
document.getElementById('filePreview').src = URL.createObjectURL(file);
document.getElementById('previewName').textContent = file.name;
wrap.style.display = 'block';
}
function clearFile() {
document.getElementById('fileInput').value = '';
document.getElementById('filePreviewWrap').style.display = 'none';
document.getElementById('filePreview').src = '';
}
// ββ Camera Init βββββββββββββββββββββββββββββββββββββββββββββββββββββ
document.getElementById('camera-tab').addEventListener('shown.bs.tab', () => {
if (!video.srcObject)
navigator.mediaDevices.getUserMedia({ video: true }).then(s => { video.srcObject = s; document.getElementById('camBadge').classList.remove('d-none'); });
});
document.getElementById('gallery-tab').addEventListener('shown.bs.tab', () => {
if (video.srcObject) { video.srcObject.getTracks().forEach(t => t.stop()); video.srcObject = null; document.getElementById('camBadge').classList.add('d-none'); }
});
// ββ Loading toggle ββββββββββββββββββββββββββββββββββββββββββββββββββ
function toggleLoading(show) {
const spinner = document.getElementById('loadingSpinner');
const placeholder = document.getElementById('placeholder');
const resultPanel = document.getElementById('resultPanel');
const btnGallery = document.getElementById('btnGallery');
const btnCamera = document.getElementById('btnCamera');
if (show) {
spinner.classList.remove('d-none');
placeholder.classList.add('d-none');
resultPanel.classList.add('d-none');
btnGallery.disabled = btnCamera.disabled = true;
} else {
spinner.classList.add('d-none');
btnGallery.disabled = btnCamera.disabled = false;
}
}
// ββ Score bars ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
function createScoreUI(scores, containerId) {
const container = document.getElementById(containerId);
container.innerHTML = '';
Object.entries(scores).forEach(([label, score]) => {
const pct = (score * 100).toFixed(1);
const barClass = `bar-${label.toLowerCase()}`;
container.innerHTML += `
<div class="mb-2">
<div class="d-flex justify-content-between align-items-center mb-1">
<span style="font-size:.8rem;font-weight:600;color:#334155">${label}</span>
<span style="font-size:.78rem;font-weight:700;color:#1d4ed8">${pct}%</span>
</div>
<div class="bar-track">
<div class="bar-fill ${barClass}" style="width:0%" data-target="${pct}%"></div>
</div>
</div>`;
});
// Animate bars after paint
requestAnimationFrame(() => requestAnimationFrame(() => {
container.querySelectorAll('.bar-fill').forEach(el => {
el.style.width = el.dataset.target;
});
}));
}
// ββ Main result render ββββββββββββββββββββββββββββββββββββββββββββββ
function handleResponse(data) {
toggleLoading(false);
const resLabel = data.results.resnet.label; // e.g. 'cool'
const mobLabel = data.results.mobilenet.label; // e.g. 'warm'
const agree = resLabel === mobLabel;
const palette = PALETTES[resLabel] || PALETTES['neutral'];
const displayLabel = palette.label; // Title-case: 'Cool'
// Original image
const originalImg = document.getElementById('originalImg');
originalImg.src = data.original_b64;
originalImg.style.boxShadow = `0 0 0 3px ${palette.ringColor}55, 0 4px 16px rgba(0,0,0,.12)`;
// Crop image + ring glow colour
const cropImg = document.getElementById('cropImg');
cropImg.src = data.crop_b64;
cropImg.style.setProperty('--ring-color', palette.ringColor);
cropImg.style.boxShadow = `0 0 0 3px ${palette.ringColor}, 0 0 24px ${palette.ringColor}55`;
// Badge
const badge = document.getElementById('resBadge');
badge.className = `undertone-badge badge-${resLabel}`;
badge.innerHTML = `<span class="swatch" style="background:${palette.swatch}"></span>${displayLabel}`;
// Agreement pill
const pill = document.getElementById('agreepill');
const agreeText = document.getElementById('agreeText');
if (agree) {
pill.className = 'agree-pill agree-yes';
pill.querySelector('i').className = 'fas fa-check-circle';
agreeText.textContent = TRANSLATIONS[currentLang].agreeYes;
} else {
pill.className = 'agree-pill agree-no';
pill.querySelector('i').className = 'fas fa-exclamation-circle';
const mobDisplay = (PALETTES[mobLabel] || PALETTES['neutral']).label;
agreeText.textContent = TRANSLATIONS[currentLang].agreeNo(displayLabel, mobDisplay);
}
// Score bars
createScoreUI(data.results.resnet.scores, 'resnetScores');
createScoreUI(data.results.mobilenet.scores, 'mobilenetScores');
// Palette chips
const chips = document.getElementById('paletteChips');
chips.innerHTML = palette.colors.map(c =>
`<div class="palette-chip" style="background:${c.hex}" title="${c.name}"></div>`
).join('');
const pDesc = document.getElementById('paletteDesc');
const paletteKey = PALETTES[resLabel] ? resLabel : 'neutral';
pDesc.dataset.palette = paletteKey;
pDesc.textContent = palette.desc[currentLang];
document.getElementById('resultPanel').classList.remove('d-none');
}
// ββ Upload ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
async function uploadFile() {
const file = document.getElementById('fileInput').files[0];
if (!file) return alert(TRANSLATIONS[currentLang].alertNoFile);
toggleLoading(true);
const fd = new FormData();
fd.append('file', file);
try {
const res = await fetch('/predict', { method: 'POST', body: fd });
const data = await res.json();
if (res.ok) handleResponse(data);
else { alert(data.error); toggleLoading(false); document.getElementById('placeholder').classList.remove('d-none'); }
} catch { alert(TRANSLATIONS[currentLang].alertServer); toggleLoading(false); }
}
// ββ Camera capture ββββββββββββββββββββββββββββββββββββββββββββββββββ
async function captureCamera() {
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(video, 0, 0);
toggleLoading(true);
try {
const res = await fetch('/predict', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ image: canvas.toDataURL('image/jpeg') })
});
const data = await res.json();
if (res.ok) handleResponse(data);
else { alert(data.error); toggleLoading(false); document.getElementById('placeholder').classList.remove('d-none'); }
} catch { alert(TRANSLATIONS[currentLang].alertServer); toggleLoading(false); }
}
// Set default language on load
document.addEventListener('DOMContentLoaded', () => setLang('id'));
</script>
</body>
</html> |