HiDream O1 Full: Image generation
Input a text prompt and optionally upload reference images. Generate a high-resolution image up to 2048x2048 with text-to-image, editing, or subject-driven…
About
Input a text prompt and optionally upload reference images. Generate a high-resolution image up to 2048x2048 with text-to-image, editing, or subject-driven…
What you provide
- Reading the workflow
Runs in ComfyUI. This workflow can't run on this page. Download it and open it in ComfyUI.
Download WorkflowNo sample outputs for this workflow yet.
Inside the workflow
A read-only preview of the node graph. Open it in Comfy Cloud or download it to edit the nodes.
Loading the graph
Open full-size workflow previewFiles in this workflow
- Comfy Cloud
- Yes
- Output
- Image
- Author
- Author unavailable
Requires custom nodes
- Reading the workflow
Use this workflow from code
Generated from the workflow graph and inputs when possible; stored examples are shown otherwise. Review credentials and endpoints before running code, which may incur charges.
What you need
- Runs on
- Comfy Cloud
- Key
- COMFY_API_KEY
Needs a paid Cloud plan and credits.
# 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({
"6": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "hidream_o1_image_bf16.safetensors"
},
"_meta": {
"title": "Load Checkpoint"
}
},
"104": {
"class_type": "HiDreamO1ReferenceImages",
"inputs": {
"images.image_1": [
"213",
0
],
"negative": [
"188",
0
],
"positive": [
"110",
0
]
},
"_meta": {
"title": "HiDream-O1 Reference Images"
}
},
"105": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"108",
0
],
"vae": [
"6",
2
]
},
"_meta": {
"title": "VAE Decode"
}
},
"108": {
"class_type": "SamplerCustom",
"inputs": {
"add_noise": True,
"cfg": 5,
"latent_image": [
"155",
0
],
"model": [
"232",
0
],
"negative": [
"153",
0
],
"noise_seed": 493576922569549,
"positive": [
"152",
0
],
"sampler": [
"230",
0
],
"sigmas": [
"112",
0
]
},
"_meta": {
"title": "SamplerCustom"
}
},
"110": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"6",
1
],
"text": [
"221",
0
]
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"112": {
"class_type": "BasicScheduler",
"inputs": {
"denoise": 1,
"model": [
"124",
0
],
"scheduler": "normal",
"steps": 40
},
"_meta": {
"title": "BasicScheduler"
}
},
"124": {
"class_type": "ModelNoiseScale",
"inputs": {
"model": [
"6",
0
],
"noise_scale": 8
},
"_meta": {
"title": "ModelNoiseScale"
}
},
"152": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"110",
0
],
"on_true": [
"104",
0
],
"switch": [
"154",
0
]
},
"_meta": {
"title": "If/Else Switch"
}
},
"153": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"188",
0
],
"on_true": [
"104",
1
],
"switch": [
"154",
0
]
},
"_meta": {
"title": "If/Else Switch"
}
},
"154": {
"class_type": "PrimitiveBoolean",
"inputs": {
"value": False
},
"_meta": {
"title": "Switch to Image Edit"
}
},
"155": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"156",
0
],
"on_true": [
"172",
0
],
"switch": [
"154",
0
]
},
"_meta": {
"title": "If/Else Switch"
}
},
"156": {
"class_type": "EmptyHiDreamO1LatentImage",
"inputs": {
"batch_size": 1,
"height": 2048,
"width": 2048
},
"_meta": {
"title": "Empty HiDream-O1 Latent Image"
}
},
"157": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"213",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"171": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "Graceful female skincare shot, light nude makeup, holding essence bottle, warm ivory backdrop, soft diffused light"
},
"_meta": {
"title": "User Prompt"
}
},
"172": {
"class_type": "EmptyHiDreamO1LatentImage",
"inputs": {
"batch_size": 1,
"height": [
"219",
1
],
"width": [
"218",
1
]
},
"_meta": {
"title": "Empty HiDream-O1 Latent Image"
}
},
"176": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"171",
0
],
"on_true": [
"175:198",
0
],
"switch": [
"177",
0
]
},
"_meta": {
"title": "If/Else Switch"
}
},
"177": {
"class_type": "PrimitiveBoolean",
"inputs": {
"value": False
},
"_meta": {
"title": "Enable Prompt Refine?"
}
},
"188": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"6",
1
],
"text": ""
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"213": {
"class_type": "LoadImage",
"inputs": {
"image": "noir_portrait.png"
},
"_meta": {
"title": "Load Image"
}
},
"218": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "floor(a/32)*32",
"values.a": [
"157",
0
]
},
"_meta": {
"title": "Math Expression"
}
},
"219": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "floor(a/32)*32",
"values.a": [
"157",
1
]
},
"_meta": {
"title": "Math Expression"
}
},
"221": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"176",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"227": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "hidream_o1",
"images": [
"105",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"230": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "dpmpp_2m_sde_gpu"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"232": {
"class_type": "HiDreamO1PatchSeamSmoothing",
"inputs": {
"blend": "median",
"end_percent": 1,
"model": [
"124",
0
],
"passes": "ramp_2_4",
"pattern": "single_shift",
"start_percent": 0.8,
"strength": 1
},
"_meta": {
"title": "HiDream-O1 Patch Seam Smoothing"
}
},
"175:164": {
"class_type": "TextGenerateV2",
"inputs": {
"clip": [
"175:167",
0
],
"images.image1": [
"213",
0
],
"max_length": 2048,
"mtp": "auto",
"prompt": [
"175:166",
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": False
},
"_meta": {
"title": "Generate Text"
}
},
"175:165": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "<|turn>system\n你是专业的AI图像生成Prompt工程师的Prompt Engineering Engine,也是一名拥有百科知识和视觉导演能力的创意总监.你的任务是分析用户的原始图像需求,推理出隐含知识和最佳视觉方案,并改写成一个**明确,详细,可直接用于图像生成的英文prompt**.\n\n## 核心目标\n\n图像生成模型只能执行直接的视觉描述,不能自行补全背景知识,逻辑关系或文字内容.因此,你必须提前完成知识解析,空间规划和视觉导演,把结果显式写入prompt中.\n\n使用 SCALIST 框架扩写每个画面:\n- **Subject**: 主体的身份,外观,颜色,材质,纹理,动作,表情,服饰.\n- **Composition**: 镜头景别,视角,主体位置,前景/中景/背景层次,留白和视觉焦点.\n- **Action**: 主体正在做什么,动作方向,姿态,互动关系.\n- **Location**: 场景地点,室内/室外,时代,天气,时间段,环境细节.\n- **Image style**: photorealistic, cinematic, oil painting, watercolor, anime, 3D render 等,并匹配合适的光线和色彩氛围.\n- **Specs**: 摄影/渲染参数,如 85mm lens, low-angle shot, shallow depth of field, soft diffused light, dramatic backlighting, matte texture, sharp focus.\n- **Text rendering**: 如果用户要求文字,必须把准确文字放在英文双引号中,并说明字体风格,颜色,大小,材质和精确位置.\n\n1. **知识解析与显式化**: 凡是诗词,歌词,名言,公式,历史人物,科学概念,地标,名画,文化符号,历史事件,UI布局或现实世界对象,都要先解析出具体答案和可见特征,再写入prompt.不要只写 \"Mona Lisa\",\"Dunkirk evacuation\",\"freedom\" 这类需要模型自行理解的词.\n2. **空间与逻辑锚定**: 把模糊关系改写为明确布局,例如 top left corner, centered in the foreground, slightly behind the main subject, background out of focus, text aligned along the bottom edge.不要使用\"旁边\"\"一些\"\"好看\"等含糊表达.\n3. **文字排版精度**: 中文,英文,公式,多语言文本都必须逐字保留在引号中,例如 \"床前明月光,疑是地上霜.举头望明月,低头思故乡.\" 或 \"E = mc²\";同时指定字体(calligraphy, serif, sans-serif, handwritten),颜色,材质和位置.\n4. **真实世界落地**: 如果用户要求事实准确的内容,例如历史文物,天气现象,人物肖像,建筑,仪表盘或应用界面,要使用你的内部知识补全准确视觉细节.\n5. **抽象概念具象化**: 把\"自由,孤独,未来感,治愈\"等抽象词转成可见场景,符号和氛围,例如飞鸟,断裂锁链,辽阔天空,冷色霓虹,柔和晨光等.\n\n## 示例与学习\n\n- 用户说\"李白的静夜思写在墙上\",prompt 应写出完整中文诗句,并指定它以优雅中国书法写在古旧石墙的哪个位置.\n- 用户说\"三大力学的奠基人\"或\"爱因斯坦写质能方程\",prompt 应解析出 Isaac Newton 或 Albert Einstein,并描述人物外貌,时代服饰,黑板,公式 \"E = mc²\" 等可见内容.\n- 用户说\"蒙娜丽莎\"\"比萨斜塔\"\"福字\"\"敦刻尔克大撤退\",prompt 应描述对应画面特征: 神秘微笑与交叠双手,倾斜白色大理石钟楼与拱廊,红底金色/黑色书法 \"福\",1940年海滩上等待撤离的士兵和海面船只.\n\n## 输出prompt要求\n\n- prompt 必须是一个英文的,连贯自然的单段落,像 Creative Director's Brief,而不是关键词堆砌或 tag soup.\n- 长度通常为 80-220 词;简单需求可以更短,复杂画面可以更长.\n- 最重要的主体和画面意图放在开头,然后自然展开构图,动作,地点,风格,技术参数和文字渲染.\n- 使用完整句子,丰富但准确的形容词,摄影/绘画/设计术语.\n- 不要包含任何需要图像模型继续推理才能理解的表达.\n- prompt 必须自包含,仅凭prompt本身就能准确生成图片.\n\n## 执行步骤\n\n1. **Analyze**: 识别核心主体,用户意图,文字要求,参考限制和需要解析的隐含知识.\n2. **Reason**: 选择最适宜画面的光线,镜头,角度,纹理,风格,空间布局和事实细节.\n3. **Rewrite**: 输出最终增强后的英文单段落prompt.\n\n只输出JSON,不加任何其他文字:\n{\"prompt\": \"英文单段落prompt\", \"reasoning\": \"你的推理和知识解析过程(需要用用户输入的提示词语言来生成)\", \"resolved_knowledge\": \"你解析了哪些隐含知识(根据输入用户语言简述,如果没有隐含知识用对应语言写'无')\"} \n<|turn|>"
},
"_meta": {
"title": "REWRITE_SYSTEM_PROMPT"
}
},
"175:166": {
"class_type": "StringConcatenate",
"inputs": {
"delimiter": "",
"string_a": [
"175:165",
0
],
"string_b": [
"175:170",
0
]
},
"_meta": {
"title": "Concatenate Text"
}
},
"175:167": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "gemma4_e4b_it_fp8_scaled.safetensors",
"device": "default",
"type": "stable_diffusion"
},
"_meta": {
"title": "Load CLIP"
}
},
"175:170": {
"class_type": "StringReplace",
"inputs": {
"find": "{user_prompt}",
"replace": [
"171",
0
],
"string": "<|turn>user\n{user_prompt}<|turn|>\n<|turn>model\n"
},
"_meta": {
"title": "Replace Text"
}
},
"175:198": {
"class_type": "JsonExtractString",
"inputs": {
"json_string": [
"175:202",
0
],
"key": "prompt"
},
"_meta": {
"title": "Extract Text from JSON"
}
},
"175:201": {
"class_type": "RegexReplace",
"inputs": {
"case_insensitive": False,
"count": 1,
"dotall": False,
"multiline": False,
"regex_pattern": "^```(?:json)?\\s*\\n?",
"replace": "",
"string": [
"175:164",
0
]
},
"_meta": {
"title": "Replace Text (Regex)"
}
},
"175:202": {
"class_type": "RegexReplace",
"inputs": {
"case_insensitive": False,
"count": 1,
"dotall": False,
"multiline": False,
"regex_pattern": "\\n?```\\s*$",
"replace": "",
"string": [
"175:201",
0
]
},
"_meta": {
"title": "Replace Text (Regex)"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)