模型文件路径

This commit is contained in:
good
2026-02-06 02:54:10 -05:00
parent d7dd434fec
commit d3ab9a6d05
2 changed files with 17 additions and 4 deletions
+9 -3
View File
@@ -19,7 +19,10 @@ 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/grid_search_20251204_140816/model_s64.0_m0.4.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):
@@ -94,12 +97,15 @@ 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_20251204_140816/best_embedding_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)
print(f"✓ TorchScript模型保存成功: {output_path}")
# 验证保存的模型
loaded_model = torch.jit.load(output_path)
with torch.no_grad():