ComfyUI Node

HYPIR Image Restore

The diffusion restorer that's trying not to change your photo

By EricRollei·Created 11 months ago·Updated 10 months ago· 15
HYPIR Image Restore
  • image
  • image
  • seed
  • prompt
prompt
base_model_pathstabilityai/stable-diffusion-2-1-base
weight_nameHYPIR_sd2.pth
upscale4.0
patch_size512
stride256
scale_byfactor
target_longest_side2048
seed-1
enhance_promptfalse
lm_endpointhttp://127.0.0.1:1234
lm_modellmstudio
lm_system_promptYou are an expert photographic conservator working with Stable Diffusion 2.1 and the HYPIR restoration LoRA. Rewrite the provided notes into a concise 1-2 sentence restoration prompt that keeps subjects, era, and mood intact. Emphasise realistic fine detail, natural lighting, gentle noise reduction, and faithful colour recovery. Do not invent new elements, props, or camera changes unless explicitly requested. Return only the final prompt text without quotes. If the user supplies no notes, respond with: 'Restored vintage photograph, faithful colours, natural film grain preserved, realistic detail and gentle contrast.' Example: Restored 1950s family portrait, smiling couple on front porch, warm evening light, crisp yet natural detail, subtle grain preserved.
lm_temperature0.60
lm_max_tokens120
enhancement_strength1.00
detail_boost0.00
detail_sigma1.0

If you've ever fed a faded family scan through a generative upscaler and got back a photo where your grandfather's face is now a handsome stranger, you know the problem HYPIR is answering. It's the same XPixelGroup lab as SUPIR - same "restoration as diffusion" idea - but built on Stable Diffusion 2.1 instead of SDXL, and tuned to be conservative. Where SUPIR captions your image with an LLM and rebuilds it toward what that caption describes, HYPIR just cleans and upscales what's actually there. People who run it describe it exactly that way: reach for it "if you don't want to change the image much."

This node (HyperComfyUIHYPIRRestore) wraps the upstream HYPIR method so you can run it inside ComfyUI. It lands under Hyper Image Restoration/HYPIR, and its happy place is film scans, old prints, and other genuinely damaged sources where you want repairs, not reinvention. Know the context though: by 2026 the default for this job is SeedVR2 or Qwen-Edit, and Comfy Org's upscaling handbook conspicuously left SUPIR and HYPIR out. This is a niche tool for a specific taste - keeping the source recognizable - not the state of the art.

How it works

Under the hood it's a one-step diffusion restore: your image gets bicubic-upscaled to the target size, VAE-encoded into SD2.1's latent space, then pushed through a LoRA-tuned UNet at a fixed timestep (200) that predicts the clean latent in a single denoising step. Decode and you're done - no multi-step sampling loop. That's why it's so much faster than SUPIR and runs fine on older GPUs, and the tiled VAE encode/decode keeps big scans from OOMing you.

The mechanism is worth remembering when you hit the inputs: nothing here touches your ComfyUI checkpoints. The node loads its own diffusers copy of SD2.1 (UNet, VAE, text encoder, tokenizer, scheduler) plus the HYPIR LoRA - a small ComfyUI inside a node, and the first run downloads several gigabytes before anything happens.

The inputs that matter

The README calls image, prompt, base_model_path, weight_name, upscale, patch_size/stride, and scale_by required, but you mostly care about four:

  • upscale (default 4, range 1–8) - the factor applied before restoration. 2× on a scan that's already big, 4× if you need print size.
  • scale_by - factor (default) or longest_side. Pick longest_side and set target_longest_side when you want a specific output dimension instead of a multiplier.
  • patch_size / stride (512 / 256) - tile size and overlap for latent processing. This is your memory dial: smaller patches, more VRAM headroom.
  • weight_name - dropdown of LoRA files in the node's models/ folder.

Two more worth knowing, both optional: enhancement_strength blends the restored output with the original (0.5 = half-and-half - the honest "I don't fully trust it" setting), and detail_boost (0–1, with detail_sigma for the blur radius) adds an unsharp-mask-style crispness layer that scans often want.

Outputs: image wires to any Save Image node, seed back into a seed control if you want reproducible runs, and prompt is the text that was actually fed to the model - handy because it's the third output, not the image, that tells you whether your enhancement did anything.

There's also a prompt-enhancement sidecar: flip enhance_prompt on and the node sends your notes to an LM Studio chat-completions endpoint (lm_endpoint default http://127.0.0.1:1234, lm_model from LM Studio's UI) and rewrites them into a restoration prompt. It's the pack's one distinctive feature, it's entirely optional, and for plain scans you can ignore it - an empty prompt just means prompt-free restoration.

Installing it

ComfyUI Manager → search "HYPIR" → Install → restart. Or the manual way:

cd ComfyUI/custom_nodes
git clone https://github.com/EricRollei/HYPIR-ComfyUI
# restart ComfyUI

Then two downloads, and this is where people get burned:

  1. The LoRA: grab HYPIR_sd2.pth from https://huggingface.co/lxq007/HYPIR/tree/main and drop it in HYPIR-ComfyUI/models/.
  2. A diffusers-format SD2.1 base. The default base_model_path of stabilityai/stable-diffusion-2-1-base (512px) works out of the box and downloads on demand; stabilityai/stable-diffusion-2-1 (768px) is sharper if you want it. If you prefer offline: huggingface-cli download stabilityai/stable-diffusion-2-1 --local-dir "<your path>" --local-dir-use-symlinks False and point base_model_path at that folder.

Dependencies (torch, diffusers, transformers, peft, accelerate, numpy, Pillow, tqdm, requests) are all present in recent ComfyUI builds, so a stock install usually just works.

Common issues

  • "Missing config.json" - you pointed base_model_path at a raw checkpoint (.safetensors) instead of a real diffusers directory. Give it the repo id or a proper diffusers folder.
  • Out of memory - lower patch_size, raise stride, or switch to scale_by = longest_side with a smaller target_longest_side.
  • LM Studio not triggering - verify lm_endpoint/lm_model, make sure the server's running, and watch the console for [HYPIR] warnings; on any failure it silently falls back to your original prompt.

One more thing before you use this for client work: HYPIR is non-commercial only, and this pack ships under a CC BY-NC 4.0 / commercial dual license - you need to contact the author (Eric Hiss) for commercial use. Same shape of trap as SUPIR and InsightFace: the code reads free, the thing you actually need isn't.

CategoryHyper Image Restoration/HYPIR

Inputs (19)

NameTypeDefaultDescription
imageIMAGE
promptSTRING
base_model_pathSTRINGstabilityai/stable-diffusion-2-1-baseDiffusers-format directory or Hugging Face repo id (e.g. stabilityai/stable-diffusion-2-1-base).
weight_nameSTRINGHYPIR_sd2.pthName of the HYPIR LoRA weight file placed in the node's models folder.
upscaleFLOAT4.01–8Upscale factor applied before restoration (matches HYPIR defaults).
patch_sizeINT512256–1024Tile size used for latent processing and VAE tiling.
strideINT256128–1024Stride between tiles. Lower values improve seam quality at the cost of time.
scale_bySTRINGfactorChoose between fixed upscale factor or fitting to a target longest side.
target_longest_sideoptINT2048256–8192Used when scale_by=longest_side. Final longest edge after upscaling.
seedoptINT-1Random seed for deterministic noise sampling. Use -1 for random seed each run.
enhance_promptoptBOOLEANfalseToggle to rewrite the prompt using an LM Studio chat completion before restoration.
lm_endpointoptSTRINGhttp://127.0.0.1:1234LM Studio base URL (without /v1/chat/completions).
lm_modeloptSTRINGlmstudioModel identifier exposed by LM Studio (see the UI > Provider > Model).
lm_system_promptoptSTRINGYou are an expert photographic conservator working with Stable Diffusion 2.1 and the HYPIR restoration LoRA. Rewrite the provided notes into a concise 1-2 sentence restoration prompt that keeps subjects, era, and mood intact. Emphasise realistic fine detail, natural lighting, gentle noise reduction, and faithful colour recovery. Do not invent new elements, props, or camera changes unless explicitly requested. Return only the final prompt text without quotes. If the user supplies no notes, respond with: 'Restored vintage photograph, faithful colours, natural film grain preserved, realistic detail and gentle contrast.' Example: Restored 1950s family portrait, smiling couple on front porch, warm evening light, crisp yet natural detail, subtle grain preserved.System prompt fed to LM Studio when enhancing text prompts.
lm_temperatureoptFLOAT0.600–2Sampling temperature passed to LM Studio.
lm_max_tokensoptINT12016–512Maximum number of tokens generated by LM Studio for the enhanced prompt.
enhancement_strengthoptFLOAT1.000–1Blend between the original image (0) and the full HYPIR result (1).
detail_boostoptFLOAT0.000–1Add extra high-frequency detail on top of the restored image.
detail_sigmaoptFLOAT1.00.1–5Controls the radius of the detail boost blur (higher = broader).

Outputs (3)

NameTypeDescription
imageIMAGE
seedINT
promptSTRING