Upload exec1.py
Browse files
exec1.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import subprocess
|
2 |
+
import concurrent.futures
|
3 |
+
from IPython.display import clear_output
|
4 |
+
import os
|
5 |
+
import sys
|
6 |
+
|
7 |
+
params = {}
|
8 |
+
for arg in sys.argv[1:]:
|
9 |
+
if arg.startswith('--'):
|
10 |
+
key_value = arg[len('--'):].split('=')
|
11 |
+
if len(key_value) == 2:
|
12 |
+
key, value = key_value
|
13 |
+
params[key] = value
|
14 |
+
|
15 |
+
subprocess.run(f'git clone https://github.com/Lucysck/test1 {params["dir"]}', shell=True)
|
16 |
+
|
17 |
+
def run_git():
|
18 |
+
subprocess.run(f'cp -rf /content/drive/MyDrive/sd/* {params["dir"]}', shell=True)
|
19 |
+
|
20 |
+
def run_aria2c():
|
21 |
+
subprocess.run(f'aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/spaces/weo1101/111/resolve/main/chilloutmix_NiPrunedFp32Fix-inpainting.inpainting.safetensors -d {params["dir"]}/models/Stable-diffusion -o chilloutmix_NiPrunedFp32Fix-inpainting.inpainting.safetensors', shell=True)
|
22 |
+
|
23 |
+
def run_code():
|
24 |
+
subprocess.run(f"wget -O {params['dir']}/libtcmalloc_minimal.so.4 https://huggingface.co/Vanwise/sd-colab/resolve/main/libtcmalloc_minimal.so.4", shell=True)
|
25 |
+
os.environ['LD_PRELOAD'] = f"{params['dir']}/libtcmalloc_minimal.so.4"
|
26 |
+
|
27 |
+
executor = concurrent.futures.ThreadPoolExecutor(max_workers=3)
|
28 |
+
task1 = executor.submit(run_git)
|
29 |
+
task2 = executor.submit(run_aria2c)
|
30 |
+
task3 = executor.submit(run_code)
|
31 |
+
concurrent.futures.wait([task1, task2, task3])
|
32 |
+
|
33 |
+
subprocess.run(f"wget -O {params['dir']}/config.json https://huggingface.co/spaces/weo1101/111/resolve/main/config.json", shell=True)
|
34 |
+
|
35 |
+
import threading
|
36 |
+
import time
|
37 |
+
|
38 |
+
def clear_output_pro():
|
39 |
+
clear_output()
|
40 |
+
print("Clearing output...")
|
41 |
+
threading.Timer(30, clear_output_pro).start()
|
42 |
+
|
43 |
+
threading.Timer(360, clear_output_pro).start()
|
44 |
+
|
45 |
+
os.chdir(f'{params["dir"]}')
|
46 |
+
clear_output()
|
47 |
+
|
48 |
+
base_arg = "--disable-safe-unpickle --opt-sdp-attention --no-half-vae --enable-insecure-extension --theme=dark --lowram --listen --xformers"
|
49 |
+
|
50 |
+
if params["share"] == "True":
|
51 |
+
base_arg += " --share"
|
52 |
+
|
53 |
+
if params["ngrok"]:
|
54 |
+
base_arg += f' --ngrok={params["ngrok"]} --ngrok-region="auto"'
|
55 |
+
|
56 |
+
if params["cloudflared"] == "True":
|
57 |
+
base_arg += f" --cloudflared"
|
58 |
+
|
59 |
+
if params["localhostrun"] == "True":
|
60 |
+
base_arg += f" --localhostrun"
|
61 |
+
|
62 |
+
if params["remotemoe"] == "True":
|
63 |
+
base_arg += f" --remotemoe"
|
64 |
+
|
65 |
+
subprocess.run(f"python launch.py {base_arg}", shell=True)
|