Spaces:
Build error
Build error
Kevin King commited on
Commit ·
ca7a908
1
Parent(s): 0dcbb44
REFAC: Enhance UI layout for video analysis results and improve logging configuration in Streamlit app
Browse files- src/streamlit_app.py +7 -6
src/streamlit_app.py
CHANGED
|
@@ -29,11 +29,7 @@ st.title("AffectLink: Post-Hoc Emotion Analysis")
|
|
| 29 |
st.write("Upload a short video clip (under 30 seconds) to see a multimodal emotion analysis.")
|
| 30 |
|
| 31 |
# --- Logger Configuration ---
|
| 32 |
-
# [Logger setup remains the same]
|
| 33 |
logging.basicConfig(level=logging.INFO)
|
| 34 |
-
logging.getLogger('deepface').setLevel(logging.ERROR)
|
| 35 |
-
logging.getLogger('huggingface_hub').setLevel(logging.WARNING)
|
| 36 |
-
logging.getLogger('moviepy').setLevel(logging.ERROR)
|
| 37 |
|
| 38 |
# --- Emotion Mappings ---
|
| 39 |
UNIFIED_EMOTIONS = ['angry', 'happy', 'sad', 'neutral']
|
|
@@ -77,7 +73,6 @@ uploaded_file = st.file_uploader("Choose a video file...", type=["mp4", "mov", "
|
|
| 77 |
|
| 78 |
if uploaded_file is not None:
|
| 79 |
temp_video_path = None
|
| 80 |
-
video_clip_for_duration = None
|
| 81 |
try:
|
| 82 |
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as tfile:
|
| 83 |
tfile.write(uploaded_file.read())
|
|
@@ -165,11 +160,17 @@ if uploaded_file is not None:
|
|
| 165 |
|
| 166 |
similarities = [cosine_similarity([fer_vector], [text_vector])[0][0], cosine_similarity([fer_vector], [ser_vector])[0][0], cosine_similarity([ser_vector], [text_vector])[0][0]]
|
| 167 |
avg_similarity = np.nanmean([s for s in similarities if not np.isnan(s)])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
|
|
|
| 169 |
col1, col2 = st.columns([1, 2])
|
| 170 |
with col1:
|
| 171 |
st.subheader("Multimodal Summary")
|
| 172 |
-
st.write(f"**Transcription:** \"{full_transcription}\"")
|
| 173 |
st.metric("Dominant Facial Emotion", dominant_fer)
|
| 174 |
st.metric("Dominant Text Emotion", dominant_text)
|
| 175 |
st.metric("Dominant Speech Emotion", dominant_ser)
|
|
|
|
| 29 |
st.write("Upload a short video clip (under 30 seconds) to see a multimodal emotion analysis.")
|
| 30 |
|
| 31 |
# --- Logger Configuration ---
|
|
|
|
| 32 |
logging.basicConfig(level=logging.INFO)
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
# --- Emotion Mappings ---
|
| 35 |
UNIFIED_EMOTIONS = ['angry', 'happy', 'sad', 'neutral']
|
|
|
|
| 73 |
|
| 74 |
if uploaded_file is not None:
|
| 75 |
temp_video_path = None
|
|
|
|
| 76 |
try:
|
| 77 |
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as tfile:
|
| 78 |
tfile.write(uploaded_file.read())
|
|
|
|
| 160 |
|
| 161 |
similarities = [cosine_similarity([fer_vector], [text_vector])[0][0], cosine_similarity([fer_vector], [ser_vector])[0][0], cosine_similarity([ser_vector], [text_vector])[0][0]]
|
| 162 |
avg_similarity = np.nanmean([s for s in similarities if not np.isnan(s)])
|
| 163 |
+
|
| 164 |
+
# --- NEW LAYOUT ---
|
| 165 |
+
# Display the full-width transcription first
|
| 166 |
+
st.subheader("Transcription")
|
| 167 |
+
st.markdown(f"> *{full_transcription}*")
|
| 168 |
+
st.divider()
|
| 169 |
|
| 170 |
+
# Now create two columns for the summary and the plot
|
| 171 |
col1, col2 = st.columns([1, 2])
|
| 172 |
with col1:
|
| 173 |
st.subheader("Multimodal Summary")
|
|
|
|
| 174 |
st.metric("Dominant Facial Emotion", dominant_fer)
|
| 175 |
st.metric("Dominant Text Emotion", dominant_text)
|
| 176 |
st.metric("Dominant Speech Emotion", dominant_ser)
|