Rthur2003 commited on
Commit
e18d9f7
·
1 Parent(s): ba5cc97

feat: enhance score fusion confidence range and adjust CLAP weight for improved accuracy

Browse files
app/routes/analyze.py CHANGED
@@ -13,10 +13,12 @@ Pipeline:
13
 
14
  from __future__ import annotations
15
 
 
16
  import io
17
  import time
18
  import uuid
19
  from collections import defaultdict
 
20
  from typing import Optional, List, Dict, Any, Literal
21
  from fastapi import (
22
  APIRouter, File, UploadFile, Form,
@@ -83,6 +85,9 @@ clap_service = CLAPDetectorService()
83
  fst_service = FSTClientService()
84
  xai_service = get_xai_service()
85
 
 
 
 
86
 
87
  # ============================================
88
  # Response Models - Platform Uyumlu
 
13
 
14
  from __future__ import annotations
15
 
16
+ import asyncio
17
  import io
18
  import time
19
  import uuid
20
  from collections import defaultdict
21
+ from concurrent.futures import ThreadPoolExecutor
22
  from typing import Optional, List, Dict, Any, Literal
23
  from fastapi import (
24
  APIRouter, File, UploadFile, Form,
 
85
  fst_service = FSTClientService()
86
  xai_service = get_xai_service()
87
 
88
+ # Thread pool for CPU-bound audio analysis (feature extraction + vocal)
89
+ _analysis_pool = ThreadPoolExecutor(max_workers=3)
90
+
91
 
92
  # ============================================
93
  # Response Models - Platform Uyumlu
app/services/score_fusion.py CHANGED
@@ -25,7 +25,7 @@ class FusionResult:
25
  """Final fused detection result."""
26
 
27
  is_ai_generated: bool
28
- confidence: float # 0.51 – 0.97
29
  decision_source: str # "auris_fusion"
30
  model_version: str # "auris-v1-fusion"
31
 
@@ -254,9 +254,10 @@ def _fuse(
254
  # Layer 1 — always present
255
  scores.append((local, 0.40, "auris_local"))
256
 
257
- # Layer 2 — CLAP embeddings
258
  if clap and clap.available:
259
- scores.append((clap.confidence, 0.20, "clap"))
 
260
 
261
  # Layer 3 — FST external (highest individual accuracy)
262
  if fst and fst.available:
 
25
  """Final fused detection result."""
26
 
27
  is_ai_generated: bool
28
+ confidence: float # 0.03 – 0.97
29
  decision_source: str # "auris_fusion"
30
  model_version: str # "auris-v1-fusion"
31
 
 
254
  # Layer 1 — always present
255
  scores.append((local, 0.40, "auris_local"))
256
 
257
+ # Layer 2 — CLAP embeddings (reduced weight if heuristic fallback)
258
  if clap and clap.available:
259
+ clap_weight = 0.20 if clap.classifier_used == "clap_embedding" else 0.08
260
+ scores.append((clap.confidence, clap_weight, "clap"))
261
 
262
  # Layer 3 — FST external (highest individual accuracy)
263
  if fst and fst.available: