kairunwen commited on
Commit
2c2ef94
·
1 Parent(s): d0cb6f1
Files changed (1) hide show
  1. app.py +23 -3
app.py CHANGED
@@ -25,11 +25,31 @@ model_repo = "kairunwen/LSM" # Replace with the actual repository name
25
  model_filename = "checkpoint-40.pth" # Model filename
26
 
27
  # Download model from HuggingFace
28
- model_path = hf_hub_download(repo_id=model_repo, filename=model_filename)
29
 
30
  # Load model
31
- model = LSM_MASt3R.from_pretrained(model_path)
32
- model = model.eval()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
 
35
  @spaces.GPU(duration=80)
 
25
  model_filename = "checkpoint-40.pth" # Model filename
26
 
27
  # Download model from HuggingFace
28
+ # model_path = hf_hub_download(repo_id=model_repo, filename=model_filename)
29
 
30
  # Load model
31
+ # model = LSM_MASt3R.from_pretrained(model_path)
32
+ # model = model.eval()
33
+
34
+
35
+ try:
36
+ # 下载模型文件
37
+ model_path = hf_hub_download(repo_id=model_repo, filename=model_filename)
38
+ print(f"模型文件已下载到: {model_path}")
39
+
40
+ # 加载模型
41
+ model = LSM_MASt3R.from_pretrained(model_path, device='cuda')
42
+ model = model.eval()
43
+ print("模型加载成功并设置为评估模式!")
44
+
45
+ except FileNotFoundError:
46
+ print(f"错误: 无法找到文件 {model_filename},请检查仓库 {model_repo} 是否正确上传文件。")
47
+ except KeyError as e:
48
+ print(f"错误: 检查点文件格式不正确,缺少键 {e}。请确认 checkpoint-40.pth 包含 'args' 和 'model'。")
49
+ except Exception as e:
50
+ print(f"发生未知错误: {e}")
51
+
52
+
53
 
54
 
55
  @spaces.GPU(duration=80)