gmk123 commited on
Commit
71fc0da
·
verified ·
1 Parent(s): 55101af

Update sagemaker.py

Browse files
Files changed (1) hide show
  1. sagemaker.py +45 -45
sagemaker.py CHANGED
@@ -4,16 +4,16 @@ from IPython import get_ipython #line:3
4
  from IPython .utils import capture #line:4
5
  from IPython .display import clear_output #line:5
6
  wb =f'/home/studio-lab-user/stable-diffusion-webui'#line:8
7
- def gitDownload (O00OO0O0O00OOOOO0 ,OO00O0O00000OO000 ):#line:11
8
- if os .path .exists (OO00O0O00000OO000 ):#line:12
9
  return #line:13
10
- get_ipython ().system (f'git clone {O00OO0O0O00OOOOO0} {OO00O0O00000OO000}')#line:15
11
  def installAdditional ():#line:18
12
- O000OOO00OOOO0O0O =[f'https://github.com/AlUlkesh/stable-diffusion-webui-images-browser',f'https://github.com/etherealxx/batchlinks-webui',f'https://github.com/camenduru/sd-civitai-browser',f'https://github.com/thomasasfk/sd-webui-aspect-ratio-helper',f'https://github.com/kohya-ss/sd-webui-additional-networks',f'https://github.com/fkunn1326/openpose-editor',f'https://github.com/nonnonstop/sd-webui-3d-open-pose-editor',f'https://github.com/Physton/sd-webui-prompt-all-in-one',f'https://github.com/Bing-su/adetailer',f'https://github.com/picobyte/stable-diffusion-webui-wd14-tagger',f'https://github.com/Mikubill/sd-webui-controlnet',f'https://github.com/IDEA-Research/DWPose',f'https://github.com/hanamizuki-ai/stable-diffusion-webui-localization-zh_Hans',f'https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111',]#line:58
13
- for OOOO00000OO0O00OO in O000OOO00OOOO0O0O :#line:59
14
- O00OOO00000O0O0OO =OOOO00000OO0O00OO .split ('/')[-1 ]#line:61
15
- if 'github'in OOOO00000OO0O00OO :#line:63
16
- get_ipython ().system (f'git clone --depth 1 {OOOO00000OO0O00OO} {wb}/extensions/{O00OOO00000O0O0OO}')#line:64
17
  get_ipython ().system (f'wget https://raw.githubuserhome/studio-lab-user.com/camenduru/stable-diffusion-webui-scripts/main/run_n_times.py -O {wb}/scripts/run_n_times.py')#line:66
18
  clear_output ()#line:68
19
  gitDownload (f'https://huggingface.co/embed/negative',f'{wb}/embeddings/negative')#line:70
@@ -26,20 +26,20 @@ def installAdditional ():#line:18
26
  get_ipython ().system (f'rm -rf {wb}/extensions/a1111-sd-webui-tagcomplete/tags/danbooru.csv')#line:80
27
  get_ipython ().system (f'wget https://huggingface.co/gmk123/colab/raw/main/danbooru.csv -O {wb}/extensions/a1111-sd-webui-tagcomplete/tags/danbooru.csv')#line:81
28
  gitDownload (f'https://github.com/s0md3v/sd-webui-roop',f'{wb}/extensions/sd-webui-roop')#line:84
29
- get_ipython ().system (f'pip install insightface==0.7.3')#line:85
30
  get_ipython ().system (f'mkdir -p {wb}/models/roop')#line:86
31
  get_ipython ().system (f'wget https://huggingface.co/ezioruan/inswapper_128.onnx/resolve/main/inswapper_128.onnx -O {wb}/models/roop/inswapper_128.onnx')#line:87
32
  print ('Roop换脸启用')#line:88
33
  import subprocess #line:90
34
  def sync_tmp_folder ():#line:92
35
- O00OO0OO0OOO00000 =[['rm','-rf','~/tmp/*','~/tmp','~/stable-diffusion-webui/models/Stable-diffusion/tmp_models','~/stable-diffusion-webui/models/ControlNet'],['ln','-vs','/tmp','~/tmp'],['ln','-vs','/tmp/models','~/stable-diffusion-webui/models/Stable-diffusion/tmp_models'],['ln','-vs','/tmp/ControlNet','~/stable-diffusion-webui/models/ControlNet']]#line:98
36
- for OOOOO000O0O0OOOOO in O00OO0OO0OOO00000 :#line:100
37
- O00O000O00000O0OO =[os .path .expanduser (O0O000OOOO0OOO00O )for O0O000OOOO0OOO00O in OOOOO000O0O0OOOOO ]#line:101
38
- subprocess .run (O00O000O00000O0OO ,check =True )#line:102
39
- def run_command (OO0OO00O000OOOOOO ,O0OOOOO0O00OO00OO ):#line:104
40
- print (f"Please wait, {O0OOOOO0O00OO00OO} is loading...")#line:105
41
- subprocess .run (OO0OO00O000OOOOOO ,shell =True ,stdout =subprocess .DEVNULL ,stderr =subprocess .DEVNULL )#line:106
42
- print (f"{O0OOOOO0O00OO00OO} ok!")#line:107
43
  def initLocal ():#line:110
44
  run_command ('conda install -y conda glib psutil gperftools aria2 gdown wget','【 Installing Conda 】')#line:112
45
  run_command ('conda install -y -n base python=3.10.12','【 Installing Python 3.10 】')#line:113
@@ -50,31 +50,31 @@ def initLocal ():#line:110
50
  clear_output ()#line:120
51
  get_ipython ().run_line_magic ('cd','/home/studio-lab-user')#line:121
52
  get_ipython ().system (f'git clone -q --branch master https://github.com/AUTOMATIC1111/stable-diffusion-webui {wb}')#line:124
53
- sync_tmp_folder ()#line:127
54
- clear_output ()#line:129
55
- get_ipython ().system (f'pip install -q basicsr')#line:134
56
- get_ipython ().system (f'pip install -q fake_useragent')#line:135
57
- installAdditional ()#line:140
58
- get_ipython ().system (f'rm -rf {wb}/config.json')#line:143
59
- get_ipython ().system (f'wget -O {wb}/config.json "https://huggingface.co/gmk123/colab/raw/main/config.json"')#line:144
60
- get_ipython ().system (f'wget -O {wb}/styles.csv "https://huggingface.co/gmk123/colab/raw/main/styles.csv"')#line:145
61
- clear_output ()#line:147
62
- get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/192916 -d {wb}/models/Stable-diffusion -o MoyouArtificial_v1060.safetensors')#line:149
63
- get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors -d {wb}/models/VAE -o vae-ft-mse-840000-ema-pruned.safetensors')#line:151
64
- 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:153
65
- wise ="--listen --api --enable-insecure-extension-access --xformers --theme dark --gradio-queue --disable-console-progressbars --upcast-sampling --skip-version-check"#line:155
66
- ngrok_token =os .environ .get ('NGROK_TOKEN')#line:158
67
- wise +=f" --ngrok {ngrok_token}"#line:159
68
- def run (O00OOO0O0OOO00O00 ):#line:162
69
- clear_output ()#line:163
70
- print (f'Ngrok内网令牌:{ngrok_token}')#line:164
71
- print (f'Ngrok注意事项:每个账号每月1G流量!!!请留意后台剩余流量。')#line:165
72
- print (f'Ngrok剩余流量:点击查看 -- https://dashboard.ngrok.com/usage')#line:166
73
- get_ipython ().system (f'mkdir -p /tmp/ControlNet')#line:167
74
- get_ipython ().run_line_magic ('cd',f'{wb}')#line:169
75
- get_ipython ().system (f'python {O00OOO0O0OOO00O00} {wise}')#line:170
76
- if os .path .exists (f'{wb}'):#line:173
77
- run (f'webui.py')#line:175
78
- else :#line:176
79
- initLocal ()#line:178
80
- run (f'launch.py')#line:181
 
4
  from IPython .utils import capture #line:4
5
  from IPython .display import clear_output #line:5
6
  wb =f'/home/studio-lab-user/stable-diffusion-webui'#line:8
7
+ def gitDownload (O00O0O0OOO0OOO0OO ,O00O0000O0O000OOO ):#line:11
8
+ if os .path .exists (O00O0000O0O000OOO ):#line:12
9
  return #line:13
10
+ get_ipython ().system (f'git clone {O00O0O0OOO0OOO0OO} {O00O0000O0O000OOO}')#line:15
11
  def installAdditional ():#line:18
12
+ OOO0O0OO0000O00O0 =[f'https://github.com/AlUlkesh/stable-diffusion-webui-images-browser',f'https://github.com/etherealxx/batchlinks-webui',f'https://github.com/camenduru/sd-civitai-browser',f'https://github.com/thomasasfk/sd-webui-aspect-ratio-helper',f'https://github.com/kohya-ss/sd-webui-additional-networks',f'https://github.com/fkunn1326/openpose-editor',f'https://github.com/nonnonstop/sd-webui-3d-open-pose-editor',f'https://github.com/Physton/sd-webui-prompt-all-in-one',f'https://github.com/Bing-su/adetailer',f'https://github.com/picobyte/stable-diffusion-webui-wd14-tagger',f'https://github.com/Mikubill/sd-webui-controlnet',f'https://github.com/IDEA-Research/DWPose',f'https://github.com/hanamizuki-ai/stable-diffusion-webui-localization-zh_Hans',f'https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111',]#line:58
13
+ for OO0OOOOO00O0OO000 in OOO0O0OO0000O00O0 :#line:59
14
+ OOOO0OOO00O00O0OO =OO0OOOOO00O0OO000 .split ('/')[-1 ]#line:61
15
+ if 'github'in OO0OOOOO00O0OO000 :#line:63
16
+ get_ipython ().system (f'git clone --depth 1 {OO0OOOOO00O0OO000} {wb}/extensions/{OOOO0OOO00O00O0OO}')#line:64
17
  get_ipython ().system (f'wget https://raw.githubuserhome/studio-lab-user.com/camenduru/stable-diffusion-webui-scripts/main/run_n_times.py -O {wb}/scripts/run_n_times.py')#line:66
18
  clear_output ()#line:68
19
  gitDownload (f'https://huggingface.co/embed/negative',f'{wb}/embeddings/negative')#line:70
 
26
  get_ipython ().system (f'rm -rf {wb}/extensions/a1111-sd-webui-tagcomplete/tags/danbooru.csv')#line:80
27
  get_ipython ().system (f'wget https://huggingface.co/gmk123/colab/raw/main/danbooru.csv -O {wb}/extensions/a1111-sd-webui-tagcomplete/tags/danbooru.csv')#line:81
28
  gitDownload (f'https://github.com/s0md3v/sd-webui-roop',f'{wb}/extensions/sd-webui-roop')#line:84
29
+ get_ipython ().system (f'pip install -q insightface==0.7.3 onnx')#line:85
30
  get_ipython ().system (f'mkdir -p {wb}/models/roop')#line:86
31
  get_ipython ().system (f'wget https://huggingface.co/ezioruan/inswapper_128.onnx/resolve/main/inswapper_128.onnx -O {wb}/models/roop/inswapper_128.onnx')#line:87
32
  print ('Roop换脸启用')#line:88
33
  import subprocess #line:90
34
  def sync_tmp_folder ():#line:92
35
+ OO0O0OO00OOO0OOOO =[['rm','-rf','~/tmp/*','~/tmp','~/stable-diffusion-webui/models/Stable-diffusion/tmp_models','~/stable-diffusion-webui/models/ControlNet'],['ln','-vs','/tmp','~/tmp'],['ln','-vs','/tmp/models','~/stable-diffusion-webui/models/Stable-diffusion/tmp_models'],['ln','-vs','/tmp/ControlNet','~/stable-diffusion-webui/models/ControlNet']]#line:98
36
+ for OO0OO00OO0OOO0000 in OO0O0OO00OOO0OOOO :#line:100
37
+ OOO00000OO0000O00 =[os .path .expanduser (OOO00OO0OO000000O )for OOO00OO0OO000000O in OO0OO00OO0OOO0000 ]#line:101
38
+ subprocess .run (OOO00000OO0000O00 ,check =True )#line:102
39
+ def run_command (O0000OOOO0OOOO0OO ,O000O0O0OO0O0OO00 ):#line:104
40
+ print (f"Please wait, {O000O0O0OO0O0OO00} is loading...")#line:105
41
+ subprocess .run (O0000OOOO0OOOO0OO ,shell =True ,stdout =subprocess .DEVNULL ,stderr =subprocess .DEVNULL )#line:106
42
+ print (f"{O000O0O0OO0O0OO00} ok!")#line:107
43
  def initLocal ():#line:110
44
  run_command ('conda install -y conda glib psutil gperftools aria2 gdown wget','【 Installing Conda 】')#line:112
45
  run_command ('conda install -y -n base python=3.10.12','【 Installing Python 3.10 】')#line:113
 
50
  clear_output ()#line:120
51
  get_ipython ().run_line_magic ('cd','/home/studio-lab-user')#line:121
52
  get_ipython ().system (f'git clone -q --branch master https://github.com/AUTOMATIC1111/stable-diffusion-webui {wb}')#line:124
53
+ get_ipython ().system ('pip install -q -r requirements.txt basicsr')#line:127
54
+ sync_tmp_folder ()#line:130
55
+ clear_output ()#line:132
56
+ get_ipython ().system (f'pip install -q fake_useragent')#line:138
57
+ installAdditional ()#line:143
58
+ get_ipython ().system (f'rm -rf {wb}/config.json')#line:146
59
+ get_ipython ().system (f'wget -O {wb}/config.json "https://huggingface.co/gmk123/colab/raw/main/config.json"')#line:147
60
+ get_ipython ().system (f'wget -O {wb}/styles.csv "https://huggingface.co/gmk123/colab/raw/main/styles.csv"')#line:148
61
+ clear_output ()#line:150
62
+ get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://civitai.com/api/download/models/192916 -d {wb}/models/Stable-diffusion -o MoyouArtificial_v1060.safetensors')#line:152
63
+ get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors -d {wb}/models/VAE -o vae-ft-mse-840000-ema-pruned.safetensors')#line:154
64
+ 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:156
65
+ wise ="--listen --api --enable-insecure-extension-access --xformers --theme dark --gradio-queue --disable-console-progressbars --upcast-sampling --skip-version-check"#line:158
66
+ ngrok_token =os .environ .get ('NGROK_TOKEN')#line:161
67
+ wise +=f" --ngrok {ngrok_token}"#line:162
68
+ def run (OO000O00OOO0O0O00 ):#line:165
69
+ clear_output ()#line:166
70
+ print (f'Ngrok内网令牌:{ngrok_token}')#line:167
71
+ print (f'Ngrok注意事项:每个账号每月1G流量!!!请留意后台剩余流量。')#line:168
72
+ print (f'Ngrok剩余流量:点击查看 -- https://dashboard.ngrok.com/usage')#line:169
73
+ get_ipython ().system (f'mkdir -p /tmp/ControlNet')#line:170
74
+ get_ipython ().run_line_magic ('cd',f'{wb}')#line:172
75
+ get_ipython ().system (f'python {OO000O00OOO0O0O00} {wise}')#line:173
76
+ if os .path .exists (f'{wb}'):#line:176
77
+ run (f'webui.py')#line:178
78
+ else :#line:179
79
+ initLocal ()#line:181
80
+ run (f'launch.py')#line:184