Spaces:
Runtime error
Runtime error
Update flask_api_full_song.py
Browse files- flask_api_full_song.py +7 -6
flask_api_full_song.py
CHANGED
|
@@ -8,6 +8,8 @@ from inference import infer_tool, slicer
|
|
| 8 |
|
| 9 |
import requests
|
| 10 |
import os
|
|
|
|
|
|
|
| 11 |
|
| 12 |
app = Flask(__name__)
|
| 13 |
|
|
@@ -56,7 +58,6 @@ if __name__ == '__main__':
|
|
| 56 |
secret_key = os.getenv('SECRET_KEY')
|
| 57 |
region = 'na-siliconvalley'
|
| 58 |
bucket_name = 'xiaohei-cat-ai-1304646510'
|
| 59 |
-
cos_path = '你要下载的文件在COS中的路径'
|
| 60 |
|
| 61 |
config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key)
|
| 62 |
client = CosS3Client(config)
|
|
@@ -67,8 +68,8 @@ if __name__ == '__main__':
|
|
| 67 |
)
|
| 68 |
|
| 69 |
with open("/tmp/G_full.pth", 'wb') as local_file:
|
| 70 |
-
|
| 71 |
-
|
| 72 |
|
| 73 |
response2 = client.get_object(
|
| 74 |
Bucket=bucket_name,
|
|
@@ -76,10 +77,10 @@ if __name__ == '__main__':
|
|
| 76 |
)
|
| 77 |
|
| 78 |
with open("/tmp/config.json", 'wb') as local_file:
|
| 79 |
-
|
| 80 |
-
|
| 81 |
|
| 82 |
model_name = "/tmp/G_full.pth" # 模型地址
|
| 83 |
config_name = "/tmp/config.json" # config地址
|
| 84 |
svc_model = infer_tool.Svc(model_name, config_name)
|
| 85 |
-
app.run(port=1145, host="0.0.0.0", debug=False, threaded=False)
|
|
|
|
| 8 |
|
| 9 |
import requests
|
| 10 |
import os
|
| 11 |
+
from qcloud_cos import CosConfig
|
| 12 |
+
from qcloud_cos import CosS3Client
|
| 13 |
|
| 14 |
app = Flask(__name__)
|
| 15 |
|
|
|
|
| 58 |
secret_key = os.getenv('SECRET_KEY')
|
| 59 |
region = 'na-siliconvalley'
|
| 60 |
bucket_name = 'xiaohei-cat-ai-1304646510'
|
|
|
|
| 61 |
|
| 62 |
config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key)
|
| 63 |
client = CosS3Client(config)
|
|
|
|
| 68 |
)
|
| 69 |
|
| 70 |
with open("/tmp/G_full.pth", 'wb') as local_file:
|
| 71 |
+
for chunk in response1['Body'].iter_chunks():
|
| 72 |
+
local_file.write(chunk)
|
| 73 |
|
| 74 |
response2 = client.get_object(
|
| 75 |
Bucket=bucket_name,
|
|
|
|
| 77 |
)
|
| 78 |
|
| 79 |
with open("/tmp/config.json", 'wb') as local_file:
|
| 80 |
+
for chunk in response2['Body'].iter_chunks():
|
| 81 |
+
local_file.write(chunk)
|
| 82 |
|
| 83 |
model_name = "/tmp/G_full.pth" # 模型地址
|
| 84 |
config_name = "/tmp/config.json" # config地址
|
| 85 |
svc_model = infer_tool.Svc(model_name, config_name)
|
| 86 |
+
app.run(port=1145, host="0.0.0.0", debug=False, threaded=False)
|