app.py 6
Browse files
app.py
CHANGED
|
@@ -489,12 +489,21 @@ def predict_emotion(video_file):
|
|
| 489 |
|
| 490 |
confidence = float(probs.max())
|
| 491 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 492 |
result_text = f"""
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
"""
|
| 499 |
|
| 500 |
if os.path.exists(audio_path):
|
|
@@ -818,13 +827,12 @@ body::after {
|
|
| 818 |
|
| 819 |
.card-row {
|
| 820 |
font-family: 'Share Tech Mono', monospace;
|
| 821 |
-
font-size:
|
| 822 |
-
color: #
|
| 823 |
line-height: 2.2;
|
| 824 |
display: flex;
|
| 825 |
align-items: center;
|
| 826 |
gap: 10px;
|
| 827 |
-
opacity: 1 !important;
|
| 828 |
}
|
| 829 |
|
| 830 |
.card-dot {
|
|
@@ -872,9 +880,9 @@ body::after {
|
|
| 872 |
|
| 873 |
.arch-desc {
|
| 874 |
font-family: 'Rajdhani', sans-serif;
|
| 875 |
-
font-size:
|
| 876 |
-
color: #
|
| 877 |
-
line-height: 1.
|
| 878 |
margin: 0 0 8px;
|
| 879 |
}
|
| 880 |
|
|
@@ -900,9 +908,8 @@ body::after {
|
|
| 900 |
.arch-detail {
|
| 901 |
font-family: 'Share Tech Mono', monospace;
|
| 902 |
font-size: 13px;
|
| 903 |
-
color: #
|
| 904 |
-
line-height: 1.
|
| 905 |
-
opacity: 1 !important;
|
| 906 |
}
|
| 907 |
|
| 908 |
.emotion-chips {
|
|
@@ -1013,11 +1020,11 @@ div[class*="label"] > span,
|
|
| 1013 |
}
|
| 1014 |
|
| 1015 |
/* =====================================================
|
| 1016 |
-
ANALYZE BUTTON
|
| 1017 |
===================================================== */
|
| 1018 |
.gr-button,
|
| 1019 |
button[class*="primary"],
|
| 1020 |
-
button {
|
| 1021 |
font-family: 'Orbitron', monospace !important;
|
| 1022 |
font-size: 13px !important;
|
| 1023 |
font-weight: 700 !important;
|
|
@@ -1035,7 +1042,8 @@ button {
|
|
| 1035 |
}
|
| 1036 |
|
| 1037 |
.gr-button::before,
|
| 1038 |
-
button::before
|
|
|
|
| 1039 |
content: '' !important;
|
| 1040 |
position: absolute !important;
|
| 1041 |
top: 0; left: -100% !important;
|
|
@@ -1050,12 +1058,14 @@ button::before {
|
|
| 1050 |
}
|
| 1051 |
|
| 1052 |
.gr-button:hover::before,
|
| 1053 |
-
button:hover::before
|
|
|
|
| 1054 |
left: 100% !important;
|
| 1055 |
}
|
| 1056 |
|
| 1057 |
.gr-button:hover,
|
| 1058 |
-
button:hover
|
|
|
|
| 1059 |
background: rgba(0, 245, 255, 0.1) !important;
|
| 1060 |
box-shadow:
|
| 1061 |
0 0 20px rgba(0, 245, 255, 0.4),
|
|
@@ -1065,10 +1075,60 @@ button:hover {
|
|
| 1065 |
}
|
| 1066 |
|
| 1067 |
.gr-button:active,
|
| 1068 |
-
button:active
|
|
|
|
| 1069 |
transform: translateY(0px) !important;
|
| 1070 |
}
|
| 1071 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1072 |
/* =====================================================
|
| 1073 |
INPUT / TEXTAREA
|
| 1074 |
===================================================== */
|
|
@@ -1321,37 +1381,6 @@ hr {
|
|
| 1321 |
.info-grid { grid-template-columns: 1fr; }
|
| 1322 |
.cyber-title { font-size: 26px !important; letter-spacing: 3px !important; }
|
| 1323 |
}
|
| 1324 |
-
|
| 1325 |
-
/* REMOVE GRADIO FOOTER + SETTINGS */
|
| 1326 |
-
|
| 1327 |
-
footer,
|
| 1328 |
-
.settings,
|
| 1329 |
-
button[title="Settings"],
|
| 1330 |
-
button[aria-label="Settings"],
|
| 1331 |
-
.gradio-footer,
|
| 1332 |
-
div[class*="settings"],
|
| 1333 |
-
div[class*="footer"] {
|
| 1334 |
-
display: none !important;
|
| 1335 |
-
}
|
| 1336 |
-
|
| 1337 |
-
/* FIX INVISIBLE VIDEO BUTTON ICONS */
|
| 1338 |
-
|
| 1339 |
-
button svg,
|
| 1340 |
-
button span,
|
| 1341 |
-
button {
|
| 1342 |
-
color: #00f5ff !important;
|
| 1343 |
-
fill: #00f5ff !important;
|
| 1344 |
-
opacity: 1 !important;
|
| 1345 |
-
}
|
| 1346 |
-
|
| 1347 |
-
/* specifically for video action buttons */
|
| 1348 |
-
div[data-testid="video"] button {
|
| 1349 |
-
color: #00f5ff !important;
|
| 1350 |
-
fill: #00f5ff !important;
|
| 1351 |
-
background: #071020 !important;
|
| 1352 |
-
border: 1px solid #00f5ff !important;
|
| 1353 |
-
}
|
| 1354 |
-
|
| 1355 |
"""
|
| 1356 |
|
| 1357 |
# =========================================================
|
|
@@ -1430,7 +1459,7 @@ with gr.Blocks(
|
|
| 1430 |
# LEFT: Upload
|
| 1431 |
with gr.Column(scale=1):
|
| 1432 |
|
| 1433 |
-
gr.Markdown("## INPUT STREAM")
|
| 1434 |
|
| 1435 |
video_input = gr.Video(
|
| 1436 |
label="Video Input",
|
|
@@ -1438,7 +1467,7 @@ with gr.Blocks(
|
|
| 1438 |
)
|
| 1439 |
|
| 1440 |
predict_btn = gr.Button(
|
| 1441 |
-
"
|
| 1442 |
variant="primary",
|
| 1443 |
size="lg"
|
| 1444 |
)
|
|
@@ -1446,7 +1475,7 @@ with gr.Blocks(
|
|
| 1446 |
# RIGHT: Results
|
| 1447 |
with gr.Column(scale=1):
|
| 1448 |
|
| 1449 |
-
gr.Markdown("## ANALYSIS OUTPUT")
|
| 1450 |
|
| 1451 |
result_text = gr.Markdown(
|
| 1452 |
value="""
|
|
@@ -1460,7 +1489,7 @@ with gr.Blocks(
|
|
| 1460 |
)
|
| 1461 |
|
| 1462 |
transcription_output = gr.Textbox(
|
| 1463 |
-
label="Transcribed Speech",
|
| 1464 |
lines=5,
|
| 1465 |
interactive=False,
|
| 1466 |
placeholder="Speech transcription will appear here after analysis..."
|
|
@@ -1469,7 +1498,7 @@ with gr.Blocks(
|
|
| 1469 |
gr.HTML('<hr/>')
|
| 1470 |
|
| 1471 |
# ββ About Accordion βββββββββββββββββββββββββββββββββ
|
| 1472 |
-
with gr.Accordion("SYSTEM ARCHITECTURE", open=False):
|
| 1473 |
|
| 1474 |
gr.HTML("""
|
| 1475 |
<div class="arch-grid">
|
|
|
|
| 489 |
|
| 490 |
confidence = float(probs.max())
|
| 491 |
|
| 492 |
+
emotion_icons = {
|
| 493 |
+
"angry": "β‘",
|
| 494 |
+
"happy": "β",
|
| 495 |
+
"neutral": "β",
|
| 496 |
+
"sad": "β"
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
icon = emotion_icons.get(predicted_emotion, "β")
|
| 500 |
+
|
| 501 |
result_text = f"""
|
| 502 |
+
## {icon} EMOTION DETECTED
|
| 503 |
+
|
| 504 |
+
### `{predicted_emotion.upper()}`
|
| 505 |
+
|
| 506 |
+
**Neural Confidence:** `{confidence:.2%}`
|
| 507 |
"""
|
| 508 |
|
| 509 |
if os.path.exists(audio_path):
|
|
|
|
| 827 |
|
| 828 |
.card-row {
|
| 829 |
font-family: 'Share Tech Mono', monospace;
|
| 830 |
+
font-size: 13px;
|
| 831 |
+
color: #d8f0ff;
|
| 832 |
line-height: 2.2;
|
| 833 |
display: flex;
|
| 834 |
align-items: center;
|
| 835 |
gap: 10px;
|
|
|
|
| 836 |
}
|
| 837 |
|
| 838 |
.card-dot {
|
|
|
|
| 880 |
|
| 881 |
.arch-desc {
|
| 882 |
font-family: 'Rajdhani', sans-serif;
|
| 883 |
+
font-size: 14px;
|
| 884 |
+
color: #a0c8d8;
|
| 885 |
+
line-height: 1.6;
|
| 886 |
margin: 0 0 8px;
|
| 887 |
}
|
| 888 |
|
|
|
|
| 908 |
.arch-detail {
|
| 909 |
font-family: 'Share Tech Mono', monospace;
|
| 910 |
font-size: 13px;
|
| 911 |
+
color: #d0e8f0;
|
| 912 |
+
line-height: 1.6;
|
|
|
|
| 913 |
}
|
| 914 |
|
| 915 |
.emotion-chips {
|
|
|
|
| 1020 |
}
|
| 1021 |
|
| 1022 |
/* =====================================================
|
| 1023 |
+
ANALYZE BUTTON (main action buttons only)
|
| 1024 |
===================================================== */
|
| 1025 |
.gr-button,
|
| 1026 |
button[class*="primary"],
|
| 1027 |
+
button[class*="lg"] {
|
| 1028 |
font-family: 'Orbitron', monospace !important;
|
| 1029 |
font-size: 13px !important;
|
| 1030 |
font-weight: 700 !important;
|
|
|
|
| 1042 |
}
|
| 1043 |
|
| 1044 |
.gr-button::before,
|
| 1045 |
+
button[class*="primary"]::before,
|
| 1046 |
+
button[class*="lg"]::before {
|
| 1047 |
content: '' !important;
|
| 1048 |
position: absolute !important;
|
| 1049 |
top: 0; left: -100% !important;
|
|
|
|
| 1058 |
}
|
| 1059 |
|
| 1060 |
.gr-button:hover::before,
|
| 1061 |
+
button[class*="primary"]:hover::before,
|
| 1062 |
+
button[class*="lg"]:hover::before {
|
| 1063 |
left: 100% !important;
|
| 1064 |
}
|
| 1065 |
|
| 1066 |
.gr-button:hover,
|
| 1067 |
+
button[class*="primary"]:hover,
|
| 1068 |
+
button[class*="lg"]:hover {
|
| 1069 |
background: rgba(0, 245, 255, 0.1) !important;
|
| 1070 |
box-shadow:
|
| 1071 |
0 0 20px rgba(0, 245, 255, 0.4),
|
|
|
|
| 1075 |
}
|
| 1076 |
|
| 1077 |
.gr-button:active,
|
| 1078 |
+
button[class*="primary"]:active,
|
| 1079 |
+
button[class*="lg"]:active {
|
| 1080 |
transform: translateY(0px) !important;
|
| 1081 |
}
|
| 1082 |
|
| 1083 |
+
/* =====================================================
|
| 1084 |
+
VIDEO UPLOAD / RECORD TAB BUTTONS
|
| 1085 |
+
===================================================== */
|
| 1086 |
+
/* Target the small tab-style buttons under the video component */
|
| 1087 |
+
button[class*="tab"],
|
| 1088 |
+
div[class*="upload"] button,
|
| 1089 |
+
div[class*="source"] button,
|
| 1090 |
+
.source-selection button,
|
| 1091 |
+
div[data-testid*="source"] button,
|
| 1092 |
+
div[class*="wrap"] > div > button:not([class*="lg"]):not([class*="primary"]) {
|
| 1093 |
+
font-family: 'Share Tech Mono', monospace !important;
|
| 1094 |
+
font-size: 11px !important;
|
| 1095 |
+
font-weight: 600 !important;
|
| 1096 |
+
letter-spacing: 2px !important;
|
| 1097 |
+
text-transform: uppercase !important;
|
| 1098 |
+
background: rgba(0, 245, 255, 0.06) !important;
|
| 1099 |
+
border: 1px solid rgba(0, 245, 255, 0.3) !important;
|
| 1100 |
+
color: #a0dce8 !important;
|
| 1101 |
+
border-radius: 3px !important;
|
| 1102 |
+
padding: 6px 16px !important;
|
| 1103 |
+
transition: all 0.25s ease !important;
|
| 1104 |
+
cursor: pointer !important;
|
| 1105 |
+
position: relative !important;
|
| 1106 |
+
overflow: visible !important;
|
| 1107 |
+
}
|
| 1108 |
+
|
| 1109 |
+
button[class*="tab"]:hover,
|
| 1110 |
+
div[class*="upload"] button:hover,
|
| 1111 |
+
div[class*="source"] button:hover,
|
| 1112 |
+
.source-selection button:hover,
|
| 1113 |
+
div[data-testid*="source"] button:hover,
|
| 1114 |
+
div[class*="wrap"] > div > button:not([class*="lg"]):not([class*="primary"]):hover {
|
| 1115 |
+
background: rgba(0, 245, 255, 0.14) !important;
|
| 1116 |
+
border-color: var(--neon-cyan) !important;
|
| 1117 |
+
color: #ffffff !important;
|
| 1118 |
+
transform: none !important;
|
| 1119 |
+
box-shadow: 0 0 10px rgba(0, 245, 255, 0.2) !important;
|
| 1120 |
+
}
|
| 1121 |
+
|
| 1122 |
+
/* Active / selected tab */
|
| 1123 |
+
button[class*="tab"][class*="selected"],
|
| 1124 |
+
button[class*="tab"].selected,
|
| 1125 |
+
button[aria-selected="true"] {
|
| 1126 |
+
background: rgba(0, 245, 255, 0.15) !important;
|
| 1127 |
+
border-color: var(--neon-cyan) !important;
|
| 1128 |
+
color: #00f5ff !important;
|
| 1129 |
+
box-shadow: 0 0 12px rgba(0, 245, 255, 0.25) !important;
|
| 1130 |
+
}
|
| 1131 |
+
|
| 1132 |
/* =====================================================
|
| 1133 |
INPUT / TEXTAREA
|
| 1134 |
===================================================== */
|
|
|
|
| 1381 |
.info-grid { grid-template-columns: 1fr; }
|
| 1382 |
.cyber-title { font-size: 26px !important; letter-spacing: 3px !important; }
|
| 1383 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1384 |
"""
|
| 1385 |
|
| 1386 |
# =========================================================
|
|
|
|
| 1459 |
# LEFT: Upload
|
| 1460 |
with gr.Column(scale=1):
|
| 1461 |
|
| 1462 |
+
gr.Markdown("## β§ INPUT STREAM")
|
| 1463 |
|
| 1464 |
video_input = gr.Video(
|
| 1465 |
label="Video Input",
|
|
|
|
| 1467 |
)
|
| 1468 |
|
| 1469 |
predict_btn = gr.Button(
|
| 1470 |
+
"⬑ INITIALIZE ANALYSIS",
|
| 1471 |
variant="primary",
|
| 1472 |
size="lg"
|
| 1473 |
)
|
|
|
|
| 1475 |
# RIGHT: Results
|
| 1476 |
with gr.Column(scale=1):
|
| 1477 |
|
| 1478 |
+
gr.Markdown("## β¨ ANALYSIS OUTPUT")
|
| 1479 |
|
| 1480 |
result_text = gr.Markdown(
|
| 1481 |
value="""
|
|
|
|
| 1489 |
)
|
| 1490 |
|
| 1491 |
transcription_output = gr.Textbox(
|
| 1492 |
+
label="β Transcribed Speech",
|
| 1493 |
lines=5,
|
| 1494 |
interactive=False,
|
| 1495 |
placeholder="Speech transcription will appear here after analysis..."
|
|
|
|
| 1498 |
gr.HTML('<hr/>')
|
| 1499 |
|
| 1500 |
# ββ About Accordion βββββββββββββββββββββββββββββββββ
|
| 1501 |
+
with gr.Accordion("β SYSTEM ARCHITECTURE", open=False):
|
| 1502 |
|
| 1503 |
gr.HTML("""
|
| 1504 |
<div class="arch-grid">
|