feat: add emotion timeline to /process_video#20
Open
Aarchi-07 wants to merge 1 commit intoruxailab:mainfrom
Open
feat: add emotion timeline to /process_video#20Aarchi-07 wants to merge 1 commit intoruxailab:mainfrom
Aarchi-07 wants to merge 1 commit intoruxailab:mainfrom
Conversation
0c2de54 to
080a041
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Related: sentiment-analysis-api#14 | RUXAILAB#1227
The
/process_videoendpoint currently returns only a global average of emotions across the entire video. This makes it impossible for the frontend to render timelines or visualize how emotions shift over time.After investigating, the 7-class emotion labels (
Angry, Disgusted, etc.) referenced in sentiment-analysis-api#14 actually originate from this repo, not the audio sentiment API (which produces POS/NEG/NEU). The timeline feature belongs here.Changes
The
/process_videoresponse now includes atimelinearray alongside the existingemotionsobject:{ "emotions": { "Angry": 15.38, "Neutral": 53.85, ... }, "timeline": [ { "id": 1, "starting_time": "00:00", "ending_time": "00:10", "emotion": "NEUTRAL", "value": 87.5 }, { "id": 2, "starting_time": "00:10", "ending_time": "00:20", "emotion": "SAD", "value": 72.3 } ] }What was added
TimelineEntryandEmotionAnalysisResponseschemas inemotion_schema.pyemotion_analysis_imp.py:interval_s=10): groups frames into time windows, picks dominant emotion per windowinterval_s=0): creates a new segment whenever the dominant emotion changesvalueuses actual model prediction confidence (softmax output), averaged across the dominant emotion's frames in each windowinterval_soptional request body param in the route (defaults to 10)Changes
schemas/emotion_schema.pyTimelineEntry,EmotionAnalysisResponseservices/emotion_analysis/emotion_analysis_imp.pyservices/emotion_analysis/emotion_analysis_service.pyroutes/video_routes.pyinterval_sparam, returns full response viamodel_dump()tests/test_timeline.pyBackward compatibility
The
emotionskey is preserved with the exact same structure. Thetimelinekey is purely additive. Existing frontend code that readsres.data.emotionswill continue to work unchanged.