图像修复: SUPIR
利用SUPIR的生成先验和文本指导来恢复和增强图像。接受图像和可选的文本提示,实现智能修复,获得高质量结果。
Your output will appear here.
查看工作流内部
源模板的只读预览。在 Cloud 中打开,即可查看节点并进行修改。
Loading the graph
Open full-size workflow preview从代码中调用该模型
以下请求使用与体验区相同的预设图和设置。每次提交都可能开始一次付费运行;如果提交结果未知,请勿自动重试。
What you need
- Runs on
- Comfy Cloud
- 密钥
- COMFY_API_KEY
- 你的文件
- 由代码根据链接上传
需要付费的 Cloud 方案和额度。
# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"92": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"96": {
"class_type": "ImageCompare",
"inputs": {
"compare_view": None,
"image_a": [
"92",
0
],
"image_b": [
"85:39",
0
]
},
"_meta": {
"title": "Compare Images"
}
},
"97": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "upscaled_by_supir",
"images": [
"85:39",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"85:1": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "juggernautXL_v9Rdphoto2Lightning.safetensors"
},
"_meta": {
"title": "Load Checkpoint"
}
},
"85:11": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"85:20",
0
],
"vae": [
"85:1",
2
]
},
"_meta": {
"title": "VAE Decode"
}
},
"85:20": {
"class_type": "SamplerCustom",
"inputs": {
"add_noise": True,
"cfg": 1.5,
"latent_image": [
"85:57",
0
],
"model": [
"85:62",
0
],
"negative": [
"85:60",
0
],
"noise_seed": 402244474214267,
"positive": [
"85:59",
0
],
"sampler": [
"85:76",
0
],
"sigmas": [
"85:29",
0
]
},
"_meta": {
"title": "SamplerCustom"
}
},
"85:29": {
"class_type": "BasicScheduler",
"inputs": {
"denoise": 1,
"model": [
"85:62",
0
],
"scheduler": "sgm_uniform",
"steps": 10
},
"_meta": {
"title": "BasicScheduler"
}
},
"85:3": {
"class_type": "ModelPatchLoader",
"inputs": {
"name": "SUPIR-v0Q_fp16.safetensors"
},
"_meta": {
"title": "Load Model Patch"
}
},
"85:39": {
"class_type": "ColorTransfer",
"inputs": {
"image_ref": [
"85:94",
0
],
"image_target": [
"85:11",
0
],
"method": "mkl_lab",
"source_stats": "per_frame",
"strength": 1
},
"_meta": {
"title": "Transfer Color"
}
},
"85:57": {
"class_type": "EmptyLatentImage",
"inputs": {
"batch_size": 1,
"height": [
"85:58",
1
],
"width": [
"85:58",
0
]
},
"_meta": {
"title": "Empty Latent Image"
}
},
"85:58": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"85:94",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"85:59": {
"class_type": "CLIPTextEncodeSDXL",
"inputs": {
"clip": [
"85:1",
1
],
"crop_h": 0,
"crop_w": 0,
"height": 1024,
"target_height": 1024,
"target_width": 1024,
"text_g": [
"85:88",
0
],
"text_l": [
"85:88",
0
],
"width": 1024
},
"_meta": {
"title": "CLIP Text Encode (SDXL)"
}
},
"85:60": {
"class_type": "CLIPTextEncodeSDXL",
"inputs": {
"clip": [
"85:1",
1
],
"crop_h": 0,
"crop_w": 0,
"height": 1024,
"target_height": 1024,
"target_width": 1024,
"text_g": [
"85:73",
0
],
"text_l": [
"85:73",
0
],
"width": 1024
},
"_meta": {
"title": "CLIP Text Encode (SDXL)"
}
},
"85:62": {
"class_type": "SUPIRApply",
"inputs": {
"image": [
"85:94",
0
],
"model": [
"85:1",
0
],
"model_patch": [
"85:3",
0
],
"restore_cfg": 4,
"restore_cfg_s_tmin": 0.05,
"strength_end": 0.9,
"strength_start": 1,
"vae": [
"85:1",
2
]
},
"_meta": {
"title": "SUPIRApply"
}
},
"85:71": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "`A herd of wild horses gallops at night through a neon-lit city street, motion blur conveying raw energy against the urban glow.`"
},
"_meta": {
"title": "Text (Multiline)"
}
},
"85:73": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "painting, oil painting, illustration, drawing, art, sketch, cartoon, CG Style, 3D render, unreal engine, blurring, dirty, messy, worst quality, low quality, frames, watermark, signature, jpeg artifacts, deformed, lowres, over-smooth bad quality, blurry, messy"
},
"_meta": {
"title": "Text (Multiline)"
}
},
"85:76": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "dpmpp_2m_sde"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"85:86": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen3.5_4b_bf16.safetensors",
"device": "default",
"type": "stable_diffusion"
},
"_meta": {
"title": "Load CLIP"
}
},
"85:87": {
"class_type": "TextGenerate",
"inputs": {
"clip": [
"85:86",
0
],
"image": [
"92",
0
],
"max_length": 2048,
"mtp": "auto",
"prompt": [
"85:91",
0
],
"sampling_mode": "on",
"sampling_mode.min_p": 0.05,
"sampling_mode.presence_penalty": 0,
"sampling_mode.repetition_penalty": 1.05,
"sampling_mode.seed": 0,
"sampling_mode.temperature": 0.7,
"sampling_mode.top_k": 64,
"sampling_mode.top_p": 0.95,
"thinking": False,
"use_default_template": True
},
"_meta": {
"title": "Generate Text (DEPRECATED)"
}
},
"85:88": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"85:71",
0
],
"on_true": [
"85:87",
0
],
"switch": [
"85:90",
0
]
},
"_meta": {
"title": "If/Else Switch"
}
},
"85:89": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"85:88",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"85:90": {
"class_type": "BOOLConstant",
"inputs": {
"value": True
},
"_meta": {
"title": "enable_image_captioning"
}
},
"85:91": {
"class_type": "StringConcatenate",
"inputs": {
"delimiter": "",
"string_a": "Describe the scene concisely in English, using vivid, descriptive keywords and phrases suitable for AI image generation (SDXL). Focus only on visual elements, composition, lighting, style, and atmosphere. Do not include extra explanations or instructions.",
"string_b": [
"85:71",
0
]
},
"_meta": {
"title": "Concatenate Text"
}
},
"85:94": {
"class_type": "ResizeImageMaskNode",
"inputs": {
"input": [
"92",
0
],
"resize_type": "scale total pixels",
"resize_type.megapixels": 2.25,
"scale_method": "lanczos"
},
"_meta": {
"title": "Resize Image/Mask"
}
}
})
# Replace each example.com URL with a public URL of your file.
workflow.set_input("92", "image", client.assets.from_url("https://example.com/replace-with-a-url/image"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)
for output in job.get_outputs("97"):
output.to_file(output.name)关于此工作流
SUPIR restores rather than merely enlarges: it re-synthesises detail the source lost, guided by a prompt, then colour-transfers the result back onto the original so the grade survives. The shipped case is a night-time neon street of horses, described by the prompt and lifted to about 2.3 megapixels at the same framing.
Graph: LoadImage -> ResizeImageMaskNode (scale total pixels to 2.25 MP) -> SUPIRApply (SUPIR-v0Q_fp16, strength 1 -> 0.9, restore_cfg 4) -> SamplerCustom (dpmpp_2m_sde, sgm_uniform, 10 steps, cfg 1.5) -> VAEDecode -> ColorTransfer (mkl_lab, per frame) -> SaveImage. A caption branch feeds the prompt: a Qwen 3.5 4B TextGenerate describes the image, and a switch (on by default) chooses that over the hand-written prompt in the PrimitiveStringMultiline.
Runs on open weights in the cloud worker; no partner API.