viyi commited on
Commit
c8aff2a
1 Parent(s): c15c65f

Upload sdwui_install.py

Browse files
Files changed (1) hide show
  1. sdwui_install.py +50 -80
sdwui_install.py CHANGED
@@ -18,57 +18,33 @@ def mkdirs(path, exist_ok=True):
18
 
19
  # 内置参数默认值,当上下文有参数时可覆盖默认值
20
 
21
- _useFrpc = False
22
- if 'useFrpc' in locals() or 'useFrpc' in globals():
23
- _useFrpc = config.useFrpc
24
 
25
- _useNgrok = False
26
- if 'useNgrok' in locals() or 'useNgrok' in globals():
27
- _useNgrok = config.useNgrok
28
-
29
- _reLoad = False
30
- if 'reLoad' in locals() or 'reLoad' in globals():
31
- _reLoad = config.reLoad
32
-
33
- _before_downloading = ''
34
- if 'before_downloading' in locals() or 'before_downloading' in globals():
35
- _before_downloading = config.before_downloading
36
 
37
- _async_downloading = ''
38
- if 'async_downloading' in locals() or 'async_downloading' in globals():
39
- _async_downloading = config.async_downloading
40
 
41
- _before_start_sync_downloading = ''
42
- if 'before_start_sync_downloading' in locals() or 'before_start_sync_downloading' in globals():
43
- _before_start_sync_downloading = config.before_start_sync_downloading
44
-
45
- _server_port = 7860
46
- if 'server_port' in locals() or 'server_port' in globals():
47
- _server_port = config.server_port
48
-
49
- _sd_git_repo ='https://github.com/viyiviyi/stable-diffusion-webui.git -b local'
50
- if 'sd_git_repo' in locals() or 'sd_git_repo' in globals():
51
- _sd_git_repo = config.sd_git_repo\
52
  .replace('{sdwui}','stable-diffusion-webui')\
53
- .replace('{wui}',"webui")
54
 
55
- _sd_config_git_repu = 'https://github.com/viyiviyi/sd-configs.git'
56
- if 'sd_config_git_repu' in locals() or 'sd_config_git_repu' in globals():
57
- _sd_config_git_repu = config.sd_config_git_repu\
58
  .replace('{sdwui}','stable-diffusion-webui')\
59
- .replace('{wui}',"webui")
60
 
61
- _link_instead_of_copy = True
62
- if 'link_instead_of_copy' in locals() or 'link_instead_of_copy' in globals():
63
- _link_instead_of_copy = config.link_instead_of_copy
64
-
65
- show_shell_info = False
66
- if 'hidden_console_info' in locals() or 'hidden_console_info' in globals():
67
- show_shell_info = not config.hidden_console_info
68
-
69
- _skip_start = False
70
- if 'skip_start' in locals() or 'skip_start' in globals():
71
- _skip_start = config.skip_start
72
 
73
  run_by_none_device = False
74
 
@@ -143,15 +119,13 @@ def config_reader(conf:str):
143
  ngrokTokenFile = os.path.join(input_path,'configs/ngrok_token.txt') # 非必填 存放ngrokToken的文件的路径
144
  frpcConfigFile = os.path.join(input_path,'configs/frpc_koishi.ini') # 非必填 frp 配置文件
145
  # ss证书目录 下载nginx的版本,把pem格式改成crt格式
146
- frpcSSLFFlies =[os.path.join(input_path,'configs/koishi_ssl')]
147
- if 'frp_ssl_dir' in locals() or 'frp_ssl_dir' in globals():
148
- frpcSSLFFlies = frpcSSLFFlies + config_reader(config.frp_ssl_dir)
149
  # frpc 文件目录 如果目录不存在,会自动下载,也可以在数据集搜索 viyiviyi/utils 添加
150
  frpcExePath = os.path.join(input_path,'utils-tools/frpc')
151
  # 其他需要加载的webui启动参数 写到【参数列表】这个配置去
152
- otherArgs = '--xformers'
153
- if 'sd_start_args' in locals() or 'sd_start_args' in globals():
154
- otherArgs = ' '.join([item for item in config_reader(config.sd_start_args) if item != '--no-gradio-queue'])
155
  venvPath = os.path.join(input_path,'sd-webui-venv/venv.tar.bak') # 安装好的python环境 sd-webui-venv是一个公开是数据集 可以搜索添加
156
 
157
  # 用于使用kaggle api的token文件 参考 https://www.kaggle.com/docs/api
@@ -162,45 +136,41 @@ requirements = []
162
 
163
  frpcStartArg = ''
164
 
165
- _setting_file = ''
166
- if 'setting_file' in locals() or 'setting_file' in globals():
167
- _setting_file = replace_path(config.setting_file)
168
- _ui_config_file = ''
169
- if 'ui_config_file' in locals() or 'ui_config_file' in globals():
170
- _ui_config_file = replace_path(config.ui_config_file)
171
 
172
  mkdirs(f'{install_path}/configFiles',True)
173
- if 'frp_config_or_file' in locals() or 'frp_config_or_file' in globals():
174
- _frp_config_or_file = replace_path(config.frp_config_or_file)
175
- if Path(_frp_config_or_file.strip()).exists():
176
- frpcConfigFile = _frp_config_or_file.strip()
177
- if not Path(frpcConfigFile).exists():
178
- if _frp_config_or_file.strip().startswith('-f'):
179
- frpcStartArg = _frp_config_or_file.strip()
180
- else:
181
- print('没有frpcp配置')
182
- _useFrpc = False
183
  else:
184
- run(f'''cp -f {frpcConfigFile} {install_path}/configFiles/frpc_webui.ini''')
185
- frpcConfigFile = f'{install_path}/configFiles/frpc_webui.ini'
186
- run(f'''sed -i "s/local_port = .*/local_port = {_server_port}/g" {frpcConfigFile}''')
187
- frpcStartArg = f' -c {frpcConfigFile}'
 
 
 
 
188
 
189
  ngrokToken=''
190
- if 'ngrok_config_or_file' in locals() or 'ngrok_config_or_file' in globals():
191
- _ngrok_config_or_file = replace_path(config.ngrok_config_or_file)
192
- if Path(_ngrok_config_or_file.strip()).exists():
193
- ngrokTokenFile = _ngrok_config_or_file.strip()
194
- if Path(ngrokTokenFile).exists():
195
- with open(ngrokTokenFile,encoding = "utf-8") as nkfile:
196
- ngrokToken = nkfile.readline()
197
- elif not _ngrok_config_or_file.strip().startswith('/'):
198
- ngrokToken=_ngrok_config_or_file.strip()
199
 
200
  if not Path(venvPath).exists():
201
  venvPath = os.path.join(input_path,'sd-webui-venv/venv.zip')
202
 
203
-
204
  import concurrent.futures
205
  import importlib
206
  import os
 
18
 
19
  # 内置参数默认值,当上下文有参数时可覆盖默认值
20
 
21
+ _useFrpc = config.useFrpc
 
 
22
 
23
+ _useNgrok = config.useNgrok
 
 
 
 
 
 
 
 
 
 
24
 
25
+ _reLoad = config.reLoad
 
 
26
 
27
+ _before_downloading = config.before_downloading
28
+
29
+ _async_downloading = config.async_downloading
30
+
31
+ _before_start_sync_downloading = config.before_start_sync_downloading
32
+
33
+ _server_port = config.server_port or 7860
34
+
35
+ _sd_git_repo = config.sd_git_repo\
 
 
36
  .replace('{sdwui}','stable-diffusion-webui')\
37
+ .replace('{wui}',"webui") or 'https://github.com/viyiviyi/stable-diffusion-webui.git -b local'
38
 
39
+ _sd_config_git_repu = config.sd_config_git_repu\
 
 
40
  .replace('{sdwui}','stable-diffusion-webui')\
41
+ .replace('{wui}',"webui") or 'https://github.com/viyiviyi/sd-configs.git'
42
 
43
+ _link_instead_of_copy = config.link_instead_of_copy
44
+
45
+ show_shell_info = not config.hidden_console_info
46
+
47
+ _skip_start = config.skip_start
 
 
 
 
 
 
48
 
49
  run_by_none_device = False
50
 
 
119
  ngrokTokenFile = os.path.join(input_path,'configs/ngrok_token.txt') # 非必填 存放ngrokToken的文件的路径
120
  frpcConfigFile = os.path.join(input_path,'configs/frpc_koishi.ini') # 非必填 frp 配置文件
121
  # ss证书目录 下载nginx的版本,把pem格式改成crt格式
122
+ frpcSSLFFlies = [os.path.join(input_path,'configs/koishi_ssl')] + config_reader(config.frp_ssl_dir)
123
+
 
124
  # frpc 文件目录 如果目录不存在,会自动下载,也可以在数据集搜索 viyiviyi/utils 添加
125
  frpcExePath = os.path.join(input_path,'utils-tools/frpc')
126
  # 其他需要加载的webui启动参数 写到【参数列表】这个配置去
127
+ otherArgs = ' '.join([item for item in config_reader(config.sd_start_args) if item != '--no-gradio-queue']) or '--xformers'
128
+
 
129
  venvPath = os.path.join(input_path,'sd-webui-venv/venv.tar.bak') # 安装好的python环境 sd-webui-venv是一个公开是数据集 可以搜索添加
130
 
131
  # 用于使用kaggle api的token文件 参考 https://www.kaggle.com/docs/api
 
136
 
137
  frpcStartArg = ''
138
 
139
+ _setting_file = replace_path(config.setting_file)
140
+
141
+ _ui_config_file = replace_path(config.ui_config_file)
 
 
 
142
 
143
  mkdirs(f'{install_path}/configFiles',True)
144
+
145
+ _frp_config_or_file = replace_path(config.frp_config_or_file)
146
+ if Path(_frp_config_or_file.strip()).exists():
147
+ frpcConfigFile = _frp_config_or_file.strip()
148
+ if not Path(frpcConfigFile).exists():
149
+ if _frp_config_or_file.strip().startswith('-f'):
150
+ frpcStartArg = _frp_config_or_file.strip()
 
 
 
151
  else:
152
+ print('没有frpcp配置')
153
+ _useFrpc = False
154
+ else:
155
+ run(f'''cp -f {frpcConfigFile} {install_path}/configFiles/frpc_webui.ini''')
156
+ frpcConfigFile = f'{install_path}/configFiles/frpc_webui.ini'
157
+ run(f'''sed -i "s/local_port = .*/local_port = {_server_port}/g" {frpcConfigFile}''')
158
+ frpcStartArg = f' -c {frpcConfigFile}'
159
+
160
 
161
  ngrokToken=''
162
+ _ngrok_config_or_file = replace_path(config.ngrok_config_or_file)
163
+ if Path(_ngrok_config_or_file.strip()).exists():
164
+ ngrokTokenFile = _ngrok_config_or_file.strip()
165
+ if Path(ngrokTokenFile).exists():
166
+ with open(ngrokTokenFile,encoding = "utf-8") as nkfile:
167
+ ngrokToken = nkfile.readline()
168
+ elif not _ngrok_config_or_file.strip().startswith('/'):
169
+ ngrokToken=_ngrok_config_or_file.strip()
 
170
 
171
  if not Path(venvPath).exists():
172
  venvPath = os.path.join(input_path,'sd-webui-venv/venv.zip')
173
 
 
174
  import concurrent.futures
175
  import importlib
176
  import os