forked from williamyang1991/FRESCO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
115 lines (96 loc) · 3.66 KB
/
install.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import os
import platform
import requests
import stat
import subprocess
def build_ebsynth():
if os.path.exists('src/ebsynth/deps/ebsynth/bin/ebsynth'):
print('Ebsynth has been built.')
return
os_str = platform.system()
if os_str == 'Windows':
print('Build Ebsynth Windows 64 bit.',
'If you want to build for 32 bit, please modify install.py.')
cmd = '.\\build-win64-cpu+cuda.bat'
exe_file = 'src/ebsynth/deps/ebsynth/bin/ebsynth.exe'
elif os_str == 'Linux':
cmd = 'bash build-linux-cpu+cuda.sh'
exe_file = 'src/ebsynth/deps/ebsynth/bin/ebsynth'
# Add executable permissions to the ebsynth binary
# Build the ebsynth binary
subprocess.call(cmd, shell=True)
# Add execute permissions for the ebsynth binary on Linux
if os_str == 'Linux':
os.chmod(exe_file, 0o755)
elif os_str == 'Darwin':
cmd = 'sh build-macos-cpu_only.sh'
exe_file = 'src/ebsynth/deps/ebsynth/bin/ebsynth.app'
else:
print('Cannot recognize OS. Ebsynth installation stopped.')
return
os.chdir('src/ebsynth/deps/ebsynth')
print(cmd)
os.system(cmd)
os.chdir('../../../..')
if os.path.exists(exe_file):
print('Ebsynth installed successfully.')
else:
print('Failed to install Ebsynth.')
def download(url, dir, name=None):
os.makedirs(dir, exist_ok=True)
if name is None:
name = url.split('/')[-1]
path = os.path.join(dir, name)
if not os.path.exists(path):
print(f'Install {name} ...')
open(path, 'wb').write(requests.get(url).content)
print('Install successfully.')
def download(url, dir, name=None):
os.makedirs(dir, exist_ok=True)
if name is None:
name = url.split('/')[-1]
path = os.path.join(dir, name)
if not os.path.exists(path):
print(f'Install {name} ...')
open(path, 'wb').write(requests.get(url).content)
print('Install successfully.')
def download_gmflow_ckpt():
url = ('https://huggingface.co/PKUWilliamYang/Rerender/'
'resolve/main/models/gmflow_sintel-0c07dcb3.pth')
download(url, 'model')
def download_egnet_ckpt():
url = ('https://huggingface.co/PKUWilliamYang/Rerender/'
'resolve/main/models/epoch_resnet.pth')
download(url, 'model')
def download_hed_ckpt():
url = ('https://huggingface.co/lllyasviel/Annotators/'
'resolve/main/ControlNetHED.pth')
download(url, 'src/ControlNet/annotator/ckpts')
def download_depth_ckpt():
url = ('https://huggingface.co/lllyasviel/ControlNet/'
'resolve/main/annotator/ckpts/dpt_hybrid-midas-501f0c75.pt')
download(url, 'src/ControlNet/annotator/ckpts')
def download_ebsynth_ckpt():
os_str = platform.system()
if os_str == 'Linux':
url = ('https://huggingface.co/PKUWilliamYang/Rerender/'
'resolve/main/models/ebsynth')
download(url, 'src/ebsynth/deps/ebsynth/bin')
elif os_str == 'Windows':
url = ('https://huggingface.co/PKUWilliamYang/Rerender/'
'resolve/main/models/ebsynth.exe')
download(url, 'src/ebsynth/deps/ebsynth/bin')
url = ('https://huggingface.co/PKUWilliamYang/Rerender/'
'resolve/main/models/ebsynth_cpu.dll')
download(url, 'src/ebsynth/deps/ebsynth/bin')
url = ('https://huggingface.co/PKUWilliamYang/Rerender/'
'resolve/main/models/ebsynth_cpu.exe')
download(url, 'src/ebsynth/deps/ebsynth/bin')
else:
print('No available compiled Ebsynth.')
#build_ebsynth()
download_ebsynth_ckpt()
download_gmflow_ckpt()
download_egnet_ckpt()
download_hed_ckpt()
download_depth_ckpt()