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 comfyui_tmp.py
Browse files- comfyui_tmp.py +82 -82
comfyui_tmp.py
CHANGED
|
@@ -4,88 +4,88 @@ 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/ComfyUI'#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 |
get_ipython ().system (f'git clone --recursive https://github.com/ssitu/ComfyUI_UltimateSDUpscale {wb}/custom_nodes/ComfyUI_UltimateSDUpscale')#line:20
|
| 13 |
-
|
| 14 |
-
for
|
| 15 |
-
|
| 16 |
-
if 'github'in
|
| 17 |
-
get_ipython ().system (f'git clone --depth 1 {
|
| 18 |
-
get_ipython ().system (f'wget https://huggingface.co/pantat88/ui/resolve/main/embeddings.zip -O {wb}/models/embeddings/embeddings.zip')#line:
|
| 19 |
-
get_ipython ().system (f'unzip {wb}/models/embeddings/embeddings.zip -d {wb}/models/embeddings')#line:
|
| 20 |
-
get_ipython ().system (f'rm {wb}/models/embeddings/embeddings.zip')#line:
|
| 21 |
-
get_ipython ().system (f'wget https://civitai.com/api/download/models/150491 -O {wb}/models/embeddings/edgQuality.pt')#line:
|
| 22 |
-
clear_output ()#line:
|
| 23 |
-
import subprocess #line:
|
| 24 |
-
def sync_tmp_folder ():#line:
|
| 25 |
-
|
| 26 |
-
for
|
| 27 |
-
|
| 28 |
-
subprocess .run (
|
| 29 |
-
def run_command (
|
| 30 |
-
print (f"Please wait, {
|
| 31 |
-
subprocess .run (
|
| 32 |
-
print (f"{
|
| 33 |
-
def zrok ():#line:
|
| 34 |
-
try :#line:
|
| 35 |
-
|
| 36 |
-
os .makedirs (
|
| 37 |
-
subprocess .run (["curl","-sLO","https://github.com/openziti/zrok/releases/download/v0.4.23/zrok_0.4.23_linux_amd64.tar.gz"],check =True )#line:
|
| 38 |
-
subprocess .run (["tar","-xzf","zrok_0.4.23_linux_amd64.tar.gz","-C",
|
| 39 |
-
os .remove ("zrok_0.4.23_linux_amd64.tar.gz")#line:
|
| 40 |
-
except Exception as
|
| 41 |
-
print (f"An error occurred: {
|
| 42 |
-
def initLocal ():#line:
|
| 43 |
-
run_command ('conda install -y conda glib gxx_linux-64 ffmpeg imageio imageio-ffmpeg av gst-libav psutil pyngrok gperftools aria2 gdown','【 Installing Conda 】')#line:
|
| 44 |
-
run_command ('conda install -y -n base python=3.10.12','【 Installing Python 3.10 】')#line:
|
| 45 |
-
run_command ('conda clean -y --all','【 Cleaning Conda 】')#line:
|
| 46 |
-
get_ipython ().system ('pip install -q tqdm')#line:
|
| 47 |
-
clear_output ()#line:
|
| 48 |
-
get_ipython ().run_line_magic ('cd','/home/studio-lab-user')#line:
|
| 49 |
-
with capture .capture_output ()as
|
| 50 |
-
def
|
| 51 |
-
get_ipython ().system (f'git clone -q https://github.com/comfyanonymous/ComfyUI {wb}')#line:
|
| 52 |
-
with capture .capture_output ()as
|
| 53 |
-
get_ipython ().run_line_magic ('cd',f'{wb}')#line:
|
| 54 |
-
get_ipython ().system ("pip install -q https://download.pytorch.org/whl/cu118/xformers-0.0.22.post4%2Bcu118-cp310-cp310-manylinux2014_x86_64.whl -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu118")#line:
|
| 55 |
-
get_ipython ().system ('pip install -q -r requirements.txt')#line:
|
| 56 |
-
get_ipython ().system ('pip install -q opencv-python==4.7.0.72 transformers==4.26.1 tokenizers clip-interrogator')#line:
|
| 57 |
-
if os .path .isfile ("custom_nodes/ComfyUI-Manager/scripts/colab-dependencies.py"):#line:
|
| 58 |
-
get_ipython ().system ("python custom_nodes/ComfyUI-Manager/scripts/colab-dependencies.py > /dev/null")#line:
|
| 59 |
-
get_ipython ().system ("rm -rf ~/.cache/* ~/ComfyUI/custom_nodes/")#line:
|
| 60 |
-
get_ipython ().system (f'pip install -q basicsr')#line:
|
| 61 |
-
clear_output ()#line:
|
| 62 |
-
zrok ()#line:
|
| 63 |
-
get_ipython ().system (f'wget https://huggingface.co/gmk123/comfyui/raw/main/zrun.py -O {wb}/zrun.py')#line:
|
| 64 |
-
get_ipython ().system (f'wget https://huggingface.co/gmk123/comfyui/raw/main/zrok.py -O {wb}/zrok.py')#line:
|
| 65 |
-
installAdditional ()#line:
|
| 66 |
-
sync_tmp_folder ()#line:
|
| 67 |
-
clear_output ()#line:
|
| 68 |
-
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/checkpoints -o MoyouArtificial_v1060.safetensors')#line:
|
| 69 |
-
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:
|
| 70 |
-
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth -d {wb}/models/upscale_models -o 4x-UltraSharp.pth')#line:
|
| 71 |
-
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/4x-AnimeSharp.pth -d {wb}/models/upscale_models -o 4x-AnimeSharp.pth')#line:
|
| 72 |
-
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth -d {wb}/models/upscale_models -o 8x_RealESRGAN.pth')#line:
|
| 73 |
-
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth -d {wb}/models/upscale_models -o 4x_RealisticRescaler_100000_G.pth')#line:
|
| 74 |
-
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/4x_NMKD-Superscale-SP_178000_G.pth -d {wb}/models/upscale_models -o 4x_NMKD-Superscale-SP_178000_G.pth')#line:
|
| 75 |
-
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth -d {wb}/models/facerestore_models -o codeformer.pth')#line:
|
| 76 |
-
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth -d {wb}/models/facerestore_models -o GFPGANv1.4.pth')#line:
|
| 77 |
-
wise =" --
|
| 78 |
-
ngrok_token =os .environ .get ('NGROK_TOKEN')#line:
|
| 79 |
-
wise +=f" --ngrok {ngrok_token}"#line:
|
| 80 |
-
def run (
|
| 81 |
-
clear_output ()#line:
|
| 82 |
-
print (f'建议使用第二步:zrok部署,无需魔法,没有流量限制')#line:
|
| 83 |
-
print (f'Ngrok注意事项:每个账号每月1G流量!需配合魔法使用')#line:
|
| 84 |
-
get_ipython ().system (f'mkdir -p /tmp/ControlNet')#line:
|
| 85 |
-
get_ipython ().run_line_magic ('cd',f'{wb}')#line:
|
| 86 |
-
get_ipython ().system (f'python {
|
| 87 |
-
if os .path .exists (f'{wb}'):#line:
|
| 88 |
-
run (f'main.py')#line:
|
| 89 |
-
else :#line:
|
| 90 |
-
initLocal ()#line:
|
| 91 |
-
run (f'main.py')#line:
|
|
|
|
| 4 |
from IPython .utils import capture #line:4
|
| 5 |
from IPython .display import clear_output #line:5
|
| 6 |
wb =f'/home/studio-lab-user/ComfyUI'#line:8
|
| 7 |
+
def gitDownload (O0OOO00O0O00OO00O ,O000O00OOOO0O0OO0 ):#line:11
|
| 8 |
+
if os .path .exists (O000O00OOOO0O0OO0 ):#line:12
|
| 9 |
return #line:13
|
| 10 |
+
get_ipython ().system (f'git clone {O0OOO00O0O00OO00O} {O000O00OOOO0O0OO0}')#line:15
|
| 11 |
def installAdditional ():#line:18
|
| 12 |
get_ipython ().system (f'git clone --recursive https://github.com/ssitu/ComfyUI_UltimateSDUpscale {wb}/custom_nodes/ComfyUI_UltimateSDUpscale')#line:20
|
| 13 |
+
O00OOO0O0O00O0000 =['https://github.com/ltdrdata/ComfyUI-Manager','https://github.com/pythongosssss/ComfyUI-Custom-Scripts','https://github.com/city96/SD-Latent-Upscaler','https://github.com/jags111/efficiency-nodes-comfyui','https://github.com/BlenderNeko/ComfyUI_ADV_CLIP_emb','https://github.com/ssitu/ComfyUI_NestedNodeBuilder','https://github.com/Kosinkadink/ComfyUI-Advanced-ControlNet','https://github.com/Fannovel16/comfyui_controlnet_aux','https://github.com/SLAPaper/ComfyUI-Image-Selector','https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes','https://github.com/FizzleDorf/ComfyUI_FizzNodes','https://github.com/WASasquatch/was-node-suite-comfyui','https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite','https://github.com/Gourieff/comfyui-reactor-node','https://github.com/AIGODLIKE/AIGODLIKE-ComfyUI-Translation',]#line:39
|
| 14 |
+
for OOOOO0O00O0OO0OO0 in O00OOO0O0O00O0000 :#line:40
|
| 15 |
+
O00O000OOO0O0000O =OOOOO0O00O0OO0OO0 .split ('/')[-1 ]#line:42
|
| 16 |
+
if 'github'in OOOOO0O00O0OO0OO0 :#line:44
|
| 17 |
+
get_ipython ().system (f'git clone --depth 1 {OOOOO0O00O0OO0OO0} {wb}/custom_nodes/{O00O000OOO0O0000O}')#line:45
|
| 18 |
+
get_ipython ().system (f'wget https://huggingface.co/pantat88/ui/resolve/main/embeddings.zip -O {wb}/models/embeddings/embeddings.zip')#line:48
|
| 19 |
+
get_ipython ().system (f'unzip {wb}/models/embeddings/embeddings.zip -d {wb}/models/embeddings')#line:50
|
| 20 |
+
get_ipython ().system (f'rm {wb}/models/embeddings/embeddings.zip')#line:51
|
| 21 |
+
get_ipython ().system (f'wget https://civitai.com/api/download/models/150491 -O {wb}/models/embeddings/edgQuality.pt')#line:52
|
| 22 |
+
clear_output ()#line:54
|
| 23 |
+
import subprocess #line:56
|
| 24 |
+
def sync_tmp_folder ():#line:58
|
| 25 |
+
O00000O0000O0OOO0 =[['rm','-rf','~/tmp/*','~/tmp','~/ComfyUI/models/checkpoints','~/ComfyUI/models/loras','~/ComfyUI/models/controlnet'],['ln','-vs','/tmp','~/tmp'],['ln','-vs','/tmp/models','~/ComfyUI/models/checkpoints'],['ln','-vs','/tmp/Lora','~/ComfyUI/models/loras'],['ln','-vs','/tmp/ControlNet','~/ComfyUI/models/controlnet']]#line:65
|
| 26 |
+
for OOOO0OO00O0O0000O in O00000O0000O0OOO0 :#line:66
|
| 27 |
+
OOOOO00O0OO0OOOO0 =[os .path .expanduser (O0OO0OOOO0000OOOO )for O0OO0OOOO0000OOOO in OOOO0OO00O0O0000O ]#line:67
|
| 28 |
+
subprocess .run (OOOOO00O0OO0OOOO0 ,check =True )#line:68
|
| 29 |
+
def run_command (OO0OO00OO0OOO0OO0 ,OOOO00000OO0O0OO0 ):#line:71
|
| 30 |
+
print (f"Please wait, {OOOO00000OO0O0OO0} is loading...")#line:72
|
| 31 |
+
subprocess .run (OO0OO00OO0OOO0OO0 ,shell =True ,stdout =subprocess .DEVNULL ,stderr =subprocess .DEVNULL )#line:73
|
| 32 |
+
print (f"{OOOO00000OO0O0OO0} ok!")#line:74
|
| 33 |
+
def zrok ():#line:77
|
| 34 |
+
try :#line:78
|
| 35 |
+
OO0OOO0OOO0000OO0 ="/home/studio-lab-user/.zrok/bin"#line:79
|
| 36 |
+
os .makedirs (OO0OOO0OOO0000OO0 ,exist_ok =True )#line:80
|
| 37 |
+
subprocess .run (["curl","-sLO","https://github.com/openziti/zrok/releases/download/v0.4.23/zrok_0.4.23_linux_amd64.tar.gz"],check =True )#line:81
|
| 38 |
+
subprocess .run (["tar","-xzf","zrok_0.4.23_linux_amd64.tar.gz","-C",OO0OOO0OOO0000OO0 ,"--wildcards","*zrok"],check =True )#line:82
|
| 39 |
+
os .remove ("zrok_0.4.23_linux_amd64.tar.gz")#line:83
|
| 40 |
+
except Exception as O0000OOO0OO0OOO00 :#line:85
|
| 41 |
+
print (f"An error occurred: {O0000OOO0OO0OOO00}")#line:86
|
| 42 |
+
def initLocal ():#line:90
|
| 43 |
+
run_command ('conda install -y conda glib gxx_linux-64 ffmpeg imageio imageio-ffmpeg av gst-libav psutil pyngrok gperftools aria2 gdown','【 Installing Conda 】')#line:92
|
| 44 |
+
run_command ('conda install -y -n base python=3.10.12','【 Installing Python 3.10 】')#line:93
|
| 45 |
+
run_command ('conda clean -y --all','【 Cleaning Conda 】')#line:94
|
| 46 |
+
get_ipython ().system ('pip install -q tqdm')#line:98
|
| 47 |
+
clear_output ()#line:100
|
| 48 |
+
get_ipython ().run_line_magic ('cd','/home/studio-lab-user')#line:101
|
| 49 |
+
with capture .capture_output ()as O00O0OO0OOO00O0OO :#line:104
|
| 50 |
+
def O0000O00OOOOOO0O0 (OO000O00OOOOO0OO0 ,O0O00O00OO0OO0O0O ,O0OO000000000OO0O ):OO000OOO0O0O00O00 =widgets .Button (description =OO000O00OOOOO0OO0 ,disabled =True ,button_style =O0O00O00OO0OO0O0O ,layout =widgets .Layout (min_width =O0OO000000000OO0O ));display (OO000OOO0O0O00O00 )#line:105
|
| 51 |
+
get_ipython ().system (f'git clone -q https://github.com/comfyanonymous/ComfyUI {wb}')#line:107
|
| 52 |
+
with capture .capture_output ()as O00O0OO0OOO00O0OO :#line:109
|
| 53 |
+
get_ipython ().run_line_magic ('cd',f'{wb}')#line:110
|
| 54 |
+
get_ipython ().system ("pip install -q https://download.pytorch.org/whl/cu118/xformers-0.0.22.post4%2Bcu118-cp310-cp310-manylinux2014_x86_64.whl -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu118")#line:112
|
| 55 |
+
get_ipython ().system ('pip install -q -r requirements.txt')#line:113
|
| 56 |
+
get_ipython ().system ('pip install -q opencv-python==4.7.0.72 transformers==4.26.1 tokenizers clip-interrogator')#line:114
|
| 57 |
+
if os .path .isfile ("custom_nodes/ComfyUI-Manager/scripts/colab-dependencies.py"):#line:116
|
| 58 |
+
get_ipython ().system ("python custom_nodes/ComfyUI-Manager/scripts/colab-dependencies.py > /dev/null")#line:117
|
| 59 |
+
get_ipython ().system ("rm -rf ~/.cache/* ~/ComfyUI/custom_nodes/")#line:119
|
| 60 |
+
get_ipython ().system (f'pip install -q basicsr')#line:121
|
| 61 |
+
clear_output ()#line:123
|
| 62 |
+
zrok ()#line:127
|
| 63 |
+
get_ipython ().system (f'wget https://huggingface.co/gmk123/comfyui/raw/main/zrun.py -O {wb}/zrun.py')#line:128
|
| 64 |
+
get_ipython ().system (f'wget https://huggingface.co/gmk123/comfyui/raw/main/zrok.py -O {wb}/zrok.py')#line:129
|
| 65 |
+
installAdditional ()#line:132
|
| 66 |
+
sync_tmp_folder ()#line:135
|
| 67 |
+
clear_output ()#line:142
|
| 68 |
+
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/checkpoints -o MoyouArtificial_v1060.safetensors')#line:144
|
| 69 |
+
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:146
|
| 70 |
+
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/4x-UltraSharp.pth -d {wb}/models/upscale_models -o 4x-UltraSharp.pth')#line:148
|
| 71 |
+
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/4x-AnimeSharp.pth -d {wb}/models/upscale_models -o 4x-AnimeSharp.pth')#line:149
|
| 72 |
+
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/8x_RealESRGAN.pth -d {wb}/models/upscale_models -o 8x_RealESRGAN.pth')#line:150
|
| 73 |
+
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/4x_RealisticRescaler_100000_G.pth -d {wb}/models/upscale_models -o 4x_RealisticRescaler_100000_G.pth')#line:151
|
| 74 |
+
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/pantat88/ui/resolve/main/4x_NMKD-Superscale-SP_178000_G.pth -d {wb}/models/upscale_models -o 4x_NMKD-Superscale-SP_178000_G.pth')#line:152
|
| 75 |
+
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth -d {wb}/models/facerestore_models -o codeformer.pth')#line:154
|
| 76 |
+
get_ipython ().system (f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth -d {wb}/models/facerestore_models -o GFPGANv1.4.pth')#line:155
|
| 77 |
+
wise =" --listen --port 8188 --preview-method auto --enable-cors-header --use-pytorch-cross-attention --disable-xformers"#line:157
|
| 78 |
+
ngrok_token =os .environ .get ('NGROK_TOKEN')#line:160
|
| 79 |
+
wise +=f" --ngrok {ngrok_token}"#line:161
|
| 80 |
+
def run (O000OOO0OOOO0O0OO ):#line:164
|
| 81 |
+
clear_output ()#line:165
|
| 82 |
+
print (f'建议使用第二步:zrok部署,无需魔法,没有流量限制')#line:166
|
| 83 |
+
print (f'Ngrok注意事项:每个账号每月1G流量!需配合魔法使用')#line:167
|
| 84 |
+
get_ipython ().system (f'mkdir -p /tmp/ControlNet')#line:168
|
| 85 |
+
get_ipython ().run_line_magic ('cd',f'{wb}')#line:170
|
| 86 |
+
get_ipython ().system (f'python {O000OOO0OOOO0O0OO} {wise}')#line:171
|
| 87 |
+
if os .path .exists (f'{wb}'):#line:174
|
| 88 |
+
run (f'main.py')#line:176
|
| 89 |
+
else :#line:177
|
| 90 |
+
initLocal ()#line:179
|
| 91 |
+
run (f'main.py')#line:182
|