Files
xiaden-comfyui-imgutils/restore/node_nafnet.py
T
xiaden 7d82aa22e6 Full split: 26 dedicated nodes with native knobs exposed
Sub-packages:
- edge/ — Canny, Lineart, LineartAnime (3 nodes)
- restore/ — SCUNet, NAFNet, Adversarial (3 nodes)
- compare/ — CCIP, LPIPS (2 nodes)
- validate/ — Classify (11 ops), Check (5 ops), Metric (2 ops)
- tagging/ — WD14, DeepDanbooru, DeepGelbooru, MLDanbooru, Camie, PixAI (6 nodes)

Root nodes:
- ImgUtilsOCR — PaddleOCR with heat/box threshold
- ImgUtilsDetect — 10 detection types + confidence knob
- ImgUtilsPose — DWPose + auto_detect toggle
- ImgUtilsSegment — isnetis + scale knob
- ImgUtilsTags — tag string processing
- ImgUtilsCDC — upscaling + tile_size
- ImgUtilsCensor — NSFW censoring with method/confidence/body-part toggles
- ImgUtilsAlign — resize to max dimension
- ImgUtilsSqueeze — transparency-based auto-crop

Every node exposes its native function parameters as knobs.
Removed mega-nodes: transform (11 ops), compare (3 ops), validate (18 ops).
2026-07-03 01:11:46 +00:00

30 lines
1.4 KiB
Python

"""Node: ImgUtilsNAFNet — NAFNet image restoration."""
from __future__ import annotations
from comfy_api.latest import io
from ..utils import comfy_to_pil, pil_to_comfy
class ImgUtilsNAFNet(io.ComfyNode):
MODELS = ["REDS", "GoPro", "SIDD"]
@classmethod
def define_schema(cls) -> io.Schema:
return io.Schema(
node_id="ImgUtilsNAFNet", display_name="Imgutils Restore (NAFNet)",
category="imgutils/restore",
description="Restore/de-blur images using NAFNet. Note: may struggle with Gaussian noise.",
search_aliases=["restore", "nafnet", "deblur", "clean", "enhance"],
inputs=[
io.Image.Input("image", tooltip="Input image"),
io.Combo.Input("model", options=cls.MODELS, default="REDS", tooltip="NAFNet model: REDS, GoPro, or SIDD."),
io.Int.Input("tile_size", default=256, min=64, max=512, step=64, tooltip="Processing tile size."),
],
outputs=[io.Image.Output(display_name="image")],
)
@classmethod
def execute(cls, image, model, tile_size) -> io.NodeOutput:
from imgutils.restore import restore_with_nafnet
pil = comfy_to_pil(image.numpy() if hasattr(image, "numpy") else image)
result = restore_with_nafnet(pil, model=str(model), tile_size=int(tile_size))
return io.NodeOutput(pil_to_comfy(result))