|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PYTHON_PACKAGES=( |
|
|
|
) |
|
|
|
NODES=( |
|
"https://github.com/ltdrdata/ComfyUI-Manager" |
|
"https://github.com/WASasquatch/was-node-suite-comfyui" |
|
"https://github.com/cubiq/ComfyUI_essentials" |
|
"https://github.com/ltdrdata/ComfyUI-Impact-Pack" |
|
"https://github.com/Fannovel16/comfyui_controlnet_aux" |
|
"https://github.com/Gourieff/comfyui-reactor-node" |
|
"https://github.com/cubiq/ComfyUI_InstantID" |
|
"https://github.com/cubiq/ComfyUI_IPAdapter_plus" |
|
) |
|
|
|
CHECKPOINT_MODELS=( |
|
"https://huggingface.co/Lykon/dreamshaper-xl-lightning/resolve/main/DreamShaperXL_Lightning.safetensors" |
|
) |
|
|
|
LORA_MODELS=( |
|
) |
|
|
|
VAE_MODELS=( |
|
) |
|
|
|
ESRGAN_MODELS=( |
|
) |
|
|
|
CONTROLNET_MODELS=( |
|
"https://huggingface.co/InstantX/InstantID/resolve/main/ControlNetModel/diffusion_pytorch_model.safetensors" |
|
"https://huggingface.co/Kuvshin/models/resolve/main/pose_sdxl.safetensors" |
|
) |
|
|
|
INSIGHTFACE=( |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/insightface/inswapper_128.onnx" |
|
) |
|
|
|
BUFALO=( |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/insightface/models/buffalo_l/1k3d68.onnx" |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/insightface/models/buffalo_l/2d106det.onnx" |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/insightface/models/buffalo_l/det_10g.onnx" |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/insightface/models/buffalo_l/genderage.onnx" |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/insightface/models/buffalo_l/w600k_r50.onnx" |
|
) |
|
|
|
ANTELOPEV=( |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/insightface/models/antelopev2/1k3d68.onnx" |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/insightface/models/antelopev2/2d106det.onnx" |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/insightface/models/antelopev2/genderage.onnx" |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/insightface/models/antelopev2/glintr100.onnx" |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/insightface/models/antelopev2/scrfd_10g_bnkps.onnx" |
|
) |
|
|
|
BBOX=( |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/ultralytics/bbox/face_yolov8m.pt" |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/ultralytics/bbox/hand_yolov8s.pt" |
|
) |
|
|
|
SEGM=( |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/ultralytics/segm/person_yolov8m-seg.pt" |
|
) |
|
|
|
SAMS=( |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/sam_vit_b_01ec64.pth" |
|
) |
|
|
|
CLIP=( |
|
"https://huggingface.co/Kuvshin/models/resolve/main/CLIP-ViT-H-14-laion2B-s32B-b79K.safetensors" |
|
) |
|
|
|
FACEDETECTION=( |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/detection_Resnet50_Final.pth" |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/parsing_parsenet.pth" |
|
) |
|
|
|
FACERESTORE=( |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/GFPGANv1.3.pth" |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/GFPGANv1.4.pth" |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/GPEN-BFR-512.onnx" |
|
"https://huggingface.co/Kuvshin/kuvshin8/resolve/main/codeformer-v0.1.0.pth" |
|
) |
|
|
|
INSTANTID=( |
|
"https://huggingface.co/InstantX/InstantID/resolve/main/ip-adapter.bin" |
|
) |
|
|
|
|
|
function provisioning_start() { |
|
DISK_GB_AVAILABLE=$(($(df --output=avail -m "${WORKSPACE}" | tail -n1) / 1000)) |
|
DISK_GB_USED=$(($(df --output=used -m "${WORKSPACE}" | tail -n1) / 1000)) |
|
DISK_GB_ALLOCATED=$(($DISK_GB_AVAILABLE + $DISK_GB_USED)) |
|
provisioning_print_header |
|
provisioning_get_nodes |
|
provisioning_install_python_packages |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/ckpt" \ |
|
"${CHECKPOINT_MODELS[@]}" |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/lora" \ |
|
"${LORA_MODELS[@]}" |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/controlnet" \ |
|
"${CONTROLNET_MODELS[@]}" |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/vae" \ |
|
"${VAE_MODELS[@]}" |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/esrgan" \ |
|
"${ESRGAN_MODELS[@]}" |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/insightface" \ |
|
"${INSIGHTFACE[@]}" |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/insightface/models/buffalo_l" \ |
|
"${BUFALO[@]}" |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/insightface/models/antelopev2" \ |
|
"${ANTELOPEV[@]}" |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/ultralytics/bbox" \ |
|
"${BBOX[@]}" |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/ultralytics/segm" \ |
|
"${SEGM[@]}" |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/sams" \ |
|
"${SAMS[@]}" |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/clip_vision" \ |
|
"${CLIP[@]}" |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/facedetection" \ |
|
"${FACEDETECTION[@]}" |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/facerestore_models" \ |
|
"${FACERESTORE[@]}" |
|
provisioning_get_models \ |
|
"${WORKSPACE}/storage/stable_diffusion/models/instantid" \ |
|
"${INSTANTID[@]}" |
|
provisioning_print_end |
|
} |
|
|
|
function provisioning_get_nodes() { |
|
for repo in "${NODES[@]}"; do |
|
dir="${repo##*/}" |
|
path="/opt/ComfyUI/custom_nodes/${dir}" |
|
requirements="${path}/requirements.txt" |
|
if [[ -d $path ]]; then |
|
if [[ ${AUTO_UPDATE,,} != "false" ]]; then |
|
printf "Updating node: %s...\n" "${repo}" |
|
( cd "$path" && git pull ) |
|
if [[ -e $requirements ]]; then |
|
micromamba -n comfyui run ${PIP_INSTALL} -r "$requirements" |
|
fi |
|
fi |
|
else |
|
printf "Downloading node: %s...\n" "${repo}" |
|
git clone "${repo}" "${path}" --recursive |
|
if [[ -e $requirements ]]; then |
|
micromamba -n comfyui run ${PIP_INSTALL} -r "${requirements}" |
|
fi |
|
fi |
|
done |
|
} |
|
|
|
function provisioning_install_python_packages() { |
|
if [ ${#PYTHON_PACKAGES[@]} -gt 0 ]; then |
|
micromamba -n comfyui run ${PIP_INSTALL} ${PYTHON_PACKAGES[*]} |
|
fi |
|
} |
|
|
|
function provisioning_get_models() { |
|
if [[ -z $2 ]]; then return 1; fi |
|
dir="$1" |
|
mkdir -p "$dir" |
|
shift |
|
if [[ $DISK_GB_ALLOCATED -ge $DISK_GB_REQUIRED ]]; then |
|
arr=("$@") |
|
else |
|
printf "WARNING: Low disk space allocation - Only the first model will be downloaded!\n" |
|
arr=("$1") |
|
fi |
|
|
|
printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir" |
|
for url in "${arr[@]}"; do |
|
printf "Downloading: %s\n" "${url}" |
|
provisioning_download "${url}" "${dir}" |
|
printf "\n" |
|
done |
|
} |
|
|
|
function provisioning_print_header() { |
|
printf "\n##############################################\n# #\n# Provisioning container #\n# #\n# This will take some time #\n# #\n# Your container will be ready on completion #\n# #\n##############################################\n\n" |
|
if [[ $DISK_GB_ALLOCATED -lt $DISK_GB_REQUIRED ]]; then |
|
printf "WARNING: Your allocated disk size (%sGB) is below the recommended %sGB - Some models will not be downloaded\n" "$DISK_GB_ALLOCATED" "$DISK_GB_REQUIRED" |
|
fi |
|
} |
|
|
|
function provisioning_print_end() { |
|
printf "\nProvisioning complete: Web UI will start now\n\n" |
|
} |
|
|
|
|
|
function provisioning_download() { |
|
wget -qnc --content-disposition --show-progress -e dotbytes="${3:-4M}" -P "$2" "$1" |
|
} |
|
|
|
provisioning_start |