File size: 9,591 Bytes
b265261 7f0bb05 b265261 7f0bb05 6805135 b265261 7f0bb05 b265261 8d3d02a b265261 6805135 b265261 9f24aad 6805135 b265261 6805135 b265261 7f0bb05 b265261 7f0bb05 b265261 7f0bb05 b265261 6805135 b265261 6805135 b265261 6805135 b265261 6805135 b265261 6805135 b265261 6805135 b265261 7f0bb05 b265261 7f0bb05 b265261 | 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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | #!/bin/bash
# =============================================================================
# Krea 2 v1.5 — Provisioning ALLÉGÉ (pour l'image Docker perso)
# Les nodes et dépendances sont déjà dans l'image : ce script ne fait plus
# que télécharger les modèles.
#
# Variables d'environnement (template Vast) :
# CIVITAI_TOKEN (sinon la valeur en dur ci-dessous est utilisée)
# HF_TOKEN (optionnel)
# =============================================================================
source /venv/main/bin/activate
COMFYUI_DIR=${WORKSPACE}/ComfyUI
CIVITAI_TOKEN="${CIVITAI_TOKEN:-ee2791108127cd78eb0217b6207b4fe2}"
# Workflows : uploade d'abord Krea2_v1.5.json dans ton repo HF nathanglm/sofia
WORKFLOWS=(
)
# ---------------- Krea 2 (base) ----------------
DIFFUSION_MODELS=(
"https://huggingface.co/Comfy-Org/Krea-2/resolve/main/diffusion_models/krea2_turbo_bf16.safetensors"
"https://civitai.com/api/download/models/2761943|K2-GonzaLomo-v4.safetensors"
# Repli si OOM :
#"https://huggingface.co/Comfy-Org/Krea-2/resolve/main/diffusion_models/krea2_turbo_fp8_scaled.safetensors"
# Pour entraîner tes LoRA (pas pour générer) :
#"https://huggingface.co/Comfy-Org/Krea-2/resolve/main/diffusion_models/krea2_raw_bf16.safetensors"
)
TEXT_ENCODERS=(
"https://huggingface.co/Comfy-Org/Krea-2/resolve/main/text_encoders/qwen3vl_4b_bf16.safetensors"
)
VAE_MODELS=(
"https://huggingface.co/Comfy-Org/Krea-2/resolve/main/vae/qwen_image_vae.safetensors"
)
# Format: "URL|filename.safetensors"
LORA_MODELS=(
# --- Krea 2 : ControlNet + Outfit ---
"https://huggingface.co/Patil/Krea-2-depth-controlnet/resolve/main/depth-control-lora.safetensors|depth-control-lora.safetensors"
"https://huggingface.co/AliveAi/Krea-2-Edit-Outfit-Transfer/resolve/main/krea_outfittransfer.safetensors|krea_outfittransfer.safetensors"
# --- Krea 2 : LoRA Civitai ---
"https://civitai.com/api/download/models/3371956|K2-Casual-Snapshot-Realism-v2.safetensors"
"https://civitai.com/api/download/models/3278885|K2-Famegrid-Spicy.safetensors"
"https://civitai.com/api/download/models/3147117|K2-NSFW-v4.safetensors"
"https://civitai.com/api/download/models/3066079|K2-Raw-to-Turbo-r256.safetensors"
"https://civitai.com/api/download/models/3359022|K2-TextFusion-Refusal-Reduction-v2.safetensors"
"https://civitai.com/api/download/models/3141485|K2-RawGirlSpicy-v3.safetensors"
"https://civitai.com/api/download/models/3109006|K2-Realism-Engine-v3.safetensors"
"https://civitai.com/api/download/models/3390681|K2-SNOFS-v1.5.safetensors"
"https://civitai.com/api/download/models/3116175|K2-Mystic-XXX-v3.safetensors"
"https://civitai.com/api/download/models/3221218|K2-Excessive-Cum.safetensors"
"https://civitai.com/api/download/models/2268008|K2-Realistic-Snapshot-v1.safetensors" # ⚠️ vérifie que 2268008 est bien un ID de VERSION
"https://civitai.com/api/download/models/1862761|K2-NiceGirls-UltraReal-v1.safetensors" # ⚠️ vérifie que 1862761 est bien un ID de VERSION
# --- Ta LoRA perso (model01) ---
"https://huggingface.co/nathanglm/sofia/resolve/main/model01.safetensors|model01.safetensors"
# --- SDXL (détailleurs SDXL du workflow Krea2 v1.5) ---
#"https://civitai.com/api/download/models/368603|SDXL-Detailed-Nipples-v1.safetensors"
#"https://civitai.com/api/download/models/712004|SDXL-Real-Pussy-Lotte.safetensors"
#"https://civitai.com/api/download/models/216946|SDXL-Penis-XL-v1.safetensors"
)
# SDXL (Pre-Definer). Nom forcé = celui attendu par le workflow.
CHECKPOINT_MODELS=(
"https://civitai.com/api/download/models/1621447|sdxl-iniversemix.safetensors"
)
UNET_MODELS=(
)
SAMS=(
"https://huggingface.co/datasets/Gourieff/ReActor/resolve/main/models/sams/sam_vit_b_01ec64.pth"
)
BBOX=(
"https://huggingface.co/nathanglm/sofia/resolve/main/Eyes.pt"
"https://huggingface.co/nathanglm/sofia/resolve/main/Face.pt"
"https://huggingface.co/nathanglm/sofia/resolve/main/Foot.pt"
"https://huggingface.co/nathanglm/sofia/resolve/main/Hands.pt"
"https://huggingface.co/nathanglm/sofia/resolve/main/Nipples.pt"
"https://huggingface.co/nathanglm/sofia/resolve/main/Pussy.pt"
"https://huggingface.co/nathanglm/sofia/resolve/main/Pussy2.pt"
"https://huggingface.co/nathanglm/sofia/resolve/main/Penis.pt"
"https://huggingface.co/Bingsu/adetailer/resolve/main/face_yolov8m.pt"
"https://huggingface.co/Bingsu/adetailer/resolve/main/hand_yolov8s.pt"
)
SEGM=(
"https://huggingface.co/Bingsu/adetailer/resolve/main/person_yolov8m-seg.pt"
)
ESRGAN_MODELS=(
)
CONTROLNET_MODELS=(
)
### DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING ###
function provisioning_start() {
printf "\n=== Provisioning Krea 2 (modèles uniquement) ===\n\n"
provisioning_check_tokens
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/vae" "${VAE_MODELS[@]}"
provisioning_get_files "${COMFYUI_DIR}/models/loras" "${LORA_MODELS[@]}"
provisioning_get_files "${COMFYUI_DIR}/models/checkpoints" "${CHECKPOINT_MODELS[@]}"
provisioning_get_files "${COMFYUI_DIR}/models/unet" "${UNET_MODELS[@]}"
provisioning_get_files "${COMFYUI_DIR}/models/sams" "${SAMS[@]}"
provisioning_get_files "${COMFYUI_DIR}/models/ultralytics/bbox" "${BBOX[@]}"
provisioning_get_files "${COMFYUI_DIR}/models/ultralytics/segm" "${SEGM[@]}"
provisioning_get_files "${COMFYUI_DIR}/models/controlnet" "${CONTROLNET_MODELS[@]}"
provisioning_get_files "${COMFYUI_DIR}/models/upscale_models" "${ESRGAN_MODELS[@]}"
provisioning_get_files "${COMFYUI_DIR}/user/default/workflows" "${WORKFLOWS[@]}"
provisioning_report_bad_files
printf "\nProvisioning complete: Application will start now\n\n"
}
function provisioning_check_tokens() {
if provisioning_has_valid_civitai_token; then
printf "CIVITAI_TOKEN : OK\n"
else
printf "\n⚠️ CIVITAI_TOKEN absent ou invalide : les modèles Civitai vont échouer.\n\n"
fi
}
function provisioning_report_bad_files() {
printf "\nChecking for failed downloads...\n"
find "${COMFYUI_DIR}/models" -type f \( -name "*.safetensors" -o -name "*.pt" -o -name "*.pth" \) -size -100k 2>/dev/null | while read -r f; do
printf "⚠️ Fichier suspect (trop petit, probablement un échec) : %s\n" "$f"
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
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_has_valid_civitai_token() {
[[ -n "$CIVITAI_TOKEN" ]] || return 1
local code
code=$(curl -o /dev/null -s -w "%{http_code}" \
"https://civitai.com/api/v1/models?hidden=1&limit=1&token=${CIVITAI_TOKEN}")
[[ "$code" -eq 200 ]]
}
function download_civitai_bash() {
local url="$1" output_dir="$2" forced_filename="$3"
local model_id=""
[[ $url =~ /models/([0-9]+) ]] && model_id="${BASH_REMATCH[1]}"
local sep="?"; [[ "$url" == *"?"* ]] && sep="&"
local full_url="${url}${sep}token=${CIVITAI_TOKEN}"
local name="${forced_filename:-civitai_${model_id}.safetensors}"
local output_file="${output_dir}/${name}"
if [[ -f "$output_file" ]]; then
printf "File already exists: %s\n" "$name"
return 0
fi
printf "Downloading CivitAI model %s to: %s\n" "$model_id" "$name"
local code
code=$(curl -L --progress-bar -w "%{http_code}" -o "$output_file" "$full_url")
if [[ "$code" != "200" ]]; then
rm -f "$output_file"
printf "ERROR %s pour le modèle %s\n" "$code" "$model_id"
[[ "$code" == "404" ]] && printf " -> ID de version invalide ou fichier introuvable\n"
[[ "$code" == "401" || "$code" == "403" ]] && printf " -> problème de token Civitai\n"
return 1
fi
printf "Download completed: %s\n" "$name"
}
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
local hf_header=()
if [[ -n "$HF_TOKEN" && $url == https://huggingface.co/* ]]; then
hf_header=(--header="Authorization: Bearer $HF_TOKEN")
fi
if [[ -n "$forced_filename" ]]; then
if [[ -f "${dir}/${forced_filename}" ]]; then
printf "File already exists: %s\n" "$forced_filename"
return 0
fi
wget -q --show-progress "${hf_header[@]}" -e dotbytes=4M -O "${dir}/${forced_filename}" "$url" || rm -f "${dir}/${forced_filename}"
else
wget -qnc --content-disposition --show-progress "${hf_header[@]}" -e dotbytes=4M -P "$dir" "$url"
fi
fi
}
if [[ ! -f /.noprovisioning ]]; then
provisioning_start
fi |