Instructions to use gmk123/colab with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use gmk123/colab with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("gmk123/colab", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update sagemaker.py
Browse files- 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 (
|
| 8 |
-
if os .path .exists (
|
| 9 |
return #line:13
|
| 10 |
-
get_ipython ().system (f'git clone {
|
| 11 |
def installAdditional ():#line:18
|
| 12 |
-
|
| 13 |
-
for
|
| 14 |
-
|
| 15 |
-
if 'github'in
|
| 16 |
-
get_ipython ().system (f'git clone --depth 1 {
|
| 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 |
-
|
| 40 |
-
for
|
| 41 |
-
|
| 42 |
-
subprocess .run (
|
| 43 |
-
def run_command (
|
| 44 |
-
print (f"Please wait, {
|
| 45 |
-
subprocess .run (
|
| 46 |
-
print (f"{
|
| 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 |
-
|
| 55 |
-
|
| 56 |
-
get_ipython ().
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
get_ipython ().system (f'pip install -q
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
get_ipython ().system (f'
|
| 64 |
-
get_ipython ().system (f'wget -O {wb}/
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://
|
| 68 |
-
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
print (f'Ngrok
|
| 76 |
-
print (f'Ngrok剩余流量
|
| 77 |
-
|
| 78 |
-
get_ipython ().
|
| 79 |
-
get_ipython ().
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
|
|
| 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
|