#!/usr/bin/env bash # Create the isolated environment for the Polish number normalizer. # # ./setup.sh venv + dependencies # ./setup.sh --model also download both models (see below) # ./setup.sh --cpu CPU-only torch, for a machine without an NVIDIA GPU # # Kept separate from the ComfyUI environment on purpose: this needs # transformers >= 5, and the TTS install must not be disturbed. set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" VENV="$HERE/venv" MODEL_DIR="$HERE/model" MODEL_REPO="Folx/qwen3-0.6b-pl-text-normalization" # gated: times, dates, IDs LLM_REPO="CYFRAGOVPL/PLLuM-4B-instruct-2512" # open: grammar of plain integers LLM_DIR="$HERE/models/PLLuM-4B-instruct-2512" TORCH_INDEX="https://download.pytorch.org/whl/cu128" # same wheels as ComfyUI WANT_MODEL=0 CPU_ONLY=0 for arg in "$@"; do case "$arg" in --model) WANT_MODEL=1 ;; --cpu) CPU_ONLY=1 ;; -h|--help) sed -n '2,10p' "${BASH_SOURCE[0]}" | sed 's/^# \?//'; exit 0 ;; *) echo "Unknown option: $arg" >&2; exit 2 ;; esac done say() { printf '\n\033[1;36m==> %s\033[0m\n' "$1"; } say "Creating $VENV" python3 -m venv "$VENV" "$VENV/bin/pip" install --upgrade pip --quiet say "Installing torch" if [ "$CPU_ONLY" = 1 ]; then "$VENV/bin/pip" install torch --index-url https://download.pytorch.org/whl/cpu else "$VENV/bin/pip" install torch --index-url "$TORCH_INDEX" fi say "Installing transformers, accelerate, num2words" "$VENV/bin/pip" install "transformers>=5.0.0" "accelerate>=0.26.0" "num2words>=0.5.13" if [ "$WANT_MODEL" = 1 ]; then "$VENV/bin/pip" install --quiet "huggingface_hub[cli]" # The inflection model first: it needs no account, so the install gets as # far as it can before anything can ask for credentials. if [ -f "$LLM_DIR/config.json" ]; then say "$LLM_REPO already present" else say "Downloading $LLM_REPO (8 GB, no account needed)" "$VENV/bin/hf" download "$LLM_REPO" --local-dir "$LLM_DIR" fi say "Downloading $MODEL_REPO" # Either an HF_TOKEN in the environment or a stored `hf auth login` works; # the CLI picks up both on its own. Only say something when there is # neither, because the failure then is a confusing "access denied". if [ -f "$MODEL_DIR/config.json" ]; then say "$MODEL_REPO already present" elif [ -z "${HF_TOKEN:-}" ] && ! "$VENV/bin/hf" auth whoami >/dev/null 2>&1; then # Not fatal. Everything else is installed and useful; this one model # needs a human to accept a licence, which no installer can do. cat >&2 <