File size: 4,157 Bytes
c009d4f b7d4bc8 c009d4f b7d4bc8 c009d4f b7d4bc8 c009d4f b7d4bc8 c009d4f b2fb908 c009d4f b7d4bc8 c009d4f b7d4bc8 c009d4f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | import os
import sys
import shutil
from core.settings import *
def move_and_overwrite(src, dst):
if os.path.isdir(src):
if os.path.exists(dst):
shutil.rmtree(dst)
shutil.move(src, dst)
elif os.path.isfile(src):
if os.path.exists(dst):
os.remove(dst)
shutil.move(src, dst)
def initialize_comfyui():
APP_DIR = sys.path[0]
COMFYUI_TEMP_DIR = "ComfyUI_temp"
print("--- Cloning ComfyUI Repository ---")
if not os.path.exists(COMFYUI_TEMP_DIR):
os.system(f"git clone https://github.com/comfy-Org/ComfyUI {COMFYUI_TEMP_DIR}")
print("β
ComfyUI repository cloned.")
else:
print("β
ComfyUI repository already exists.")
print(f"--- Merging ComfyUI from '{COMFYUI_TEMP_DIR}' to '{APP_DIR}' ---")
for item in os.listdir(COMFYUI_TEMP_DIR):
src_path = os.path.join(COMFYUI_TEMP_DIR, item)
dst_path = os.path.join(APP_DIR, item)
if item == '.git':
continue
move_and_overwrite(src_path, dst_path)
try:
shutil.rmtree(COMFYUI_TEMP_DIR)
print("β
ComfyUI merged and temporary directory removed.")
except OSError as e:
print(f"β οΈ Could not remove temporary directory '{COMFYUI_TEMP_DIR}': {e}")
print("--- Cloning third-party extensions for ComfyUI ---")
# 1. ComfyUI_IPAdapter_plus
ipadapter_plus_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI_IPAdapter_plus")
if not os.path.exists(ipadapter_plus_path):
os.system(f"git clone https://github.com/cubiq/ComfyUI_IPAdapter_plus.git {ipadapter_plus_path}")
print("β
ComfyUI_IPAdapter_plus extension cloned.")
else:
print("β
ComfyUI_IPAdapter_plus extension already exists.")
# 2. ComfyUI-InstantX-IPAdapter-SD3
ipadapter_plus_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI-InstantX-IPAdapter-SD3")
if not os.path.exists(ipadapter_plus_path):
os.system(f"git clone https://github.com/Slickytail/ComfyUI-InstantX-IPAdapter-SD3.git {ipadapter_plus_path}")
print("β
ComfyUI-InstantX-IPAdapter-SD3 extension cloned.")
else:
print("β
ComfyUI-InstantX-IPAdapter-SD3 extension already exists.")
# 3. ComfyUI-IPAdapter-Flux
ipadapter_flux_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI-IPAdapter-Flux")
if not os.path.exists(ipadapter_flux_path):
os.system(f"git clone https://github.com/Shakker-Labs/ComfyUI-IPAdapter-Flux.git {ipadapter_flux_path}")
print("β
ComfyUI-IPAdapter-Flux extension cloned.")
else:
print("β
ComfyUI-IPAdapter-Flux extension already exists.")
# 4. ComfyUI-Newbie-Nodes
newbie_nodes_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI-Newbie-Nodes")
if not os.path.exists(newbie_nodes_path):
os.system(f"git clone https://github.com/NewBieAI-Lab/ComfyUI-Newbie-Nodes.git {newbie_nodes_path}")
print("β
ComfyUI-Newbie-Nodes extension cloned.")
else:
print("β
ComfyUI-Newbie-Nodes extension already exists.")
# 5. ComfyUI-Anima-LLLite
anima_controlnet_lllite_nodes_path = os.path.join(APP_DIR, "custom_nodes", "ComfyUI-Anima-LLLite")
if not os.path.exists(anima_controlnet_lllite_nodes_path):
os.system(f"git clone https://github.com/kohya-ss/ComfyUI-Anima-LLLite.git {anima_controlnet_lllite_nodes_path}")
print("β
ComfyUI-Anima-LLLite extension cloned.")
else:
print("β
ComfyUI-Anima-LLLite extension already exists.")
print(f"β
Current working directory is: {os.getcwd()}")
import comfy.model_management
print("--- Environment Ready ---")
print("β
ComfyUI initialized with default attention mechanism.")
for dir_path in CATEGORY_TO_DIR_MAP.values():
os.makedirs(os.path.join(APP_DIR, dir_path), exist_ok=True)
os.makedirs(os.path.join(APP_DIR, INPUT_DIR), exist_ok=True)
os.makedirs(os.path.join(APP_DIR, OUTPUT_DIR), exist_ok=True)
print("β
All required model directories are present.") |