-
Notifications
You must be signed in to change notification settings - Fork 0
fix : 시연 전후 수정사항들 반영 #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -299,7 +299,7 @@ async def _send_to_chatbot( | |||||||||
| raise InternalServerException("CHATBOT_API_URL not configured") | ||||||||||
|
|
||||||||||
| try: | ||||||||||
|
||||||||||
| try: | |
| try: | |
| # Increased timeout to 60s due to observed latency with the external chatbot API. | |
| # Consider monitoring response times and reviewing this value if performance issues persist. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -201,7 +201,7 @@ def apply_zero_prob_mask( | |
|
|
||
| def fuse_VA(audio_probs: Dict[str, float], text_score: float, text_magnitude: float) -> Dict[str, object]: | ||
| """Fuse audio (emotion probabilities) and text (score,magnitude) into composite VA. | ||
|
|
||
| Returns dict with keys: | ||
| - V_final, A_final, intensity, V_audio, A_audio, V_text, A_text, alpha, beta (float) | ||
| - per_emotion_bps (dict[str,int], sum=10000), top_emotion (str), top_confidence_bps (int) | ||
|
|
@@ -273,6 +273,22 @@ def fuse_VA(audio_probs: Dict[str, float], text_score: float, text_magnitude: fl | |
| t_sc = float(text_emotion_weight.get(emo, 0.0)) | ||
| composite_score[emo] = alpha_prob * a_sc + beta_prob * t_sc | ||
|
|
||
| # Audio에서 분노 비율이 매우 낮은 경우(angry_bps <= 2000 → angry_prob <= 0.2), | ||
| # voice_composite에서 분노가 과도하게 top으로 나오는 것을 방지하기 위해 | ||
| # audio angry 정보의 최종 기여도를 완만하게 줄인다. | ||
| try: | ||
| angry_p = float(audio_probs.get("angry", 0.0)) | ||
| if angry_p <= 0.2: | ||
| neg = max(0.0, -float(v_text)) | ||
| mag = max(0.0, min(1.0, float(a_text))) | ||
| base_factor = 0.7 | ||
| extra_down = 0.15 * neg * mag # 최대 약 0.15 추가 감쇠 | ||
| factor = max(0.5, base_factor - extra_down) # 최소 0.5배까지 | ||
| composite_score["angry"] = composite_score.get("angry", 0.0) * factor | ||
| except Exception: | ||
| # 로직 실패 시에는 안전하게 무시 | ||
| pass | ||
|
Comment on lines
+288
to
+290
|
||
|
|
||
| # 감정별 가중치 조정: neutral은 더 강하게 억제(긍정일수록 추가 억제) | ||
| neutral_base_factor = 0.6 | ||
| if v_text > 0: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -454,7 +454,14 @@ def to_bps(v: float) -> int: | |
| sad = to_bps(probs.get("sad", probs.get("sadness", 0))) | ||
| neutral = to_bps(probs.get("neutral", 0)) | ||
| angry = to_bps(probs.get("angry", probs.get("anger", 0))) | ||
| fear = to_bps(probs.get("fear", probs.get("fearful", 0))) | ||
| # fear_bps 컬럼에는 'fear' + 'anxiety' 계열을 모두 합산해서 저장한다. | ||
| # emotion_service에서 "불안"은 anxiety, "두려움/공포"는 fear 로 매핑되므로 둘을 같은 버킷으로 취급. | ||
| fear_prob = ( | ||
| float(probs.get("fear", 0) or 0) | ||
| + float(probs.get("anxiety", 0) or 0) | ||
| + float(probs.get("fearful", 0) or 0) | ||
| ) | ||
| fear = to_bps(fear_prob) | ||
|
Comment on lines
+459
to
+464
|
||
| surprise = to_bps(probs.get("surprise", probs.get("surprised", 0))) | ||
|
|
||
| # 모델 응답 키 보정: emotion_service는 기본적으로 "emotion"을 반환 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the issue in
voice_service.py, this fear/anxiety aggregation could produce probabilities exceeding 1.0. If bothfearandanxietyprobabilities are present and sum to more than 1.0, this creates an invalid probability distribution.Consider capping the aggregated value:
This ensures the aggregated probability stays within valid bounds before BPS conversion.