Download krea.sh from nathanglm/sofia: direct link, hf CLI and curl.
- Browser
- Download file 9.59 kB
-
https://huggingface.co/nathanglm/sofia/resolve/main/krea.sh
- Command line
-
hf download hf://nathanglm/sofia/krea.sh
-
curl -L -o krea.sh https://huggingface.co/nathanglm/sofia/resolve/main/krea.sh
9.59 kB
| # ============================================================================= | |
| # 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 |