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

Update main4.py

Browse files
Files changed (1) hide show
  1. main4.py +52 -27
main4.py CHANGED
@@ -1,32 +1,57 @@
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倍以上,但可能出现精度不足问题)
 
1
+ import subprocess
2
+ import sys
3
+ import os
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ params = {}
13
+ params2={}
14
+ paramArr=[]
15
+ for arg in sys.argv[1:]:
16
+ if arg.startswith('--'):
17
+ key_value = arg[len('--'):].split('=')
18
+ if len(key_value) == 2:
19
+ key, value = key_value
20
+ params[key] = value
21
+ elif len(key_value) == 1:
22
+ paramArr += key_value
23
+
24
+ params2=params.copy()
25
+ del params2["full"],params2["dark"],params2["token"],params2["dir"]
26
+
27
+ os.chdir(f'{params["dir"]}')
28
+ 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"
29
+ 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"
30
  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"
31
+ #自定义的参数
32
+ for key, value in params2.items():
33
+ full_precision_str += " --{}={}".format(key, value)
34
+ half_precision_str += " --{}={}".format(key, value)
35
+ sdxl_str+= " --{}={}".format(key, value)
36
+ for item in paramArr:
37
+ full_precision_str += f" --{item}"
38
+ half_precision_str += f" --{item}"
39
+ sdxl_str+= f" --{item}"
40
+ if params["dark"] == "True":
41
+ full_precision_str += " --theme='dark'"
42
+ half_precision_str += " --theme='dark'"
43
+ sdxl_str+= " --theme='dark'"
44
  else:
45
+ full_precision_str += " --theme='light'"
46
+ half_precision_str += " --theme='light'"
47
+ sdxl_str+= " --theme='light'"
48
+ if params["token"]:
49
+ full_precision_str += f' --ngrok={params["token"]} --ngrok-region="auto"'
50
+ half_precision_str += f' --ngrok={params["token"]} --ngrok-region="auto"'
51
+ sdxl_str+= f' --ngrok={params["token"]} --ngrok-region="auto"'
52
  if sd_web_ui=="AUTOMATIC1111原版v1.6.0[sdxl]":
53
  !python launch.py {sdxl_str} #(解决精度不足但速度不够)
54
+ elif params["full"] == "True":
55
+ subprocess.run(f"python launch.py {full_precision_str}", shell=True) # (解决精度不足但速度不够)
56
  else:
57
+ subprocess.run(f"python launch.py {half_precision_str}", shell=True) # 半精度(速度提升1倍以上,但可能出现精度不足问题)