流程就是通过http的调用prompt接口提交生成图片的请求
1、提交生成图片请求接口
http://127.0.0.1:8188/
POST /prompt
prompt参数
{
"client_id": "533ef3a3-39c0-4e39-9ced-37d290f371f8",
"prompt": {
"3": {
"inputs": {
"seed": 764714814161513,
"steps": 26,
"cfg": 5,
"sampler_name": "dpmpp_3m_sde_gpu",
"scheduler": "karras",
"denoise": 1,
"model": [
"40",
0
],
"positive": [
"49",
0
],
"negative": [
"6",
0
],
"latent_image": [
"5",
0
]
},
"class_type": "KSampler"
},
"5": {
"inputs": {
"width": 1024,
"height": 768,
"batch_size": 1
},
"class_type": "EmptyLatentImage"
},
"6": {
"inputs": {
"text": "",
"clip": [
"40",
1
]
},
"class_type": "CLIPTextEncode"
},
"8": {
"inputs": {
"samples": [
"3",
0
],
"vae": [
"40",
2
]
},
"class_type": "VAEDecode"
},
"9": {
"inputs": {
"filename_prefix": "ComfyUI",
"images": [
"8",
0
]
},
"class_type": "SaveImage"
},
"13": {
"inputs": {
"clip_vision": [
"39",
0
],
"image": [
"34",
0
]
},
"class_type": "CLIPVisionEncode"
},
"19": {
"inputs": {
"strength": 1,
"noise_augmentation": 0,
"conditioning": [
"42",
0
],
"clip_vision_output": [
"13",
0
]
},
"class_type": "unCLIPConditioning"
},
"34": {
"inputs": {
"image": "clipspace/clipspace-mask-1645940.7000000002.png [input]",
"choose file to upload": "image"
},
"class_type": "LoadImage"
},
"36": {
"inputs": {
"clip_vision": [
"39",
0
],
"image": [
"38",
0
]
},
"class_type": "CLIPVisionEncode"
},
"37": {
"inputs": {
"strength": 0.75,
"noise_augmentation": 0,
"conditioning": [
"19",
0
],
"clip_vision_output": [
"36",
0
]
},
"class_type": "unCLIPConditioning"
},
"38": {
"inputs": {
"image": "beijing1 (2).webp",
"choose file to upload": "image"
},
"class_type": "LoadImage"
},
"39": {
"inputs": {
"clip_name": "clip_vision_g.safetensors"
},
"class_type": "CLIPVisionLoader"
},
"40": {
"inputs": {
"ckpt_name": "sd_xl_base_1.0.safetensors"
},
"class_type": "CheckpointLoaderSimple"
},
"42": {
"inputs": {
"conditioning": [
"6",
0
]
},
"class_type": "ConditioningZeroOut"
},
"43": {
"inputs": {
"safe": "enable"
},
"class_type": "HEDPreprocessor"
},
"44": {
"inputs": {
"safe": "enable",
"image": [
"34",
0
]
},
"class_type": "HEDPreprocessor"
},
"45": {
"inputs": {
"images": [
"44",
0
]
},
"class_type": "PreviewImage"
},
"46": {
"inputs": {
"control_net_name": "control-lora-depth-rank256.safetensors"
},
"class_type": "ControlNetLoader"
},
"47": {
"inputs": {
"image": [
"34",
0
]
},
"class_type": "ScribblePreprocessor"
},
"48": {
"inputs": {
"images": [
"47",
0
]
},
"class_type": "PreviewImage"
},
"49": {
"inputs": {
"strength": 0.5,
"conditioning": [
"37",
0
],
"control_net": [
"46",
0
],
"image": [
"47",
0
]
},
"class_type": "ControlNetApply"
}
}
}client_id就是你自己传给comfyui的一个参数,这个在后来的comfyui通知你生成图片的进度的时候有用2、实时获取任务进度
websocket:/ws?client_id=第一步的client_id
当获取绘图结束的通知消息的时候,消息如下:
{
"type":"executing",
"data":{
"node":null,
"prompt_id":"37099310-a790-44f4-8d13-41111232"
}
}
3、调用GET /history/{prompt_id}获取输出的图片信息{
"37099310-a790-44f4-8d13-41111232": {
略。。。。。。。。。。
"outputs": {
"18": {
"images": [
{
"filename": "ComfyUI_temp_slqio_00001_.png",
"subfolder": "",
"type": "temp"
},
{
"filename": "ComfyUI_temp_slqio_00002_.png",
"subfolder": "",
"type": "temp"
},
{
"filename": "ComfyUI_temp_slqio_00003_.png",
"subfolder": "",
"type": "temp"
},
{
"filename": "ComfyUI_temp_slqio_00004_.png",
"subfolder": "",
"type": "temp"
}
]
},
}
}
}
1其中filename就是生成图片的名称
4、显示图片
调用这个url http://127.0.0.1:8188/view?filename=ComfyUI_00705_.png&type=output
就能显示这个图片了
网友回复


