From 1a4504e1a901039f250b84569fd6dd03cd5fe504 Mon Sep 17 00:00:00 2001 From: wanghanbo <1411232085@qq.com> Date: Tue, 13 Oct 2026 10:27:00 +0800 Subject: [PATCH] gx --- core/common_classifier.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/common_classifier.py b/core/common_classifier.py index 5f071db..fa785d2 100644 --- a/core/common_classifier.py +++ b/core/common_classifier.py @@ -497,8 +497,8 @@ class PartTemplateManager: def predict_from_feature(self, feat, image_path=None, auto_pending=True): """已有特征时直接匹配(避免待学习提交时重复提特征)。 - 有排餐时:主食小库 ∪ 当前餐段菜品 合并为候选再比对(主食略优先); - 无排餐 / 无今日菜单:全部未知(不进主食、不进大库)。 + 仅在「当前吃饭餐段」内:主食小库 ∪ 当前餐段菜品 合并比对(主食略优先); + 不在餐段 / 无今日排餐:全部未知(不进主食、不进大库)。 均未达标 → 未知,不回退大模板库。 """ if feat is None: @@ -532,7 +532,8 @@ class PartTemplateManager: DISH_STAPLE_PRIORITY_MARGIN, ) 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_names = store.current_period_dish_names() small_thr = float(DISH_MEAL_SMALL_LIB_THRESHOLD) @@ -545,7 +546,7 @@ class PartTemplateManager: period_names = None period_only = False - # ---------- 1) 有排餐:主食 ∪ 当前餐段 合并候选 ---------- + # ---------- 1) 在当前餐段:主食 ∪ 当前餐段 合并候选 ---------- if period_only: staple_names = self.staple_candidate_names() period_set = set(period_names or []) @@ -626,13 +627,13 @@ class PartTemplateManager: "match_scope": "period_miss", } - # ---------- 2) 无今日菜单:不进主食、不进大库,全部未知 ---------- + # ---------- 2) 不在餐段 / 无排餐:不进主食、不进大库,全部未知 ---------- pending_id = None if auto_pending and image_path: pending_id = self.pending_store.add(image_path, feat, None, None) return { - "text": "未知菜品 (无今日菜单,不匹配主食/大库,已记录待学习)", + "text": "未知菜品 (不在当前餐段,不匹配主食/大库,已记录待学习)", "is_unknown": True, "label": None, "score": None,