Skip to content

Commit 4e274a5

Browse files
committed
from onedrive to modelscope
1 parent 1fa67f4 commit 4e274a5

1 file changed

Lines changed: 19 additions & 39 deletions

File tree

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,27 @@
11
import os, commentjson, shutil, subprocess, tqdm, shutil
2-
from onedrivedownloader import download
3-
from distutils import dir_util
4-
2+
import zipfile
3+
from modelscope import snapshot_download
54
try: os.makedirs('./TEMP')
65
except: pass
76

8-
def download_from_shared_server(key = 'cat'):
9-
# download uhmap file manifest | 下载manifest目录文件
10-
print('Download uhmap file manifest | 下载manifest目录文件')
11-
manifest_url = "https://ageasga-my.sharepoint.com/:u:/g/personal/fuqingxu_yiteam_tech/EVmCQMSUWV5MgREWaxiz_GoBalBRV3DWBU3ToSJ5OTQaLQ?e=I8yjl9"
12-
try:
13-
download(manifest_url, filename="./TEMP/", force_download=True)
14-
except:
15-
print('Failed to connect to onedrive | 连接onedrive失败, 您可能需要翻墙才能下载资源')
16-
return False
17-
18-
with open("./TEMP/uhmap_manifest.jsonc", "r") as f:
19-
manifest = commentjson.load(f)
20-
21-
uhmap_url = manifest[key]
22-
print('Download main files | 下载预定文件')
23-
try:
24-
download(uhmap_url, filename="./TEMP/DOWNLOAD", unzip=True, unzip_path='./TEMP/UNZIP')
25-
except:
26-
print(f'Download timeout | 下载失败, 您可能需要翻墙才能下载资源。另外如果您想手动下载的话: {uhmap_url}')
27-
return False
7+
version = 'unreal-map-v3.4'
8+
model_dir = snapshot_download(f'BinaryHusky/{version}')
9+
zip_file_path = f'./TEMP/{version}.zip'
2810

29-
return True
11+
def combine_file(model_dir, output_file_path, num_parts):
12+
with open(output_file_path, 'wb') as output_file:
13+
for i in range(0, num_parts):
14+
part_file_path = os.path.join(model_dir, "tensor", f"safetensor_{i+1}.pt")
15+
with open(part_file_path, 'rb') as part_file:
16+
output_file.write(part_file.read())
3017

31-
def get_current_version():
32-
with open('current_version', 'r', encoding='utf8') as f:
33-
version = f.read()
34-
return version
18+
extract_to_path = './'
19+
combine_file(model_dir, output_file_path=zip_file_path, num_parts=5)
3520

36-
version = get_current_version()
37-
success = download_from_shared_server(f'uhmp-big-file-v{version}')
21+
# 打开 ZIP 文件
22+
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
23+
# 解压所有文件到指定目录
24+
zip_ref.extractall(extract_to_path)
25+
print(f"files unzipped {extract_to_path}")
3826

39-
if success:
40-
print('Copying downloaded files to project root')
41-
print('This will take a while if you are not using SSD...')
42-
dir_util.copy_tree('./TEMP/UNZIP', './')
43-
print('Download complete | 下载完成')
44-
else:
45-
try: shutil.rmtree('./TEMP')
46-
except: pass
47-
print('Download fail, clear TEMP folder | 下载失败, 临时文件夹已清除')
27+
print("everything is ready!")

0 commit comments

Comments
 (0)