Create sd.py
Browse files
sd.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import subprocess
|
3 |
+
import subprocess
|
4 |
+
|
5 |
+
# 启动Jupyter Lab
|
6 |
+
subprocess.Popen([
|
7 |
+
"jupyter-lab",
|
8 |
+
"--no-browser",
|
9 |
+
"--ip=0.0.0.0",
|
10 |
+
"--allow-root",
|
11 |
+
"--notebook-dir=/",
|
12 |
+
"--port=8888",
|
13 |
+
"--LabApp.allow_origin=*",
|
14 |
+
"--LabApp.token=",
|
15 |
+
"--LabApp.base_url="
|
16 |
+
])
|
17 |
+
# 更新包列表并安装aria2和screen
|
18 |
+
os.system("apt update && apt install -y aria2 screen")
|
19 |
+
|
20 |
+
# 获取下载链接和文件保存名字
|
21 |
+
download_link = input("请输入下载链接:")
|
22 |
+
file_name = input("请输入文件保存名字(带后缀的):")
|
23 |
+
|
24 |
+
# 使用aria2进行下载,并将文件保存到指定目录
|
25 |
+
os.system(f"cd /group_share/lora-scripts/sd-models && aria2c -x 16 -s 16 -c '{download_link}' -o '{file_name}.safetensors'")
|
26 |
+
import os
|
27 |
+
import subprocess
|
28 |
+
import subprocess
|
29 |
+
|
30 |
+
# 启动Jupyter Lab
|
31 |
+
subprocess.Popen([
|
32 |
+
"jupyter-lab",
|
33 |
+
"--no-browser",
|
34 |
+
"--ip=0.0.0.0",
|
35 |
+
"--allow-root",
|
36 |
+
"--notebook-dir=/",
|
37 |
+
"--port=8888",
|
38 |
+
"--LabApp.allow_origin=*",
|
39 |
+
"--LabApp.token=",
|
40 |
+
"--LabApp.base_url="
|
41 |
+
])
|
42 |
+
# 更新包列表并安装aria2和screen
|
43 |
+
os.system("apt update && apt install -y aria2 screen")
|
44 |
+
|
45 |
+
# 获取下载链接和文件保存名字
|
46 |
+
download_link = input("请输入下载链接:")
|
47 |
+
file_name = input("请输入文件保存名字(带后缀的):")
|
48 |
+
|
49 |
+
# 使用aria2进行下载,并将文件保存到指定目录
|
50 |
+
os.system(f"cd /group_share/lora-scripts/sd-models && aria2c -x 16 -s 16 -c '{download_link}' -o '{file_name}.safetensors'")
|
51 |
+
|
52 |
+
# 激活conda环境并运行脚本
|
53 |
+
os.system("cd /group_share/xlab-app-center/stable-diffusion-webui && HF_ENDPOINT=https://hf-mirror.com python launch.py --api --xformers --port=7860 --no-hashing --ckpt-dir=/group_share/lora-scripts/sd-models --lora-dir=/group_share/lora-scripts/output")
|