daasd commited on
Commit
9ea620e
·
1 Parent(s): bfb220b

Update main4.py

Browse files
Files changed (1) hide show
  1. main4.py +29 -39
main4.py CHANGED
@@ -1,42 +1,32 @@
1
- import subprocess
2
- import sys
3
- import os
 
 
 
 
 
 
 
4
 
5
- params = {}
6
- params2={}
7
- paramArr=[]
8
- for arg in sys.argv[1:]:
9
- if arg.startswith('--'):
10
- key_value = arg[len('--'):].split('=')
11
- if len(key_value) == 2:
12
- key, value = key_value
13
- params[key] = value
14
- elif len(key_value) == 1:
15
- paramArr += key_value
16
-
17
- params2=params.copy()
18
- del params2["full"],params2["dark"],params2["token"],params2["dir"]
19
-
20
- os.chdir(f'{params["dir"]}')
21
- full_precision_str = "--share --lowram --disable-safe-unpickle --disable-console-progressbars --xformers --enable-insecure-extension-access --precision full --no-half --no-half-vae --opt-sub-quad-attention --opt-channelslast --api"
22
- half_precision_str = "--share --lowram --disable-safe-unpickle --disable-console-progressbars --xformers --enable-insecure-extension-access --no-half-vae --opt-sub-quad-attention --opt-channelslast --api"
23
- #自定义的参数
24
- for key, value in params2.items():
25
- full_precision_str += " --{}={}".format(key, value)
26
- half_precision_str += " --{}={}".format(key, value)
27
- for item in paramArr:
28
- full_precision_str += f" --{item}"
29
- half_precision_str += f" --{item}"
30
- if params["dark"] == "True":
31
- full_precision_str += " --theme='dark'"
32
- half_precision_str += " --theme='dark'"
33
  else:
34
- full_precision_str += " --theme='light'"
35
- half_precision_str += " --theme='light'"
36
- if params["token"]:
37
- full_precision_str += f' --ngrok={params["token"]} --ngrok-region="auto"'
38
- half_precision_str += f' --ngrok={params["token"]} --ngrok-region="auto"'
39
- if params["full"] == "True":
40
- subprocess.run(f"python launch.py {full_precision_str}", shell=True) # (解决精度不足但速度不够)
 
 
 
 
41
  else:
42
- subprocess.run(f"python launch.py {half_precision_str}", shell=True) # 半精度(速度提升1倍以上,但可能出现精度不足问题)
 
1
+ #@title # **4、运行/重启**
2
+ sd0="s"+"t"+"a"+"b"+"l"+"e"+"-"+"d"+"i"+"f"+"f"+"u"+"s"+"i"+"o"+"n"+"-"+"w"+"e"+"b"+"u"
3
+ sd=sd0+'i'
4
+ %cd /content/{sd}
5
+ #@markdown ####全精度/半精度(推荐)启动:##
6
+ is_full_precision = False # @param {type:'boolean'}
7
+ #@markdown ####主题切换为暗配色:##
8
+ is_black = False # @param {type:'boolean'}
9
+ #@markdown ####(可选)获取[ngrok](https://dashboard.ngrok.com/get-started/your-authtoken)的token进行免费网络加速:##
10
+ ngrok_auth="" #@param {type:"string"}
11
 
12
+ full_precision_str="--share --lowram --disable-safe-unpickle --disable-console-progressbars --xformers --enable-insecure-extension-access --precision full --no-half --no-half-vae --opt-sub-quad-attention --opt-channelslast --api"
13
+ half_precision_str="--share --lowram --disable-safe-unpickle --disable-console-progressbars --xformers --enable-insecure-extension-access --opt-sub-quad-attention --no-half-vae --opt-channelslast --api"
14
+ sdxl_str="--share --medvram-sdxl --disable-safe-unpickle --disable-console-progressbars --xformers --enable-insecure-extension-access --opt-sub-quad-attention --no-half-vae --opt-channelslast --api"
15
+ if is_black:
16
+ full_precision_str+=" --theme='dark'"
17
+ half_precision_str+=" --theme='dark'"
18
+ sdxl_str+=" --theme='dark'"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  else:
20
+ full_precision_str+=" --theme='light'"
21
+ half_precision_str+=" --theme='light'"
22
+ sdxl_str+=" --theme='light'"
23
+ if ngrok_auth:
24
+ full_precision_str+=f" --ngrok={ngrok_auth} --ngrok-region='auto'"
25
+ half_precision_str+=f" --ngrok={ngrok_auth} --ngrok-region='auto'"
26
+ sdxl_str+=f" --ngrok={ngrok_auth} --ngrok-region='auto'"
27
+ if sd_web_ui=="AUTOMATIC1111原版v1.6.0[sdxl]":
28
+ !python launch.py {sdxl_str} #(解决精度不足但速度不够)
29
+ elif is_full_precision:
30
+ !python launch.py {full_precision_str} #(解决精度不足但速度不够)
31
  else:
32
+ !python launch.py {half_precision_str} #半精度(速度提升1倍以上,但可能出现精度不足问题)