Upscale and restore detail
Enlarge an image and restore fine detail with SeedVR2.
Baixar workflowExperimentar no Cloud Documentação da API
Dentro do workflow
Uma prévia somente leitura do modelo de origem. Abra-o no Cloud para explorar os nós e fazer alterações.
Loading the graph
Open full-size workflow preview- Autor
- ComfyUI
Chame este modelo pelo seu código
A solicitação abaixo usa o mesmo grafo e as mesmas configurações preparadas no Playground. Cada envio pode iniciar uma execução paga; não tente novamente automaticamente um envio cujo resultado seja desconhecido.
1 Obter chave de API ↗
What you need
- Runs on
- Comfy Cloud
- Chave
- COMFY_API_KEY
- Seus arquivos
- Enviados pelo código a partir de suas URLs
Requer um plano pago do Cloud e créditos.
# 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)