Upscale and restore detail
Enlarge an image and restore fine detail with SeedVR2.
下载工作流在 Cloud 中试用 API 文档
查看工作流内部
源模板的只读预览。在 Cloud 中打开,即可查看节点并进行修改。
Loading the graph
Open full-size workflow preview- 作者
- ComfyUI
从代码中调用该模型
以下请求使用与体验区相同的预设图和设置。每次提交都可能开始一次付费运行;如果提交结果未知,请勿自动重试。
1 获取 API 密钥 ↗
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({
"24": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"45": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "ComfyUI-upscaled",
"images": [
"47:27",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"47:21": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"24",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"47:22": {
"class_type": "SeedVR2LoadVAEModel",
"inputs": {
"cache_model": False,
"decode_tile_overlap": 128,
"decode_tile_size": 1024,
"decode_tiled": True,
"device": "cuda:0",
"encode_tile_overlap": 128,
"encode_tile_size": 1024,
"encode_tiled": True,
"model": "ema_vae_fp16.safetensors",
"offload_device": "none",
"tile_debug": "false"
},
"_meta": {
"title": "SeedVR2 (Down)Load VAE Model"
}
},
"47:25": {
"class_type": "SimpleMath+",
"inputs": {
"a": [
"47:43",
0
],
"b": [
"47:30",
0
],
"value": "a*b"
},
"_meta": {
"title": "Upscale to Shortest Edge (pixels)"
}
},
"47:27": {
"class_type": "SeedVR2VideoUpscaler",
"inputs": {
"batch_size": 1,
"color_correction": "lab",
"dit": [
"47:28",
0
],
"enable_debug": False,
"image": [
"24",
0
],
"input_noise_scale": 0,
"latent_noise_scale": 0,
"max_resolution": 0,
"offload_device": "cpu",
"prepend_frames": 0,
"resolution": [
"47:25",
0
],
"seed": 296258884,
"temporal_overlap": 0,
"uniform_batch_size": False,
"vae": [
"47:22",
0
]
},
"_meta": {
"title": "SeedVR2 Video Upscaler (v2.5.24)"
}
},
"47:28": {
"class_type": "SeedVR2LoadDiTModel",
"inputs": {
"attention_mode": "sdpa",
"blocks_to_swap": 0,
"cache_model": False,
"device": "cuda:0",
"model": "seedvr2_ema_7b_fp16.safetensors",
"offload_device": "cpu",
"swap_io_components": False
},
"_meta": {
"title": "SeedVR2 (Down)Load DiT Model"
}
},
"47:30": {
"class_type": "PrimitiveFloat",
"inputs": {
"value": 4
},
"_meta": {
"title": "Upscale Factor"
}
},
"47:40": {
"class_type": "ImpactCompare",
"inputs": {
"a": [
"47:21",
0
],
"b": [
"47:21",
1
],
"cmp": "a <= b"
},
"_meta": {
"title": "ImpactCompare"
}
},
"47:43": {
"class_type": "LayerUtility: If ",
"inputs": {
"if_condition": [
"47:40",
0
],
"when_FALSE": [
"47:21",
1
],
"when_TRUE": [
"47:21",
0
]
},
"_meta": {
"title": "IfElse"
}
}
})
workflow.set_input("24", "image", client.assets.from_url("https://cdn.jsdelivr.net/gh/Comfy-Org/workflow_templates@90c71fb78b3726392d010ff62a8e79e92d7296ad/input/vr_ad.png"))
# 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("45"):
output.to_file(output.name)