From 8d61721196c9f6a6b841dc3bdbb9ea9dada61c82 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 24 Mar 2026 11:16:45 +0200 Subject: Add SUPIR photo restoration + local colour corrections - workflows/photo-enhance.json: replace Real-ESRGAN-only pipeline with SUPIR_Upscale (SUPIR-v0Q + SDXL base backbone). Parameters: 20 steps, scale_by=1.0 (original resolution), Wavelet colour fix, tiled VAE + tiled sampling for L40 VRAM headroom. - photo-enhance.rb: add ImageMagick colour corrections after download: S-curve contrast (-sigmoidal-contrast 3,50%), +20% saturation (-modulate 100,120,100), micro-contrast sharpening (-unsharp). These stack on top of SUPIR's internal Wavelet colour fix. - hyperstack.rb: update comfyui_install_script to install ComfyUI-SUPIR custom node and download both SUPIR-v0Q + sd_xl_base_1.0 on provision. - hyperstack.rb: extend status_config_loaders to auto-discover hyperstack-vm-photo.toml so --watch shows the photo VM. Co-Authored-By: Claude Sonnet 4.6 --- hyperstack.rb | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'hyperstack.rb') diff --git a/hyperstack.rb b/hyperstack.rb index e04355b..61f53ec 100755 --- a/hyperstack.rb +++ b/hyperstack.rb @@ -1371,8 +1371,15 @@ module HyperstackVM script << 'done' script << "curl -sf http://localhost:#{port}/system_stats >/dev/null || { echo 'FATAL: ComfyUI did not become ready within 5 minutes'; exit 1; }" + # Install ComfyUI-SUPIR custom node (provides SUPIR_Upscale and related nodes). + supir_node_dir = "#{install_dir}/custom_nodes/ComfyUI-SUPIR" + script << "if [ ! -d #{Shellwords.escape(supir_node_dir)} ]; then" + script << " git clone --depth 1 https://github.com/kijai/ComfyUI-SUPIR #{Shellwords.escape(supir_node_dir)}" + script << " #{venv_dir}/bin/pip install --quiet -r #{Shellwords.escape("#{supir_node_dir}/requirements.txt")}" + script << 'fi' + # Download model weights into the ComfyUI subdirectories. - # Real-ESRGAN → upscale_models/; SUPIR → checkpoints/. + # Real-ESRGAN → upscale_models/; SUPIR → checkpoints/; SDXL base → checkpoints/. model_names.each do |model_name| case model_name when /RealESRGAN/i @@ -1386,15 +1393,27 @@ module HyperstackVM script << "mkdir -p #{Shellwords.escape(dest_dir)}" script << "[ -f #{Shellwords.escape(dest_file)} ] || wget -q --show-progress -O #{Shellwords.escape(dest_file)} #{Shellwords.escape(url)}" when /SUPIR/i + # SUPIR-v0Q (~5 GB): AI photo restoration backbone (denoising + detail recovery). + # SDXL base (~7 GB): provides CLIP encoders that SUPIR uses for text conditioning. + # Both must live in checkpoints/ so SUPIR_Upscale can find them by filename. dest_dir = "#{models_dir}/checkpoints" - # SUPIR weights on HuggingFace; v0Q is the quantised variant (~8 GB). hf_file = model_name.end_with?('F') ? 'SUPIR-v0F.ckpt' : 'SUPIR-v0Q.ckpt' - url = "https://huggingface.co/camenduru/SUPIR/resolve/main/#{hf_file}" + supir_url = "https://huggingface.co/camenduru/SUPIR/resolve/main/#{hf_file}" + sdxl_url = 'https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors' script << "mkdir -p #{Shellwords.escape(dest_dir)}" - script << "[ -f #{Shellwords.escape("#{dest_dir}/#{hf_file}")} ] || wget -q --show-progress -O #{Shellwords.escape("#{dest_dir}/#{hf_file}")} #{Shellwords.escape(url)}" + script << "[ -f #{Shellwords.escape("#{dest_dir}/#{hf_file}")} ] || wget -q --show-progress -O #{Shellwords.escape("#{dest_dir}/#{hf_file}")} #{Shellwords.escape(supir_url)}" + script << "[ -f #{Shellwords.escape("#{dest_dir}/sd_xl_base_1.0.safetensors")} ] || wget -q --show-progress -O #{Shellwords.escape("#{dest_dir}/sd_xl_base_1.0.safetensors")} #{Shellwords.escape(sdxl_url)}" end end + # Restart ComfyUI so it picks up the new custom nodes and model files. + script << "sudo systemctl restart #{Shellwords.escape(service)}" + script << 'echo "Waiting for ComfyUI restart..."' + script << 'for i in $(seq 1 60); do' + script << " if curl -sf http://localhost:#{port}/system_stats >/dev/null 2>&1; then echo comfyui-ready; break; fi" + script << " echo \" ComfyUI not ready yet ($i/60)...\"; sleep 5" + script << 'done' + script << 'echo comfyui-install-ok' script.join("\n") end -- cgit v1.2.3