gmk123 commited on
Commit
e21b57c
·
verified ·
1 Parent(s): 3a8cc62

Update run.py

Browse files
Files changed (1) hide show
  1. run.py +34 -34
run.py CHANGED
@@ -1,13 +1,13 @@
1
  import argparse #line:1
2
  import binascii #line:2
3
  import ipywidgets as widgets #line:3
4
- def str_to_bool (OOOOOO00OOO00OO00 ):#line:7
5
- if OOOOOO00OOO00OO00 .lower ()in ('yes','true','t','y','1'):#line:8
6
  return True #line:9
7
- elif OOOOOO00OOO00OO00 .lower ()in ('no','false','f','n','0'):#line:10
8
  return False #line:11
9
  else :#line:12
10
- raise argparse .ArgumentTypeError ('Invalid boolean value: {}'.format (OOOOOO00OOO00OO00 ))#line:13
11
  parser =argparse .ArgumentParser ()#line:16
12
  parser .add_argument ('--Animatediff',type =str_to_bool )#line:18
13
  parser .add_argument ('--ControlNet',type =str )#line:19
@@ -46,13 +46,13 @@ wb =f'/root/main'#line:63
46
  sai =base64 .b64decode (("c3RhYmxlLWRpZmZ1c2lvbi1zdGFiaWxpdHktYWk=").encode ('ascii')).decode ('ascii')#line:64
47
  sd =base64 .b64decode (("U3RhYmxlLWRpZmZ1c2lvbg==").encode ('ascii')).decode ('ascii')#line:65
48
  gwb =f'/content/drive/MyDrive/SD_DATA'#line:66
49
- def cloudDriveSync (OO000O0000O00O00O ,OO000O0O0O00000O0 ='',OOOOO0O0O0OOOO0O0 =False ):#line:70
50
- if not os .path .exists (OO000O0000O00O00O ):#line:72
51
- get_ipython ().system (f'mkdir {OO000O0000O00O00O}')#line:74
52
- if not OOOOO0O0O0OOOO0O0 :#line:77
53
  return #line:78
54
- get_ipython ().system (f'rm -rf {OO000O0O0O00000O0}')#line:81
55
- get_ipython ().system (f'ln -s {OO000O0000O00O00O} {OO000O0O0O00000O0}')#line:83
56
  def initCloudDrive ():#line:86
57
  cloudDriveSync (f'{gwb}')#line:87
58
  cloudDriveSync (f'{gwb}/Config')#line:88
@@ -66,16 +66,16 @@ def initCloudDrive ():#line:86
66
  get_ipython ().system (f'wget -O {gwb}/Config/config.json "https://huggingface.co/gmk123/colab/raw/main/config.json"')#line:99
67
  if not os .path .exists (f'{gwb}/styles.csv'):#line:101
68
  get_ipython ().system (f'wget -O {gwb}/styles.csv "https://huggingface.co/gmk123/colab/raw/main/styles.csv"')#line:103
69
- def gitDownload (OOOO0OOO0OO0OOOOO ,OOO0OOO0OOOO0O0O0 ):#line:106
70
- if os .path .exists (OOO0OOO0OOOO0O0O0 ):#line:107
71
  return #line:108
72
- get_ipython ().system (f'git clone {OOOO0OOO0OO0OOOOO} {OOO0OOO0OOOO0O0O0}')#line:110
73
  def installAdditional ():#line:113
74
- OOO00O00O00O0OOO0 =[f'https://github.com/AlUlkesh/{sdw}-images-browser',f'https://github.com/etherealxx/batchlinks-{w}',f'https://github.com/camenduru/sd-civitai-browser',f'https://github.com/AUTOMATIC1111/{sdw}-rembg',f'https://github.com/thomasasfk/sd-{w}-aspect-ratio-helper',f'https://github.com/hanamizuki-ai/{sdw}-localization-zh_Hans',f'https://github.com/kohya-ss/sd-{w}-additional-networks',f'https://github.com/fkunn1326/openpose-editor',f'https://github.com/nonnonstop/sd-{w}-3d-open-pose-editor',f'https://github.com/IDEA-Research/DWPose',f'https://github.com/Physton/sd-{w}-prompt-all-in-one',f'https://github.com/adieyal/sd-dynamic-prompts',f'https://github.com/Bing-su/adetailer',f'https://github.com/Tencent/LightDiffusionFlow',f'https://github.com/picobyte/{sdw}-wd14-tagger',f'https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111',]#line:152
75
- for O00OOOOO0O0OOOO0O in OOO00O00O00O0OOO0 :#line:153
76
- O0O0O0O0000O000O0 =O00OOOOO0O0OOOO0O .split ('/')[-1 ]#line:155
77
- if 'github'in O00OOOOO0O0OOOO0O :#line:157
78
- get_ipython ().system (f'git clone {O00OOOOO0O0OOOO0O} {wb}/extensions/{O0O0O0O0000O000O0}')#line:158
79
  cloudDriveSync (f'{gwb}/prompts',f'{wb}/extensions/sd-dynamic-prompts/wildcards',Drive_Map )#line:160
80
  get_ipython ().system (f'wget https://raw.githubusercontent.com/camenduru/{sdw}-scripts/main/run_n_times.py -O {wb}/scripts/run_n_times.py')#line:161
81
  get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/embed/upscale/resolve/main/4x-UltraSharp.pth -d {wb}/models/ESRGAN -o 4x-UltraSharp.pth')#line:162
@@ -102,23 +102,23 @@ def installAdditional ():#line:113
102
  print ('Roop换脸启用')#line:193
103
  else :#line:194
104
  print ('Roop换脸不启用')#line:195
105
- OO0O0OOOOO0O00OOO =['control_v11e_sd15_ip2p.pth','control_v11e_sd15_shuffle.pth','control_v11f1e_sd15_tile.pth','control_v11f1p_sd15_depth.pth','control_v11p_sd15_canny.pth','control_v11p_sd15_inpaint.pth','control_v11p_sd15_lineart.pth','control_v11p_sd15_mlsd.pth','control_v11p_sd15_normalbae.pth','control_v11p_sd15_openpose.pth','control_v11p_sd15_scribble.pth','control_v11p_sd15_seg.pth','control_v11p_sd15_softedge.pth','control_v11p_sd15s2_lineart_anime.pth',]#line:213
106
  get_ipython ().system (f'rm -rf {wb}/extensions/sd-{w}-controlnet')#line:214
107
  if ControlNet =="Colab":#line:216
108
  gitDownload (f'https://github.com/Mikubill/sd-{w}-controlnet',f'{wb}/extensions/sd-{w}-controlnet')#line:217
109
- for OO00000O000OOOOO0 in OO0O0OOOOO0O00OOO :#line:218
110
- get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/{OO00000O000OOOOO0} -d {wb}/extensions/sd-{w}-controlnet/models -o {v}')#line:219
111
  elif ControlNet =="Google_Drive":#line:222
112
  cloudDriveSync (f'{gwb}/CntModels')#line:223
113
  gitDownload (f'https://github.com/Mikubill/sd-{w}-controlnet',f'{wb}/extensions/sd-{w}-controlnet')#line:224
114
- for OO00000O000OOOOO0 in OO0O0OOOOO0O00OOO :#line:225
115
- if not os .path .exists (f'{gwb}/CntModels/{OO00000O000OOOOO0}'):#line:226
116
- get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/{OO00000O000OOOOO0} -d {gwb}/CntModels -o {v}')#line:227
117
- print ("创建扩展",f'{OO00000O000OOOOO0}')#line:228
118
  else :#line:229
119
- print ("扩展存在",f'{OO00000O000OOOOO0}')#line:230
120
- for OO00000O000OOOOO0 in os .listdir (f'{gwb}/CntModels'):#line:232
121
- get_ipython ().system (f'ln -s {gwb}/CntModels/{OO00000O000OOOOO0} {wb}/extensions/sd-{w}-controlnet/models')#line:234
122
  elif ControlNet =="No":#line:236
123
  print ("不使用 ControlNet")#line:237
124
  if Animatediff :#line:240
@@ -162,14 +162,14 @@ def installAdditional ():#line:113
162
  def initLocal ():#line:297
163
  get_ipython ().system ('apt -y install -qq aria2 git')#line:299
164
  get_ipython ().system (f'pip install lmdb')#line:301
165
- get_ipython ().system (f'pip install torch==2.1.2+cu121 torchvision==0.16.2+cu121 torchaudio==2.1.2+cu121 torchtext==0.18.0+cpu torchdata==0.8.0 --index-url https://download.pytorch.org/whl/cu121')#line:303
166
  get_ipython ().system (f'pip install xformers==0.0.23.post1')#line:304
167
  get_ipython ().run_line_magic ('cd','/content')#line:305
168
  get_ipython ().system (f'pip install -q basicsr')#line:306
169
- with capture .capture_output ()as OO000OOO00O0O0O00 :#line:308
170
- def O00O00O00O0O000O0 (O00000O0OO00OO0O0 ,O0O00OO0OO0O000O0 ,OOO000O00O0O0O0OO ):O0O0O0OOOOOOO00OO =widgets .Button (description =O00000O0OO00OO0O0 ,disabled =True ,button_style =O0O00OO0OO0O000O0 ,layout =widgets .Layout (min_width =OOO000O00O0O0O0OO ));display (O0O0O0OOOOOOO00OO )#line:309
171
  get_ipython ().system (f'git clone -q --branch master https://github.com/AUTOMATIC1111/{sdw} /root/main')#line:311
172
- with capture .capture_output ()as OO000OOO00O0O0O00 :#line:313
173
  get_ipython ().run_line_magic ('cd','/content')#line:314
174
  get_ipython ().system (f'mkdir -p {wb}/repositories/{sai}')#line:316
175
  get_ipython ().system ('wget -q -i https://huggingface.co/gmk123/run/raw/main/A1111.txt')#line:317
@@ -210,10 +210,10 @@ def initLocal ():#line:297
210
  get_ipython ().system (f'sed -i \'s@possible_sd_paths =.*@possible_sd_paths = [\"{wb}/repositories/{sai}\"]@\' {wb}/modules/paths.py')#line:380
211
  get_ipython ().system (f'sed -i \'s@\\.\\.\\/@src/@g\' {wb}/modules/paths.py')#line:381
212
  get_ipython ().system (f'sed -i \'s@src/generative-models@generative-models@g\' {wb}/modules/paths.py')#line:382
213
- def run (OOOO0OO00O00000O0 ):#line:386
214
  clear_output ()#line:387
215
  get_ipython ().run_line_magic ('cd',f'{wb}')#line:388
216
- get_ipython ().system (f'python {OOOO0OO00O00000O0} --share --api --disable-safe-unpickle --enable-insecure-extension-access --xformers --disable-console-progressbars --theme dark --upcast-sampling --cors-allow-origins=*')#line:389
217
  if os .path .exists (f'{wb}'):#line:392
218
  run (f'{w}.py')#line:393
219
  else :#line:394
 
1
  import argparse #line:1
2
  import binascii #line:2
3
  import ipywidgets as widgets #line:3
4
+ def str_to_bool (OO00OO000OO0O0O00 ):#line:7
5
+ if OO00OO000OO0O0O00 .lower ()in ('yes','true','t','y','1'):#line:8
6
  return True #line:9
7
+ elif OO00OO000OO0O0O00 .lower ()in ('no','false','f','n','0'):#line:10
8
  return False #line:11
9
  else :#line:12
10
+ raise argparse .ArgumentTypeError ('Invalid boolean value: {}'.format (OO00OO000OO0O0O00 ))#line:13
11
  parser =argparse .ArgumentParser ()#line:16
12
  parser .add_argument ('--Animatediff',type =str_to_bool )#line:18
13
  parser .add_argument ('--ControlNet',type =str )#line:19
 
46
  sai =base64 .b64decode (("c3RhYmxlLWRpZmZ1c2lvbi1zdGFiaWxpdHktYWk=").encode ('ascii')).decode ('ascii')#line:64
47
  sd =base64 .b64decode (("U3RhYmxlLWRpZmZ1c2lvbg==").encode ('ascii')).decode ('ascii')#line:65
48
  gwb =f'/content/drive/MyDrive/SD_DATA'#line:66
49
+ def cloudDriveSync (O000OOOOOOOO0OOO0 ,O000O0O00OOOO0OOO ='',O0000OOO00OO00OO0 =False ):#line:70
50
+ if not os .path .exists (O000OOOOOOOO0OOO0 ):#line:72
51
+ get_ipython ().system (f'mkdir {O000OOOOOOOO0OOO0}')#line:74
52
+ if not O0000OOO00OO00OO0 :#line:77
53
  return #line:78
54
+ get_ipython ().system (f'rm -rf {O000O0O00OOOO0OOO}')#line:81
55
+ get_ipython ().system (f'ln -s {O000OOOOOOOO0OOO0} {O000O0O00OOOO0OOO}')#line:83
56
  def initCloudDrive ():#line:86
57
  cloudDriveSync (f'{gwb}')#line:87
58
  cloudDriveSync (f'{gwb}/Config')#line:88
 
66
  get_ipython ().system (f'wget -O {gwb}/Config/config.json "https://huggingface.co/gmk123/colab/raw/main/config.json"')#line:99
67
  if not os .path .exists (f'{gwb}/styles.csv'):#line:101
68
  get_ipython ().system (f'wget -O {gwb}/styles.csv "https://huggingface.co/gmk123/colab/raw/main/styles.csv"')#line:103
69
+ def gitDownload (OO0000OOOO000O000 ,OOO0OO0OOO0OO0O00 ):#line:106
70
+ if os .path .exists (OOO0OO0OOO0OO0O00 ):#line:107
71
  return #line:108
72
+ get_ipython ().system (f'git clone {OO0000OOOO000O000} {OOO0OO0OOO0OO0O00}')#line:110
73
  def installAdditional ():#line:113
74
+ OO00O0000O0OO0O00 =[f'https://github.com/AlUlkesh/{sdw}-images-browser',f'https://github.com/etherealxx/batchlinks-{w}',f'https://github.com/camenduru/sd-civitai-browser',f'https://github.com/AUTOMATIC1111/{sdw}-rembg',f'https://github.com/thomasasfk/sd-{w}-aspect-ratio-helper',f'https://github.com/hanamizuki-ai/{sdw}-localization-zh_Hans',f'https://github.com/kohya-ss/sd-{w}-additional-networks',f'https://github.com/fkunn1326/openpose-editor',f'https://github.com/nonnonstop/sd-{w}-3d-open-pose-editor',f'https://github.com/IDEA-Research/DWPose',f'https://github.com/Physton/sd-{w}-prompt-all-in-one',f'https://github.com/adieyal/sd-dynamic-prompts',f'https://github.com/Bing-su/adetailer',f'https://github.com/Tencent/LightDiffusionFlow',f'https://github.com/picobyte/{sdw}-wd14-tagger',f'https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111',]#line:152
75
+ for O0O0OO0O0O0OOO0O0 in OO00O0000O0OO0O00 :#line:153
76
+ OOO0O0O0O00OO00OO =O0O0OO0O0O0OOO0O0 .split ('/')[-1 ]#line:155
77
+ if 'github'in O0O0OO0O0O0OOO0O0 :#line:157
78
+ get_ipython ().system (f'git clone {O0O0OO0O0O0OOO0O0} {wb}/extensions/{OOO0O0O0O00OO00OO}')#line:158
79
  cloudDriveSync (f'{gwb}/prompts',f'{wb}/extensions/sd-dynamic-prompts/wildcards',Drive_Map )#line:160
80
  get_ipython ().system (f'wget https://raw.githubusercontent.com/camenduru/{sdw}-scripts/main/run_n_times.py -O {wb}/scripts/run_n_times.py')#line:161
81
  get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/embed/upscale/resolve/main/4x-UltraSharp.pth -d {wb}/models/ESRGAN -o 4x-UltraSharp.pth')#line:162
 
102
  print ('Roop换脸启用')#line:193
103
  else :#line:194
104
  print ('Roop换脸不启用')#line:195
105
+ OO0000O000O00OOO0 =['control_v11e_sd15_ip2p.pth','control_v11e_sd15_shuffle.pth','control_v11f1e_sd15_tile.pth','control_v11f1p_sd15_depth.pth','control_v11p_sd15_canny.pth','control_v11p_sd15_inpaint.pth','control_v11p_sd15_lineart.pth','control_v11p_sd15_mlsd.pth','control_v11p_sd15_normalbae.pth','control_v11p_sd15_openpose.pth','control_v11p_sd15_scribble.pth','control_v11p_sd15_seg.pth','control_v11p_sd15_softedge.pth','control_v11p_sd15s2_lineart_anime.pth',]#line:213
106
  get_ipython ().system (f'rm -rf {wb}/extensions/sd-{w}-controlnet')#line:214
107
  if ControlNet =="Colab":#line:216
108
  gitDownload (f'https://github.com/Mikubill/sd-{w}-controlnet',f'{wb}/extensions/sd-{w}-controlnet')#line:217
109
+ for O000OOOO000O000OO in OO0000O000O00OOO0 :#line:218
110
+ get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/{O000OOOO000O000OO} -d {wb}/extensions/sd-{w}-controlnet/models -o {v}')#line:219
111
  elif ControlNet =="Google_Drive":#line:222
112
  cloudDriveSync (f'{gwb}/CntModels')#line:223
113
  gitDownload (f'https://github.com/Mikubill/sd-{w}-controlnet',f'{wb}/extensions/sd-{w}-controlnet')#line:224
114
+ for O000OOOO000O000OO in OO0000O000O00OOO0 :#line:225
115
+ if not os .path .exists (f'{gwb}/CntModels/{O000OOOO000O000OO}'):#line:226
116
+ get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/{O000OOOO000O000OO} -d {gwb}/CntModels -o {v}')#line:227
117
+ print ("创建扩展",f'{O000OOOO000O000OO}')#line:228
118
  else :#line:229
119
+ print ("扩展存在",f'{O000OOOO000O000OO}')#line:230
120
+ for O000OOOO000O000OO in os .listdir (f'{gwb}/CntModels'):#line:232
121
+ get_ipython ().system (f'ln -s {gwb}/CntModels/{O000OOOO000O000OO} {wb}/extensions/sd-{w}-controlnet/models')#line:234
122
  elif ControlNet =="No":#line:236
123
  print ("不使用 ControlNet")#line:237
124
  if Animatediff :#line:240
 
162
  def initLocal ():#line:297
163
  get_ipython ().system ('apt -y install -qq aria2 git')#line:299
164
  get_ipython ().system (f'pip install lmdb')#line:301
165
+ get_ipython ().system (f'pip install torch==2.1.2+cu121 torchvision==0.16.2+cu121 torchaudio==2.1.2+cu121 torchtext==0.17.0+cpu torchdata==0.8.0 --index-url https://download.pytorch.org/whl/cu121')#line:303
166
  get_ipython ().system (f'pip install xformers==0.0.23.post1')#line:304
167
  get_ipython ().run_line_magic ('cd','/content')#line:305
168
  get_ipython ().system (f'pip install -q basicsr')#line:306
169
+ with capture .capture_output ()as OO0O000OOO0O0000O :#line:308
170
+ def OO0OOO0OOO0OO00O0 (O00OO0000OO00O0OO ,O00OO0OOO0OO0OO0O ,OOOO0O000O0000O0O ):OO000O0OO0O0OO000 =widgets .Button (description =O00OO0000OO00O0OO ,disabled =True ,button_style =O00OO0OOO0OO0OO0O ,layout =widgets .Layout (min_width =OOOO0O000O0000O0O ));display (OO000O0OO0O0OO000 )#line:309
171
  get_ipython ().system (f'git clone -q --branch master https://github.com/AUTOMATIC1111/{sdw} /root/main')#line:311
172
+ with capture .capture_output ()as OO0O000OOO0O0000O :#line:313
173
  get_ipython ().run_line_magic ('cd','/content')#line:314
174
  get_ipython ().system (f'mkdir -p {wb}/repositories/{sai}')#line:316
175
  get_ipython ().system ('wget -q -i https://huggingface.co/gmk123/run/raw/main/A1111.txt')#line:317
 
210
  get_ipython ().system (f'sed -i \'s@possible_sd_paths =.*@possible_sd_paths = [\"{wb}/repositories/{sai}\"]@\' {wb}/modules/paths.py')#line:380
211
  get_ipython ().system (f'sed -i \'s@\\.\\.\\/@src/@g\' {wb}/modules/paths.py')#line:381
212
  get_ipython ().system (f'sed -i \'s@src/generative-models@generative-models@g\' {wb}/modules/paths.py')#line:382
213
+ def run (O0O000000O00O000O ):#line:386
214
  clear_output ()#line:387
215
  get_ipython ().run_line_magic ('cd',f'{wb}')#line:388
216
+ get_ipython ().system (f'python {O0O000000O00O000O} --share --api --disable-safe-unpickle --enable-insecure-extension-access --xformers --disable-console-progressbars --theme dark --upcast-sampling --cors-allow-origins=*')#line:389
217
  if os .path .exists (f'{wb}'):#line:392
218
  run (f'{w}.py')#line:393
219
  else :#line:394