gmk123 commited on
Commit
1afcef2
·
verified ·
1 Parent(s): b6c54de

Update sagemaker.py

Browse files
Files changed (1) hide show
  1. sagemaker.py +48 -47
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 (OO0O0O0OOOO0O0OO0 ,O0O00OOOOO000000O ):#line:11
8
- if os .path .exists (O0O00OOOOO000000O ):#line:12
9
  return #line:13
10
- get_ipython ().system (f'git clone {OO0O0O0OOOO0O0OO0} {O0O00OOOOO000000O}')#line:15
11
  def installAdditional ():#line:18
12
- OOO0O0O000O00OOO0 =[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 O0OO0OOOOO00O000O in OOO0O0O000O00OOO0 :#line:59
14
- OO000OOOOO000OOOO =O0OO0OOOOO00O000O .split ('/')[-1 ]#line:61
15
- if 'github'in O0OO0OOOOO00O000O :#line:63
16
- get_ipython ().system (f'git clone --depth 1 {O0OO0OOOOO00O000O} {wb}/extensions/{OO000OOOOO000OOOO}')#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
@@ -36,14 +36,14 @@ def installAdditional ():#line:18
36
  print ('Reactor换脸插件启用')#line:92
37
  import subprocess #line:94
38
  def sync_tmp_folder ():#line:96
39
- OOOO000OOOOO0000O =[['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:102
40
- for O00O0O0OO000O0O00 in OOOO000OOOOO0000O :#line:104
41
- O0O0OO0000O00O00O =[os .path .expanduser (O00OOO0O00OOO000O )for O00OOO0O00OOO000O in O00O0O0OO000O0O00 ]#line:105
42
- subprocess .run (O0O0OO0000O00O00O ,check =True )#line:106
43
- def run_command (O000OO000OO0O0000 ,OO0OO00OO0O00O00O ):#line:108
44
- print (f"Please wait, {OO0OO00OO0O00O00O} is loading...")#line:109
45
- subprocess .run (O000OO000OO0O0000 ,shell =True ,stdout =subprocess .DEVNULL ,stderr =subprocess .DEVNULL )#line:110
46
- print (f"{OO0OO00OO0O00O00O} ok!")#line:111
47
  def initLocal ():#line:114
48
  run_command ('conda install -y conda glib psutil gperftools aria2 gdown wget','【 Installing Conda 】')#line:116
49
  run_command ('conda install -y -n base python=3.10.12','【 Installing Python 3.10 】')#line:117
@@ -51,34 +51,35 @@ def initLocal ():#line:114
51
  run_command ('pip install torch==2.1.2+cu121 torchvision==0.16.2+cu121 torchaudio==2.1.2 --extra-index-url https://download.pytorch.org/whl/cu121','【 Installing Torch 】')#line:119
52
  run_command ('pip install xformers==0.0.23.post1 triton==2.1.0','【 Installing xformers 】')#line:120
53
  get_ipython ().system ('pip install -q tqdm')#line:122
54
- clear_output ()#line:124
55
- get_ipython ().run_line_magic ('cd','/home/studio-lab-user')#line:125
56
- get_ipython ().system (f'git clone -q --branch master https://github.com/AUTOMATIC1111/stable-diffusion-webui {wb}')#line:128
57
- sync_tmp_folder ()#line:131
58
- clear_output ()#line:133
59
- get_ipython ().system (f'pip install -q basicsr')#line:138
60
- get_ipython ().system (f'pip install -q fake_useragent')#line:139
61
- installAdditional ()#line:144
62
- get_ipython ().system (f'rm -rf {wb}/config.json')#line:147
63
- get_ipython ().system (f'wget -O {wb}/config.json "https://huggingface.co/gmk123/colab/raw/main/config.json"')#line:148
64
- get_ipython ().system (f'wget -O {wb}/styles.csv "https://huggingface.co/gmk123/colab/raw/main/styles.csv"')#line:149
65
- clear_output ()#line:151
66
- 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:153
67
- 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:155
68
- 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:157
69
- wise ="--listen --api --enable-insecure-extension-access --xformers --theme dark --gradio-queue --disable-console-progressbars --upcast-sampling --skip-version-check"#line:159
70
- ngrok_token =os .environ .get ('NGROK_TOKEN')#line:162
71
- wise +=f" --ngrok {ngrok_token}"#line:163
72
- def run (OOOO000O00OO00O00 ):#line:166
73
- clear_output ()#line:167
74
- print (f'Ngrok内网令牌:{ngrok_token}')#line:168
75
- print (f'Ngrok注意事项:每个账号每月1G流量!!!请留意后台剩余流量。')#line:169
76
- print (f'Ngrok剩余流量:点击查看 -- https://dashboard.ngrok.com/usage')#line:170
77
- get_ipython ().system (f'mkdir -p /tmp/ControlNet')#line:171
78
- get_ipython ().run_line_magic ('cd',f'{wb}')#line:173
79
- get_ipython ().system (f'python {OOOO000O00OO00O00} {wise}')#line:174
80
- if os .path .exists (f'{wb}'):#line:177
81
- run (f'webui.py')#line:179
82
- else :#line:180
83
- initLocal ()#line:182
84
- run (f'launch.py')#line:185
 
 
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 (OO0OO0OO00OO00O00 ,O0000O0OOOO0OO00O ):#line:11
8
+ if os .path .exists (O0000O0OOOO0OO00O ):#line:12
9
  return #line:13
10
+ get_ipython ().system (f'git clone {OO0OO0OO00OO00O00} {O0000O0OOOO0OO00O}')#line:15
11
  def installAdditional ():#line:18
12
+ O0000O0O0O0OOO00O =[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 O00OO0O00OOO00OO0 in O0000O0O0O0OOO00O :#line:59
14
+ OOO000O0O0O00OO0O =O00OO0O00OOO00OO0 .split ('/')[-1 ]#line:61
15
+ if 'github'in O00OO0O00OOO00OO0 :#line:63
16
+ get_ipython ().system (f'git clone --depth 1 {O00OO0O00OOO00OO0} {wb}/extensions/{OOO000O0O0O00OO0O}')#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
 
36
  print ('Reactor换脸插件启用')#line:92
37
  import subprocess #line:94
38
  def sync_tmp_folder ():#line:96
39
+ OO000O0O0O000O0O0 =[['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:102
40
+ for O0O00O0OOO000O000 in OO000O0O0O000O0O0 :#line:104
41
+ OO0000OOOOOO0O0OO =[os .path .expanduser (OOO000OOOOOOOOOOO )for OOO000OOOOOOOOOOO in O0O00O0OOO000O000 ]#line:105
42
+ subprocess .run (OO0000OOOOOO0O0OO ,check =True )#line:106
43
+ def run_command (O0000O00OOO0OOO00 ,OOO0000O000O0O000 ):#line:108
44
+ print (f"Please wait, {OOO0000O000O0O000} is loading...")#line:109
45
+ subprocess .run (O0000O00OOO0OOO00 ,shell =True ,stdout =subprocess .DEVNULL ,stderr =subprocess .DEVNULL )#line:110
46
+ print (f"{OOO0000O000O0O000} ok!")#line:111
47
  def initLocal ():#line:114
48
  run_command ('conda install -y conda glib psutil gperftools aria2 gdown wget','【 Installing Conda 】')#line:116
49
  run_command ('conda install -y -n base python=3.10.12','【 Installing Python 3.10 】')#line:117
 
51
  run_command ('pip install torch==2.1.2+cu121 torchvision==0.16.2+cu121 torchaudio==2.1.2 --extra-index-url https://download.pytorch.org/whl/cu121','【 Installing Torch 】')#line:119
52
  run_command ('pip install xformers==0.0.23.post1 triton==2.1.0','【 Installing xformers 】')#line:120
53
  get_ipython ().system ('pip install -q tqdm')#line:122
54
+ get_ipython ().system ('pip install matplotlib')#line:123
55
+ clear_output ()#line:125
56
+ get_ipython ().run_line_magic ('cd','/home/studio-lab-user')#line:126
57
+ get_ipython ().system (f'git clone -q --branch master https://github.com/AUTOMATIC1111/stable-diffusion-webui {wb}')#line:129
58
+ sync_tmp_folder ()#line:132
59
+ clear_output ()#line:134
60
+ get_ipython ().system (f'pip install -q basicsr')#line:139
61
+ get_ipython ().system (f'pip install -q fake_useragent')#line:140
62
+ installAdditional ()#line:145
63
+ get_ipython ().system (f'rm -rf {wb}/config.json')#line:148
64
+ get_ipython ().system (f'wget -O {wb}/config.json "https://huggingface.co/gmk123/colab/raw/main/config.json"')#line:149
65
+ get_ipython ().system (f'wget -O {wb}/styles.csv "https://huggingface.co/gmk123/colab/raw/main/styles.csv"')#line:150
66
+ clear_output ()#line:152
67
+ 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:154
68
+ 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:156
69
+ 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:158
70
+ wise ="--listen --api --enable-insecure-extension-access --xformers --theme dark --gradio-queue --disable-console-progressbars --upcast-sampling --skip-version-check"#line:160
71
+ ngrok_token =os .environ .get ('NGROK_TOKEN')#line:163
72
+ wise +=f" --ngrok {ngrok_token}"#line:164
73
+ def run (OO000OO0000OO000O ):#line:167
74
+ clear_output ()#line:168
75
+ print (f'Ngrok内网令牌:{ngrok_token}')#line:169
76
+ print (f'Ngrok注意事项:每个账号每月1G流量!!!请留意后台剩余流量。')#line:170
77
+ print (f'Ngrok剩余流量:点击查看 -- https://dashboard.ngrok.com/usage')#line:171
78
+ get_ipython ().system (f'mkdir -p /tmp/ControlNet')#line:172
79
+ get_ipython ().run_line_magic ('cd',f'{wb}')#line:174
80
+ get_ipython ().system (f'python {OO000OO0000OO000O} {wise}')#line:175
81
+ if os .path .exists (f'{wb}'):#line:178
82
+ run (f'webui.py')#line:180
83
+ else :#line:181
84
+ initLocal ()#line:183
85
+ run (f'launch.py')#line:186