forked from zfw1226/gym-unrealcv
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathload_env.py
72 lines (64 loc) · 2.12 KB
/
load_env.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import os
import argparse
import zipfile
import sys
import shutil
import unrealcv
modelscope = {
'UE4': 'UnrealZoo/UnrealZoo-UE4',
'UE5': 'UnrealZoo/UnrealZoo-UE5',
}
binary_linux = dict(
UE4_ExampleScene='UE4_ExampleScene_Linux.zip',
UE5_ExampleScene='UE5_ExampleScene_Linux.zip',
UE4_Collection_Preview='Collection_v4_LinuxNoEditor.zip',
Textures='Textures.zip'
)
binary_win = dict(
UE4_ExampleScene='UE4_ExampleScene_Win.zip',
UE5_ExampleScene='UE5_ExampleScene_Win.zip',
Textures='Textures.zip'
)
binary_mac = dict(
UE4_ExampleScene='UE4_ExampleScene_Mac.zip',
Textures='Textures.zip'
)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=None)
parser.add_argument("-e", "--env", nargs='?', default='Textures',
help='Select the binary to download')
parser.add_argument("-cloud", "--cloud", nargs='?', default='modelscope',
help='Select the cloud to download the binary, modelscope or aliyun')
args = parser.parse_args()
if 'linux' in sys.platform:
binary_all = binary_linux
elif 'darwin' in sys.platform:
binary_all = binary_mac
elif 'win' in sys.platform:
binary_all = binary_win
if args.env in binary_all:
target_name = binary_all[args.env]
else:
print(f"{args.env} is not available to your platform")
exit()
if args.cloud == 'modelscope':
if 'UE5' in target_name:
remote_repo = modelscope['UE5']
else:
remote_repo = modelscope['UE4']
cmd = f"modelscope download --dataset {remote_repo} --include {target_name} --local_dir ."
try:
os.system(cmd)
except:
print('Please install modelscope first: pip install modelscope')
exit()
filename = target_name
with zipfile.ZipFile(filename, "r") as z:
z.extractall() # extract the zip file
if 'Textures' in filename:
folder ='textures'
else:
folder = filename[:-4]
target = unrealcv.util.get_path2UnrealEnv()
shutil.move(folder, target)
os.remove(filename)