This commit is contained in:
wanghanbo 2026-10-13 10:27:00 +08:00
parent 3dbfcfd388
commit 1a4504e1a9
1 changed files with 7 additions and 6 deletions

View File

@ -497,8 +497,8 @@ class PartTemplateManager:
def predict_from_feature(self, feat, image_path=None, auto_pending=True): def predict_from_feature(self, feat, image_path=None, auto_pending=True):
"""已有特征时直接匹配(避免待学习提交时重复提特征)。 """已有特征时直接匹配(避免待学习提交时重复提特征)。
有排餐时:主食小库 ∪ 当前餐段菜品 合并为候选再比对(主食略优先); 仅在「当前吃饭餐段」内:主食小库 ∪ 当前餐段菜品 合并比对(主食略优先);
无排餐 / 无今日菜单:全部未知(不进主食、不进大库)。 不在餐段 / 无今日排餐:全部未知(不进主食、不进大库)。
均未达标 → 未知,不回退大模板库。 均未达标 → 未知,不回退大模板库。
""" """
if feat is None: if feat is None:
@ -532,7 +532,8 @@ class PartTemplateManager:
DISH_STAPLE_PRIORITY_MARGIN, DISH_STAPLE_PRIORITY_MARGIN,
) )
store = get_meal_schedule_store() store = get_meal_schedule_store()
if store.should_use_small_library(): # 必须「在当前餐段时间」才识别;有今日排餐但不在餐段 → 仍全部未知
if store.should_use_small_library() and store.current_period():
period_only = True period_only = True
period_names = store.current_period_dish_names() period_names = store.current_period_dish_names()
small_thr = float(DISH_MEAL_SMALL_LIB_THRESHOLD) small_thr = float(DISH_MEAL_SMALL_LIB_THRESHOLD)
@ -545,7 +546,7 @@ class PartTemplateManager:
period_names = None period_names = None
period_only = False period_only = False
# ---------- 1) 有排餐:主食 ∪ 当前餐段 合并候选 ---------- # ---------- 1) 在当前餐段:主食 ∪ 当前餐段 合并候选 ----------
if period_only: if period_only:
staple_names = self.staple_candidate_names() staple_names = self.staple_candidate_names()
period_set = set(period_names or []) period_set = set(period_names or [])
@ -626,13 +627,13 @@ class PartTemplateManager:
"match_scope": "period_miss", "match_scope": "period_miss",
} }
# ---------- 2) 无今日菜单:不进主食、不进大库,全部未知 ---------- # ---------- 2) 不在餐段 / 无排餐:不进主食、不进大库,全部未知 ----------
pending_id = None pending_id = None
if auto_pending and image_path: if auto_pending and image_path:
pending_id = self.pending_store.add(image_path, feat, None, None) pending_id = self.pending_store.add(image_path, feat, None, None)
return { return {
"text": "未知菜品 (无今日菜单,不匹配主食/大库,已记录待学习)", "text": "未知菜品 (不在当前餐段,不匹配主食/大库,已记录待学习)",
"is_unknown": True, "is_unknown": True,
"label": None, "label": None,
"score": None, "score": None,