BBrother commited on
Commit
b9bc53e
·
1 Parent(s): 62b80a7

Update v2_3.py

Browse files
Files changed (1) hide show
  1. v2_3.py +15 -37
v2_3.py CHANGED
@@ -189,28 +189,15 @@ for repo_url, destination in extensions_to_clone:
189
 
190
  print ("修改启动文件...")
191
 
192
- # 修改 launch.py 文件
193
- with open('/bushu/ui/launch.py', 'r') as file:
194
- lines = file.readlines()
195
 
196
- with open('/bushu/ui/launch.py', 'w') as file:
197
- for line in lines:
198
- if 'from modules import launch_utils' in line:
199
- file.write('import os\n')
200
- elif 'prepare_environment()' in line:
201
- file.write(' os.system(f\'sed -i -e \'\'\'s/stable/dict()))/dict())).cuda()/g\'\'\' /bushu/ui/repositories/diffusion-stability-stable/ldm/util.py\')\n')
202
- else:
203
- file.write(line)
204
-
205
- # 修改 shared.py 文件
206
- with open('/bushu/ui/modules/shared.py', 'r') as file:
207
- content = file.read()
208
-
209
- content = content.replace('["sd_model_checkpoint"]', '["sd_model_checkpoint","sd_vae","CLIP_stop_at_last_layers"]')
210
-
211
- with open('/bushu/ui/modules/shared.py', 'w') as file:
212
- file.write(content)
213
 
 
 
214
 
215
 
216
  # 汉化
@@ -294,24 +281,15 @@ if T2I_:
294
 
295
 
296
  print ("修改启动文件...")
297
- # 修改 launch.py 文件
298
- launch_file_path = '/bushu/ui/launch.py'
299
- if os.path.exists(launch_file_path):
300
- with fileinput.FileInput(launch_file_path, inplace=True, backup='.bak') as file:
301
- for line in file:
302
- print(line.replace('from modules import launch_utils', 'import os'), end='')
303
-
304
- with fileinput.FileInput(launch_file_path, inplace=True, backup='.bak') as file:
305
- for line in file:
306
- print(line.replace('prepare_environment()', 'os.system(f"""sed -i -e \'s/stable/dict()))/dict())).cuda()/g\' /bushu/ui/repositories/diffusion-stability-stable/ldm/util.py""")'), end='')
307
-
308
- # 修改 shared.py 文件
309
- shared_file_path = '/bushu/ui/modules/shared.py'
310
- if os.path.exists(shared_file_path):
311
- with fileinput.FileInput(shared_file_path, inplace=True, backup='.bak') as file:
312
- for line in file:
313
- print(line.replace('["sd_model_checkpoint"]', '["sd_model_checkpoint","sd_vae","CLIP_stop_at_last_layers"]'), end='')
314
 
 
 
315
 
316
 
317
  """# 模型下载"""
 
189
 
190
  print ("修改启动文件...")
191
 
192
+ # 第一个命令
193
+ subprocess.run(["sed", "-i", r"/from modules import launch_utils/a\import os", "/content/ui/launch.py"])
 
194
 
195
+ # 第二个命令
196
+ sed_command = r"sed -i -e '/ prepare_environment()/a\ os.system(\"sed -i -e ''s/stable/dict()))/dict())).cuda()/g\" /content/ui/repositories/diffusion-stability-stable/ldm/util.py\")' /content/ui/launch.py"
197
+ subprocess.run(["bash", "-c", sed_command])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
 
199
+ # 第三个命令
200
+ subprocess.run(["sed", "-i", r"s/\[\"sd_model_checkpoint\"\]/\[\"sd_model_checkpoint\",\"sd_vae\",\"CLIP_stop_at_last_layers\"\]/g", "/content/ui/modules/shared.py"])
201
 
202
 
203
  # 汉化
 
281
 
282
 
283
  print ("修改启动文件...")
284
+ # 第一个命令
285
+ subprocess.run(["sed", "-i", r'/from modules import launch_utils/a\import os', '/content/ui/launch.py'])
286
+
287
+ # 第二个命令
288
+ sed_command = r"/ prepare_environment()/a\ os.system(r\"sed -i -e 's/stable/dict()))/dict())).cuda()/g' /content/ui/repositories/stable-diffusion-stability-ai/ldm/util.py\")"
289
+ subprocess.run(["sed", "-i", sed_command, "/content/ui/launch.py"])
 
 
 
 
 
 
 
 
 
 
 
290
 
291
+ # 第三个命令
292
+ subprocess.run(["sed", "-i", r's/\["sd_model_checkpoint"\]/\["sd_model_checkpoint","sd_vae","CLIP_stop_at_last_layers"\]/g', '/content/ui/modules/shared.py'])
293
 
294
 
295
  """# 模型下载"""