Download synthid.sh from nathanglm/sofia: direct link, hf CLI and curl.
- Browser
- Download file 11.2 kB
-
https://huggingface.co/nathanglm/sofia/resolve/main/synthid.sh
- Command line
-
hf download hf://nathanglm/sofia/synthid.sh
-
curl -L -o synthid.sh https://huggingface.co/nathanglm/sofia/resolve/main/synthid.sh
11.2 kB
| source /venv/main/bin/activate | |
| COMFYUI_DIR=${WORKSPACE}/ComfyUI | |
| # Packages are installed after nodes so we can fix them... | |
| APT_PACKAGES=( | |
| ) | |
| PIP_PACKAGES=( | |
| ) | |
| NODES=( | |
| "https://github.com/ltdrdata/ComfyUI-Manager" | |
| "https://github.com/city96/ComfyUI-GGUF" | |
| "https://github.com/ltdrdata/ComfyUI-Impact-Pack" | |
| "https://github.com/rgthree/rgthree-comfy" | |
| "https://github.com/Fannovel16/comfyui_controlnet_aux" | |
| "https://github.com/kijai/ComfyUI-KJNodes" | |
| "https://github.com/lquesada/ComfyUI-Inpaint-CropAndStitch" | |
| "https://github.com/ClownsharkBatwing/RES4LYF" | |
| "https://github.com/wildminder/ComfyUI-DyPE" | |
| "https://github.com/BadCafeCode/masquerade-nodes-comfyui" | |
| "https://github.com/numz/ComfyUI-SeedVR2_VideoUpscaler" | |
| "https://github.com/0xN4TH4N/SynthID-Bypass" | |
| "https://github.com/ltdrdata/ComfyUI-Impact-Subpack" | |
| ) | |
| WORKFLOWS=( | |
| ) | |
| SAMS=( | |
| "https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth" | |
| ) | |
| CHECKPOINT_MODELS=( | |
| ) | |
| BBOX=( | |
| "https://huggingface.co/deepghs/yolo-face/resolve/739664f2d00e436a8882238f83175ab0f6497578/yolov8n-face/model.pt" | |
| ) | |
| UNET_MODELS=( | |
| ) | |
| # Format: "URL|filename.safetensors" | |
| LORA_MODELS=( | |
| "https://huggingface.co/lightx2v/Qwen-Image-2512-Lightning/resolve/main/Qwen-Image-2512-Lightning-4steps-V1.0-fp32.safetensors" | |
| ) | |
| VAE_MODELS=( | |
| "https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/vae/ae.safetensors" | |
| "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI/resolve/main/split_files/vae/qwen_image_vae.safetensors" | |
| ) | |
| DIFFUSION_MODELS=( | |
| "https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/diffusion_models/z_image_turbo_bf16.safetensors" | |
| "https://huggingface.co/unsloth/Qwen-Image-2512-GGUF/resolve/main/qwen-image-2512-Q4_K_M.gguf" | |
| "https://huggingface.co/jayn7/Z-Image-Turbo-GGUF/resolve/main/z_image_turbo-Q4_K_M.gguf" | |
| ) | |
| TEXT_ENCODERS=( | |
| "https://huggingface.co/Comfy-Org/z_image_turbo/resolve/main/split_files/text_encoders/qwen_3_4b.safetensors" | |
| ) | |
| ESRGAN_MODELS=( | |
| ) | |
| CONTROLNET_MODELS=( | |
| ) | |
| BBOX=( | |
| "https://huggingface.co/Bingsu/adetailer/resolve/main/face_yolov8n.pt" | |
| ) | |
| CLIP=( | |
| "https://huggingface.co/unsloth/Qwen2.5-VL-7B-Instruct-GGUF/resolve/main/Qwen2.5-VL-7B-Instruct-Q4_K_M.gguf" | |
| "https://huggingface.co/worstplayer/Z-Image_Qwen_3_4b_text_encoder_GGUF/resolve/main/Qwen_3_4b-imatrix-IQ4_XS.gguf" | |
| ) | |
| MODEL_PATCHES=( | |
| "https://huggingface.co/Comfy-Org/Qwen-Image-DiffSynth-ControlNets/resolve/main/split_files/model_patches/qwen_image_canny_diffsynth_controlnet.safetensors" | |
| ) | |
| ### DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ### | |
| function provisioning_start() { | |
| provisioning_print_header | |
| provisioning_get_apt_packages | |
| provisioning_get_nodes | |
| provisioning_get_pip_packages | |
| provisioning_get_files \ | |
| "${COMFYUI_DIR}/models/sams" \ | |
| "${SAMS[@]}" | |
| provisioning_get_files \ | |
| "${COMFYUI_DIR}/models/checkpoints" \ | |
| "${CHECKPOINT_MODELS[@]}" | |
| provisioning_get_files \ | |
| "${COMFYUI_DIR}/models/ultralytics/bbox" \ | |
| "${BBOX[@]}" | |
| provisioning_get_files \ | |
| "${COMFYUI_DIR}/models/unet" \ | |
| "${UNET_MODELS[@]}" | |
| provisioning_get_files \ | |
| "${COMFYUI_DIR}/models/clip" \ | |
| "${CLIP[@]}" | |
| provisioning_get_files \ | |
| "${COMFYUI_DIR}/models/model_patches" \ | |
| "${MODEL_PATCHES[@]}" | |
| provisioning_get_files \ | |
| "${COMFYUI_DIR}/models/loras" \ | |
| "${LORA_MODELS[@]}" | |
| provisioning_get_files \ | |
| "${COMFYUI_DIR}/models/diffusion_models" \ | |
| "${DIFFUSION_MODELS[@]}" | |
| provisioning_get_files \ | |
| "${COMFYUI_DIR}/models/text_encoders" \ | |
| "${TEXT_ENCODERS[@]}" | |
| provisioning_get_files \ | |
| "${COMFYUI_DIR}/models/ultralytics/bbox" \ | |
| "${BBOX[@]}" | |
| provisioning_get_files \ | |
| "${COMFYUI_DIR}/models/controlnet" \ | |
| "${CONTROLNET_MODELS[@]}" | |
| provisioning_get_files \ | |
| "${COMFYUI_DIR}/models/vae" \ | |
| "${VAE_MODELS[@]}" | |
| provisioning_get_files \ | |
| "${COMFYUI_DIR}/user/default/workflows" \ | |
| "${WORKFLOWS[@]}" | |
| provisioning_get_files \ | |
| "${COMFYUI_DIR}/models/esrgan" \ | |
| "${ESRGAN_MODELS[@]}" | |
| provisioning_print_end | |
| } | |
| function provisioning_get_apt_packages() { | |
| if [[ -n $APT_PACKAGES ]]; then | |
| sudo $APT_INSTALL ${APT_PACKAGES[@]} | |
| fi | |
| } | |
| function provisioning_get_pip_packages() { | |
| if [[ -n $PIP_PACKAGES ]]; then | |
| pip install --no-cache-dir ${PIP_PACKAGES[@]} | |
| fi | |
| } | |
| function provisioning_get_nodes() { | |
| for repo in "${NODES[@]}"; do | |
| dir="${repo##*/}" | |
| path="${COMFYUI_DIR}/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 | |
| pip install --no-cache-dir -r "$requirements" | |
| fi | |
| fi | |
| else | |
| printf "Downloading node: %s...\n" "${repo}" | |
| git clone "${repo}" "${path}" --recursive | |
| if [[ -e $requirements ]]; then | |
| pip install --no-cache-dir -r "${requirements}" | |
| fi | |
| fi | |
| done | |
| } | |
| function provisioning_get_files() { | |
| if [[ -z $2 ]]; then return 1; fi | |
| dir="$1" | |
| mkdir -p "$dir" | |
| shift | |
| arr=("$@") | |
| printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir" | |
| for entry in "${arr[@]}"; do | |
| # Support "URL|filename" format for custom filenames | |
| if [[ "$entry" == *"|"* ]]; then | |
| url="${entry%%|*}" | |
| filename="${entry##*|}" | |
| else | |
| url="$entry" | |
| filename="" | |
| fi | |
| printf "Downloading: %s\n" "${url}" | |
| provisioning_download "${url}" "${dir}" "${filename}" | |
| 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" | |
| } | |
| function provisioning_print_end() { | |
| printf "\nProvisioning complete: Application will start now\n\n" | |
| } | |
| function provisioning_has_valid_hf_token() { | |
| [[ -n "$HF_TOKEN" ]] || return 1 | |
| url="https://huggingface.co/api/whoami-v2" | |
| response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \ | |
| -H "Authorization: Bearer $HF_TOKEN" \ | |
| -H "Content-Type: application/json") | |
| if [ "$response" -eq 200 ]; then | |
| return 0 | |
| else | |
| return 1 | |
| fi | |
| } | |
| function provisioning_has_valid_civitai_token() { | |
| [[ -n "$CIVITAI_TOKEN" ]] || return 1 | |
| url="https://civitai.com/api/v1/models?hidden=1&limit=1" | |
| response=$(curl -o /dev/null -s -w "%{http_code}" -X GET "$url" \ | |
| -H "Authorization: Bearer $CIVITAI_TOKEN" \ | |
| -H "Content-Type: application/json") | |
| if [ "$response" -eq 200 ]; then | |
| return 0 | |
| else | |
| return 1 | |
| fi | |
| } | |
| # Download CivitAI models with curl (pure bash) | |
| function download_civitai_bash() { | |
| local url="$1" | |
| local output_dir="$2" | |
| local forced_filename="$3" | |
| local model_id="" | |
| if [[ $url =~ /models/([0-9]+) ]]; then | |
| model_id="${BASH_REMATCH[1]}" | |
| else | |
| printf "ERROR: Could not extract model ID from URL\n" | |
| return 1 | |
| fi | |
| printf "Downloading CivitAI model %s...\n" "$model_id" | |
| if [[ -n "$forced_filename" ]]; then | |
| local output_file="${output_dir}/${forced_filename}" | |
| if [[ -f "$output_file" ]]; then | |
| printf "File already exists: %s\n" "$forced_filename" | |
| return 0 | |
| fi | |
| printf "Downloading to: %s\n" "$forced_filename" | |
| if [[ -n "$CIVITAI_TOKEN" ]]; then | |
| curl -L -o "$output_file" --progress-bar -H "Authorization: Bearer $CIVITAI_TOKEN" "$url" | |
| else | |
| curl -L -o "$output_file" --progress-bar "$url" | |
| fi | |
| if [[ $? -eq 0 ]]; then | |
| printf "Download completed: %s\n" "$forced_filename" | |
| return 0 | |
| else | |
| printf "ERROR: Download failed for model %s\n" "$model_id" | |
| return 1 | |
| fi | |
| fi | |
| local redirect_url="" | |
| if [[ -n "$CIVITAI_TOKEN" ]]; then | |
| redirect_url=$(curl -s -I -L -H "Authorization: Bearer $CIVITAI_TOKEN" "$url" | grep -i "^location:" | tail -1 | sed 's/location: //i' | tr -d '\r\n') | |
| else | |
| redirect_url=$(curl -s -I -L "$url" | grep -i "^location:" | tail -1 | sed 's/location: //i' | tr -d '\r\n') | |
| fi | |
| if [[ -z "$redirect_url" ]]; then | |
| printf "ERROR: Could not get redirect URL for model %s\n" "$model_id" | |
| return 1 | |
| fi | |
| local filename="" | |
| if [[ $redirect_url =~ response-content-disposition=attachment.*filename%3D%22([^%\"]+) ]]; then | |
| filename="${BASH_REMATCH[1]}" | |
| filename=$(echo "$filename" | sed 's/%20/ /g; s/%2D/-/g; s/%2E/./g; s/%5F/_/g') | |
| elif [[ $redirect_url =~ filename=\"([^\"]+)\" ]]; then | |
| filename="${BASH_REMATCH[1]}" | |
| elif [[ $redirect_url =~ filename=([^&]+) ]]; then | |
| filename="${BASH_REMATCH[1]}" | |
| else | |
| local path_part=$(echo "$redirect_url" | sed 's/?.*//') | |
| filename=$(basename "$path_part") | |
| if [[ ! "$filename" =~ \.(safetensors|pt|pth|ckpt|bin)$ ]]; then | |
| filename="${filename}.safetensors" | |
| fi | |
| fi | |
| filename=$(printf '%b' "${filename//%/\\x}") | |
| if [[ -z "$filename" ]] || [[ "$filename" == "." ]] || [[ "$filename" == ".safetensors" ]]; then | |
| filename="civitai_${model_id}.safetensors" | |
| fi | |
| local output_file="${output_dir}/${filename}" | |
| if [[ -f "$output_file" ]]; then | |
| printf "File already exists: %s\n" "$filename" | |
| return 0 | |
| fi | |
| printf "Downloading to: %s\n" "$filename" | |
| curl -L -o "$output_file" --progress-bar "$redirect_url" | |
| if [[ $? -eq 0 ]]; then | |
| printf "Download completed: %s\n" "$filename" | |
| return 0 | |
| else | |
| printf "ERROR: Download failed for model %s\n" "$model_id" | |
| return 1 | |
| fi | |
| } | |
| # Download from $1 URL to $2 file path, with optional $3 forced filename | |
| function provisioning_download() { | |
| local url="$1" | |
| local dir="$2" | |
| local forced_filename="$3" | |
| if [[ $url =~ ^https://civitai\.com/api/download/models/([0-9]+) ]]; then | |
| download_civitai_bash "$url" "$dir" "$forced_filename" | |
| else | |
| if [[ -n "$forced_filename" ]]; then | |
| wget -qnc --show-progress -e dotbytes="${4:-4M}" -O "${dir}/${forced_filename}" "$url" | |
| else | |
| wget -qnc --content-disposition --show-progress -e dotbytes="${4:-4M}" -P "$dir" "$url" | |
| fi | |
| fi | |
| } | |
| # Allow user to disable provisioning if they started with a script they didn't want | |
| if [[ ! -f /.noprovisioning ]]; then | |
| provisioning_start | |
| fi |