gmk123 commited on
Commit
26da97c
·
verified ·
1 Parent(s): 282108b

Update sagemaker.py

Browse files
Files changed (1) hide show
  1. sagemaker.py +53 -50
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 (O0O00OO00000OO000 ,OO00O0OOOO0OOOOO0 ):#line:11
8
- if os .path .exists (OO00O0OOOO0OOOOO0 ):#line:12
9
  return #line:13
10
- get_ipython ().system (f'git clone {O0O00OO00000OO000} {OO00O0OOOO0OOOOO0}')#line:15
11
  def installAdditional ():#line:18
12
- OO0O00000OO00OO0O =[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 O00OO0OOO0OOO0000 in OO0O00000OO00OO0O :#line:59
14
- OO00O0000OOOOO000 =O00OO0OOO0OOO0000 .split ('/')[-1 ]#line:61
15
- if 'github'in O00OO0OOO0OOO0000 :#line:63
16
- get_ipython ().system (f'git clone --depth 1 {O00OO0OOO0OOO0000} {wb}/extensions/{OO00O0000OOOOO000}')#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
  gitDownload (f'https://huggingface.co/embed/negative',f'{wb}/embeddings/negative')#line:70
19
  get_ipython ().system (f'rm -rf {wb}/embeddings/negative/.git')#line:71
@@ -30,49 +30,52 @@ def installAdditional ():#line:18
30
  print ('Roop换脸启用')#line:88
31
  import subprocess #line:90
32
  def sync_tmp_folder ():#line:92
33
- OO0OOOO00O0OOOOO0 =[['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
34
- for O00OOO0O000O0OO0O in OO0OOOO00O0OOOOO0 :#line:100
35
- O00OO00OOO0O00O00 =[os .path .expanduser (OOO0O000O00OOO000 )for OOO0O000O00OOO000 in O00OOO0O000O0OO0O ]#line:101
36
- subprocess .run (O00OO00OOO0O00O00 ,check =True )#line:102
37
- def run_command (O0O0O00O0000000O0 ,O00O0000O000000O0 ):#line:104
38
- print (f"Please wait, {O00O0000O000000O0} is loading...")#line:105
39
- subprocess .run (O0O0O00O0000000O0 ,shell =True ,stdout =subprocess .DEVNULL ,stderr =subprocess .DEVNULL )#line:106
40
- print (f"{O00O0000O000000O0} ok!")#line:107
41
  def initLocal ():#line:110
42
- run_command ('conda install -y conda glib aria2','【 Installing Conda 】')#line:114
43
- run_command ('conda install -y -n base python=3.10.12','【 Installing Python 3.10 】')#line:115
 
 
44
  run_command ('conda clean -y --all','【 Cleaning Conda 】')#line:116
45
  run_command ('pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118','【 Installing Torch 】')#line:117
46
  run_command ('pip install xformers==0.0.20 triton==2.0.0','【 Installing xformers 】')#line:118
47
- clear_output ()#line:121
48
- get_ipython ().run_line_magic ('cd','/home/studio-lab-user')#line:122
49
- get_ipython ().system (f'git clone -q --branch master https://github.com/AUTOMATIC1111/stable-diffusion-webui {wb}')#line:125
50
- sync_tmp_folder ()#line:128
51
- clear_output ()#line:130
52
- get_ipython ().system (f'pip install -q basicsr')#line:135
53
- get_ipython ().system (f'pip install -q fake_useragent')#line:136
54
- installAdditional ()#line:141
55
- get_ipython ().system (f'rm -rf {wb}/config.json')#line:144
56
- get_ipython ().system (f'wget -O {wb}/config.json "https://huggingface.co/gmk123/colab/raw/main/config.json"')#line:145
57
- get_ipython ().system (f'wget -O {wb}/styles.csv "https://huggingface.co/gmk123/colab/raw/main/styles.csv"')#line:146
58
- clear_output ()#line:148
59
- 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:150
60
- 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:152
61
- 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:154
62
- get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ezioruan/inswapper_128.onnx/resolve/main/inswapper_128.onnx -d {wb}/models/roop -o inswapper_128.onnx')#line:156
63
- wise ="--listen --api --enable-insecure-extension-access --xformers --theme dark --gradio-queue --disable-console-progressbars --upcast-sampling --cors-allow-origins=*"#line:158
64
- ngrok_token =os .environ .get ('NGROK_TOKEN')#line:161
65
- wise +=f" --ngrok {ngrok_token}"#line:162
66
- def run (OOOO00O00O0O00O00 ):#line:165
67
- clear_output ()#line:166
68
- print (f'Ngrok内网令牌:{ngrok_token}')#line:167
69
- print (f'Ngrok注意事项:每个账号每月1G流量!!!请留意后台剩余流量。')#line:168
70
- print (f'Ngrok剩余流量:点击查看 -- https://dashboard.ngrok.com/usage')#line:169
71
- get_ipython ().system (f'mkdir -p /tmp/ControlNet')#line:170
72
- get_ipython ().run_line_magic ('cd',f'{wb}')#line:172
73
- get_ipython ().system (f'python {OOOO00O00O0O00O00} {wise}')#line:173
74
- if os .path .exists (f'{wb}'):#line:176
75
- run (f'webui.py')#line:178
76
- else :#line:179
77
- initLocal ()#line:181
78
- run (f'launch.py')#line:184
 
 
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 (OO000O00O0OOO0O00 ,O00OOO0O00O0OO00O ):#line:11
8
+ if os .path .exists (O00OOO0O00O0OO00O ):#line:12
9
  return #line:13
10
+ get_ipython ().system (f'git clone {OO000O00O0OOO0O00} {O00OOO0O00O0OO00O}')#line:15
11
  def installAdditional ():#line:18
12
+ OO000OOO0OO0O0O0O =[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 O0O00O0OOO00OOO0O in OO000OOO0OO0O0O0O :#line:59
14
+ OOOO00OOOOOO00OO0 =O0O00O0OOO00OOO0O .split ('/')[-1 ]#line:61
15
+ if 'github'in O0O00O0OOO00OOO0O :#line:63
16
+ get_ipython ().system (f'git clone --depth 1 {O0O00O0OOO00OOO0O} {wb}/extensions/{OOOO00OOOOOO00OO0}')#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
  gitDownload (f'https://huggingface.co/embed/negative',f'{wb}/embeddings/negative')#line:70
19
  get_ipython ().system (f'rm -rf {wb}/embeddings/negative/.git')#line:71
 
30
  print ('Roop换脸启用')#line:88
31
  import subprocess #line:90
32
  def sync_tmp_folder ():#line:92
33
+ OO00OO0O0O00O0OO0 =[['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
34
+ for OO00O0OOOOO0O0000 in OO00OO0O0O00O0OO0 :#line:100
35
+ OOO0O000OO000O00O =[os .path .expanduser (O000OOOOO00000OOO )for O000OOOOO00000OOO in OO00O0OOOOO0O0000 ]#line:101
36
+ subprocess .run (OOO0O000OO000O00O ,check =True )#line:102
37
+ def run_command (O0OOOOO00O00OOO0O ,OOOOOOO0000OO000O ):#line:104
38
+ print (f"Please wait, {OOOOOOO0000OO000O} is loading...")#line:105
39
+ subprocess .run (O0OOOOO00O00OOO0O ,shell =True ,stdout =subprocess .DEVNULL ,stderr =subprocess .DEVNULL )#line:106
40
+ print (f"{OOOOOOO0000OO000O} ok!")#line:107
41
  def initLocal ():#line:110
42
+ run_command ('conda install conda -y','Conda')#line:112
43
+ run_command ('conda update -n base conda -y','Update')#line:113
44
+ run_command ('conda install -n base python=3.10 -y','Python')#line:114
45
+ run_command ('conda install -q -y glib=2.51.0','glib')#line:115
46
  run_command ('conda clean -y --all','【 Cleaning Conda 】')#line:116
47
  run_command ('pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118','【 Installing Torch 】')#line:117
48
  run_command ('pip install xformers==0.0.20 triton==2.0.0','【 Installing xformers 】')#line:118
49
+ get_ipython ().system ('conda install -c conda-forge aria2')#line:119
50
+ clear_output ()#line:122
51
+ get_ipython ().run_line_magic ('cd','/home/studio-lab-user')#line:123
52
+ get_ipython ().system (f'git clone -q --branch master https://github.com/AUTOMATIC1111/stable-diffusion-webui {wb}')#line:126
53
+ sync_tmp_folder ()#line:129
54
+ clear_output ()#line:131
55
+ get_ipython ().system (f'pip install -q basicsr')#line:136
56
+ get_ipython ().system (f'pip install -q fake_useragent')#line:137
57
+ installAdditional ()#line:142
58
+ get_ipython ().system (f'rm -rf {wb}/config.json')#line:145
59
+ get_ipython ().system (f'wget -O {wb}/config.json "https://huggingface.co/gmk123/colab/raw/main/config.json"')#line:146
60
+ get_ipython ().system (f'wget -O {wb}/styles.csv "https://huggingface.co/gmk123/colab/raw/main/styles.csv"')#line:147
61
+ clear_output ()#line:149
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:151
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:153
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:155
65
+ get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ezioruan/inswapper_128.onnx/resolve/main/inswapper_128.onnx -d {wb}/models/roop -o inswapper_128.onnx')#line:157
66
+ wise ="--listen --api --enable-insecure-extension-access --xformers --theme dark --gradio-queue --disable-console-progressbars --upcast-sampling --cors-allow-origins=*"#line:159
67
+ ngrok_token =os .environ .get ('NGROK_TOKEN')#line:162
68
+ wise +=f" --ngrok {ngrok_token}"#line:163
69
+ def run (OOOOO0OOOO0000O00 ):#line:166
70
+ clear_output ()#line:167
71
+ print (f'Ngrok内网令牌:{ngrok_token}')#line:168
72
+ print (f'Ngrok注意事项:每个账号每月1G流量!!!请留意后台剩余流量。')#line:169
73
+ print (f'Ngrok剩余流量:点击查看 -- https://dashboard.ngrok.com/usage')#line:170
74
+ get_ipython ().system (f'mkdir -p /tmp/ControlNet')#line:171
75
+ get_ipython ().run_line_magic ('cd',f'{wb}')#line:173
76
+ get_ipython ().system (f'python {OOOOO0OOOO0000O00} {wise}')#line:174
77
+ if os .path .exists (f'{wb}'):#line:177
78
+ run (f'webui.py')#line:179
79
+ else :#line:180
80
+ initLocal ()#line:182
81
+ run (f'launch.py')#line:185