Hanxiaofeng123 commited on
Commit
aa9bc90
·
verified ·
1 Parent(s): 317de70

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -38
app.py CHANGED
@@ -1,41 +1,3 @@
1
- import os
2
- import requests
3
-
4
- def download_model():
5
- model_path = "checkpoint/final_model_K_30.pth"
6
-
7
- # 检查并修复目录权限问题
8
- try:
9
- os.makedirs("checkpoint", exist_ok=True)
10
- except PermissionError:
11
- print("无法创建目录,尝试使用当前目录")
12
- model_path = "final_model_K_30.pth" # 直接下载到当前目录
13
-
14
- if not os.path.exists(model_path):
15
- print("下载模型文件...")
16
- try:
17
- url = "https://huggingface.co/spaces/Hanxiaofeng123/Deepcube/resolve/main/checkpoint/final_model_K_30.pth"
18
-
19
- response = requests.get(url, stream=True, timeout=60)
20
- response.raise_for_status()
21
-
22
- # 直接下载到文件
23
- with open(model_path, 'wb') as f:
24
- for data in response.iter_content(8192):
25
- f.write(data)
26
-
27
- print(f"下载完成: {model_path}")
28
- return True
29
-
30
- except Exception as e:
31
- print(f"下载失败: {e}")
32
- return False
33
- else:
34
- print("模型文件已存在")
35
- return True
36
-
37
- download_model()
38
-
39
  import flask
40
  from flask import request, jsonify
41
  import torch
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import flask
2
  from flask import request, jsonify
3
  import torch