Rename comfyui.sh to comfyui.py
Browse files- comfyui.py +70 -0
- comfyui.sh +0 -4
comfyui.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
import threading
|
| 3 |
+
import time
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
# 检查文件是否存在
|
| 7 |
+
def check_file_exists(file_path):
|
| 8 |
+
while os.path.exists(file_path):
|
| 9 |
+
print(f"等待文件 {file_path} 下载完成...")
|
| 10 |
+
time.sleep(1) # 等待 1 秒钟后再检查
|
| 11 |
+
print(f"文件 {file_path} 已下载完成。")
|
| 12 |
+
|
| 13 |
+
# 下载并解压的函数
|
| 14 |
+
def download_file_A():
|
| 15 |
+
download_cmd_A = "cd /root && aria2c -x 16 -s 16 -c -k 1M 'https://www.modelscope.cn/models/ACCC1380/Comfyui_buckup_20241201_1952/resolve/master/ComfyUI.tar.safetensors' -o ComfyUI-aki-v1.3.1.tar"
|
| 16 |
+
subprocess.run(download_cmd_A, shell=True, check=True) # 下载 A 文件并等待完成
|
| 17 |
+
|
| 18 |
+
# 文件 A 下载完成后立即解压
|
| 19 |
+
unzip_cmd = "cd /root && tar -xvf ComfyUI-aki-v1.3.1.tar"
|
| 20 |
+
subprocess.run(unzip_cmd, shell=True, check=True)
|
| 21 |
+
|
| 22 |
+
def download_file_B():
|
| 23 |
+
time.sleep(3)
|
| 24 |
+
# 等待 A 文件下载完成
|
| 25 |
+
check_file_exists('/root/ComfyUI-aki-v1.3.1.tar.aria2')
|
| 26 |
+
# 下载 B 文件
|
| 27 |
+
download_cmd_B = "cd /root && aria2c -x 16 -s 16 -c -k 1M 'https://www.modelscope.cn/models/ACCC1380/Comfyui_buckup_20241201_1952/resolve/master/cfvenv2.tar.safetensors' -o cfvenv.tar.safetensors -d /root"
|
| 28 |
+
subprocess.run(download_cmd_B, shell=True, check=True)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
# 解压 B 文件
|
| 32 |
+
tar_cmd = "cd /root && tar -xvf cfvenv.tar.safetensors"
|
| 33 |
+
subprocess.run(tar_cmd, shell=True, check=True)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def extract_and_setup():
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
# 删除原 Python 文件并创建虚拟环境
|
| 41 |
+
#venv_cmd = "cd /root && rm /root/cfvenv/bin/python* && python -m venv cfvenv"
|
| 42 |
+
#subprocess.run(venv_cmd, shell=True, check=True)
|
| 43 |
+
|
| 44 |
+
# 运行 ComfyUI 的 Python 脚本
|
| 45 |
+
run_comfyui_cmd = "cd /root/comfyui/ComfyUI-aki-v1.3.1 && /root/cfvenv/bin/python3 main.py"
|
| 46 |
+
subprocess.Popen(run_comfyui_cmd, shell=True)
|
| 47 |
+
|
| 48 |
+
def cleanup():
|
| 49 |
+
# 删除临时文件
|
| 50 |
+
cleanup_cmd = "rm /root/ComfyUI-aki-v1.3.1.tar && rm /root/cfvenv.tar.safetensors"
|
| 51 |
+
subprocess.run(cleanup_cmd, shell=True, check=True)
|
| 52 |
+
|
| 53 |
+
# 启动下载任务 A 和 B
|
| 54 |
+
thread_A = threading.Thread(target=download_file_A)
|
| 55 |
+
thread_B = threading.Thread(target=download_file_B)
|
| 56 |
+
|
| 57 |
+
thread_A.start() # 开始下载 A 文件
|
| 58 |
+
thread_B.start() # 开始下载 B 文件
|
| 59 |
+
|
| 60 |
+
# 等待 A 和 B 下载完成
|
| 61 |
+
thread_A.join()
|
| 62 |
+
thread_B.join()
|
| 63 |
+
|
| 64 |
+
# 解压并设置环境
|
| 65 |
+
extract_and_setup()
|
| 66 |
+
|
| 67 |
+
# 清理临时文件
|
| 68 |
+
cleanup()
|
| 69 |
+
while True:
|
| 70 |
+
time.sleep(8888888)
|
comfyui.sh
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
apt update
|
| 2 |
-
apt install -y aria2
|
| 3 |
-
cd /root && aria2c -x 16 -s 16 -c -k 1M "https://www.modelscope.cn/models/ACCC1380/Comfyui_Model_Flux/resolve/master/ComfyUI-aki-v1.3.1.safetensors" -o ComfyUI-aki-v1.3.1.zip
|
| 4 |
-
cd /root && unzip -P "nyan" ComfyUI-aki-v1.3.1.zip
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|