对于类别中样本超过30个的采用K-Means算法截取前30个,存入向量数据库

This commit is contained in:
2026-03-03 17:07:06 +08:00
parent 8a50e2973b
commit dedf72f53c
4 changed files with 120 additions and 32 deletions
+4 -6
View File
@@ -19,10 +19,8 @@ def main():
base_model = create_mobile_resnet50_embedding(embedding_dim=512, pretrained=True)
# model_path = "../model/DishClassification/grid_search_20251121_102723/model_s56.0_m0.4.pth"
# model_path = "../model/WholeIngredientRecognition/cosface_20251106_134718/best_cosface_model.pth"
#原本路径,原本模型
#model_path = "../model/WholeIngredientRecognition/grid_search_20251204_140816/model_s64.0_m0.4.pth"
#新路径,新模型 (模型不可用)
model_path = "../model/WholeIngredientRecognition/cosface_20260121_133207/best_cosface_model.pth"
model_path = "../model/WholeIngredientRecognition/grid_search_20260302_182102/best_model_s60.0_m0.42.pth"
# model_path = "../model/WholeIngredientRecognition/cosface_20260121_133207/best_cosface_model.pth"
# model_path = "../model/ProcessedIngredientRecognition/embedding_20251029_173607/best_embedding_model.pth"
if not os.path.exists(model_path):
@@ -98,9 +96,9 @@ def main():
# 保存模型,一定不要乱改,防止模型覆盖!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# output_path = "../model/DishClassification/grid_search_20251121_102723/best_embedding_model_mobile.pt"
#原本路径
#output_path = "../model/WholeIngredientRecognition/grid_search_20251204_140816/best_embedding_model_mobile.pt"
output_path = "../model/WholeIngredientRecognition/grid_search_20260302_182102/best_embedding_model_mobile.pt"
#新路径
output_path = "../model/WholeIngredientRecognition/cosface_20260121_133207/best_cosface_model_mobile.pt"
# output_path = "../model/WholeIngredientRecognition/cosface_20260121_133207/best_cosface_model_mobile.pt"
# output_path = "../model/WholeIngredientRecognition/cosface_20251106_134718/best_embedding_model_mobile.pt"
# output_path = "../model/ProcessedIngredientRecognition/embedding_20251029_173607/best_embedding_model_mobile.pt"
traced_model.save(output_path)