修复新增菜品不更新的问题
This commit is contained in:
@@ -4,3 +4,4 @@
|
||||
/faiss_vector_db/demo_faiss_index/
|
||||
/faiss_vector_db/faiss_index/
|
||||
/faiss_vector_db/faiss_index092901/
|
||||
/faiss_vector_db/faiss_index101001/
|
||||
|
||||
@@ -739,7 +739,9 @@ class EmbeddingFoodClassifierApp:
|
||||
def save_updated_index(self):
|
||||
"""保存更新后的索引和元数据"""
|
||||
try:
|
||||
index_dir = "../faiss_vector_db/faiss_index"
|
||||
# 与加载阶段保持一致:使用当前文件目录作为基准,组合索引目录的绝对路径
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
index_dir = os.path.join(BASE_DIR, "../faiss_vector_db/faiss_index")
|
||||
|
||||
# 保存FAISS索引
|
||||
index_path = os.path.join(index_dir, 'faiss_index.bin')
|
||||
@@ -791,11 +793,8 @@ class EmbeddingFoodClassifierApp:
|
||||
self.new_class_name.set("")
|
||||
self.class_dropdown.set("")
|
||||
|
||||
# 更新类别下拉框(如果有新类别)
|
||||
if target_class not in self.class_dropdown.cget("values"):
|
||||
current_values = list(self.class_dropdown.cget("values"))
|
||||
current_values.append(target_class)
|
||||
self.class_dropdown.configure(values=current_values)
|
||||
# 更新类别下拉框:统一以当前 self.class_names 列表刷新
|
||||
self.class_dropdown.configure(values=self.class_names)
|
||||
|
||||
self.update_add_button_state()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user