TypeSafe Jev:判定、打分、分类与择优
Jev 能回答关于文本、图片或两者的是非、打分、多选、批量择优等问题,并把答案作为可分支的值返回。一个工作流里放了四个完整案例:单图过审判定、两张候选按 1–10 打分后比较、用自定义选项分类、从一批图里挑最匹配的。需要哪个案例直接复制那一段,每条链路都是接好可直接跑的。
简介
Jev answers a yes/no, scored, multiple-choice or pick-from-a-batch question about text, images or both, and returns a value the graph can branch on. Four complete cases share one workflow: a publish gate on a single image, two candidates scored 1-10 against the same question and compared, free-form classification into your own option list, and picking the best image out of a batch. Copy the case you need — each is wired end to end.
Graph: BatchImagesNode, ComfyMathExpression, ComfySwitchNode, ImageFromBatch, LoadImage, MarkdownNote, PreviewAny, PreviewImage, PrimitiveStringMultiline, TypeSafeJevChoice, TypeSafeJevPickImage, TypeSafeJevScore, TypeSafeJevYesNo. Output: image.
你需要提供
- 正在读取工作流
在 ComfyUI 中运行。 此工作流无法在本页面运行。请下载后在 ComfyUI 中打开。
下载工作流此工作流暂无示例输出。
查看工作流内部
节点图的只读预览。在 Comfy 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({
"2": {
"class_type": "LoadImage",
"inputs": {
"image": "girl_red_umbrella_station.png"
},
"_meta": {
"title": "Load Image"
}
},
"3": {
"class_type": "TypeSafeJevYesNo",
"inputs": {
"images.image_1": [
"2",
0
],
"model": "jev-1.14.0",
"question": "Is there a person in the image?",
"threshold": 0.5
},
"_meta": {
"title": "TypeSafe Jev (Yes/No)"
}
},
"4": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"3",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"5": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"3",
1
]
},
"_meta": {
"title": "Preview as Text"
}
},
"6": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"3",
2
]
},
"_meta": {
"title": "Preview as Text"
}
},
"8": {
"class_type": "LoadImage",
"inputs": {
"image": "girl_red_umbrella_station.png"
},
"_meta": {
"title": "Load Image"
}
},
"9": {
"class_type": "LoadImage",
"inputs": {
"image": "cyclist_in_rain_night_street.png"
},
"_meta": {
"title": "Load Image"
}
},
"10": {
"class_type": "TypeSafeJevScore",
"inputs": {
"images.image_1": [
"8",
0
],
"model": "jev-1.14.0",
"question": "Rate the technical quality of the image from 1 (worst) to 10 (best).",
"threshold": 5
},
"_meta": {
"title": "TypeSafe Jev (Score)"
}
},
"11": {
"class_type": "TypeSafeJevScore",
"inputs": {
"images.image_1": [
"9",
0
],
"model": "jev-1.14.0",
"question": "Rate the technical quality of the image from 1 (worst) to 10 (best).",
"threshold": 5
},
"_meta": {
"title": "TypeSafe Jev (Score)"
}
},
"12": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a > b",
"values.a": [
"10",
1
],
"values.b": [
"11",
1
]
},
"_meta": {
"title": "Math Expression"
}
},
"13": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"9",
0
],
"on_true": [
"8",
0
],
"switch": [
"12",
2
]
},
"_meta": {
"title": "If/Else Switch"
}
},
"14": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"13",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"16": {
"class_type": "LoadImage",
"inputs": {
"image": "ramen_bowl_top_view.png"
},
"_meta": {
"title": "Load Image"
}
},
"17": {
"class_type": "TypeSafeJevChoice",
"inputs": {
"images.image_1": [
"16",
0
],
"model": "jev-1.14.0",
"options": "photo\nillustration\n3d render\nanime\nsketch\nother",
"question": "What style is the image?"
},
"_meta": {
"title": "TypeSafe Jev (Choice)"
}
},
"18": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"17",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"19": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"17",
1
]
},
"_meta": {
"title": "Preview as Text"
}
},
"20": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"17",
2
]
},
"_meta": {
"title": "Preview as Text"
}
},
"22": {
"class_type": "LoadImage",
"inputs": {
"image": "ramen_bowl_top_view.png"
},
"_meta": {
"title": "Load Image"
}
},
"23": {
"class_type": "LoadImage",
"inputs": {
"image": "cyclist_in_rain_night_street.png"
},
"_meta": {
"title": "Load Image"
}
},
"24": {
"class_type": "BatchImagesNode",
"inputs": {
"images.image0": [
"22",
0
],
"images.image1": [
"23",
0
]
},
"_meta": {
"title": "Batch Images"
}
},
"25": {
"class_type": "TypeSafeJevPickImage",
"inputs": {
"images": [
"24",
0
],
"model": "jev-1.14.0",
"question": "Which image best matches the prompt in text? If there is no text, which image has the best quality?",
"text": [
"31",
0
]
},
"_meta": {
"title": "TypeSafe Jev (Pick Image)"
}
},
"29": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"32",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"31": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "a bowl of ramen with a soft-boiled egg, shot from above"
},
"_meta": {
"title": "Text (Multiline)"
}
},
"32": {
"class_type": "ImageFromBatch",
"inputs": {
"batch_index": [
"25",
0
],
"image": [
"24",
0
],
"length": 1
},
"_meta": {
"title": "Get Image from Batch"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)