- 以 ConsumableVisionAlgorithmService 替代 consumable_classifier 与 tear_action; 可选手部检测权重,未配置时全帧分类;时间窗众数与 Excel 白名单配置。 - 语音待确认:ASR 先匹配 pending topk,再匹配本台 candidate_consumables; 记账 item_id 与 vision 一致使用 name_to_code。 - 更新 config、Compose、.env.example、依赖(pandas/openpyxl)与测试。 Made-with: Cursor
22 lines
784 B
Python
22 lines
784 B
Python
from app.services.consumable_vision_algorithm import PredictionCandidate
|
|
from app.services.video.session_manager import _rank_topk_for_candidates
|
|
|
|
|
|
def test_rank_respects_candidate_order() -> None:
|
|
topk = [
|
|
PredictionCandidate(label="缝线", confidence=0.9),
|
|
PredictionCandidate(label="纱布", confidence=0.5),
|
|
]
|
|
ordered = ["纱布", "缝线"]
|
|
ranked = _rank_topk_for_candidates(topk, ordered)
|
|
assert [c.label for c in ranked] == ["纱布", "缝线"]
|
|
|
|
|
|
def test_rank_without_candidates_keeps_model_order() -> None:
|
|
topk = [
|
|
PredictionCandidate(label="a", confidence=0.9),
|
|
PredictionCandidate(label="b", confidence=0.5),
|
|
]
|
|
ranked = _rank_topk_for_candidates(topk, [])
|
|
assert [c.label for c in ranked] == ["a", "b"]
|