摘要: 介绍如何在ComfyUI中使用JoyCaption2实现提示词反推:将参考图片转换为SD/MJ风格提示词,再用提示词生成相似风格图像。
今天介绍小白开始AI绘画,都要面临的一个问题,看到了很好看的图片,却不清楚如何描述,如何制作类似的图片。花了大量时间反复调试、修改提示词,生成的图片总与预想的画面不同,
这里就需要一个工具,提示词反推。
它的作用就是根据图片,反推出图片的内容提示词。也可以直接生成 Stable Diffusion 或 MidJourney 的提示词。甚至用于图像打标签,以更好的为训练模型做准备。
提示词反推
,核心是基于图像理解,描述画面内容。并生成不同风格的提示词。
下面是几种风格的提示词反推效果:
原图:
JOY Caption提示词反推工作流详解
官方仓库:
https://
github.com/fpgaminer/jo
ycaption
提示词反推有很多种实现,今天我们介绍的这个是基于joyCaption实现的。
整个工作流也比较简单。一种只需要4个几点。
图像加载
模型加载
Joy Caption Two推示词反推
文本展示
图像加载节点
我们使用了“加载并缩放图像”。避免有的图片过大,导致反推太慢。
宽高设置:1024 \
1024。
kee_proportion:true,代表保持图像缩放比例。
Joy Caption Two节点
caption_type:选择提示词风格。
caption_length:可以调整提示词的长度
提示词效果
下面是根据反推出的SD提示词,出的效果图。
模型使用我们前面用到的dreamshaper 和 promemix。如果不会,可以这篇文章。去掉lora节点就可以了。
https://
mp.weixin.qq.com/s/FMDp
8S39apU5no1Vrh3lIA
在线工作流获取
JOY Caption的使用,需要机器配置较高。我使用的是liblib在线工作流搭建的。
可以直接发布成应用,也可以分享工作流。
地址:
https://www.
liblib.art/modelinfo/f4
7150c2b5314c44b14cc5dcf09f9227?mine=1&from=personal_page&versionUuid=61b685c396b541a7b7596a1954f0811d
工作流下载
工作流JSON文件我放在网盘了,需要的可以公众号后台回复【250915】获取。
| 需求 | 输入 | 实现 | 输出 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| # | 目的 | 作用 | 实质 | 形式 | 类型 | 值 | 来源 | 外部工具 | 动作 | 指令 | 类型 | 值 | 去处 |
| s1 | 用 ComfyUI 调整 参考图,缩放至统一规格得 缩放图像 | 预处理 | 图像 | 内容类型/素材/化学变化/参考图 | <一张花田草地+音符场景的彩色数字插画(封面参考图)> | ← 工序输入 | ComfyUI | 修改/变/调整 | 宽度1024、高度1024、保持原始比例(keep_proportion=true) | 缩放图像 | s1o1 <封面花田草地音符彩色数字插画,已缩放至1024x1024保持原始比例> | → s3 | |
| s2 | 用 ComfyUI 调取 模型配置,加载 模型管道 备用 | 预准备 | 模型配置 | model: unsloth/Meta-Llama-3.1-8B-Instruct | ← 工序输入 | ComfyUI | 获取/查询/调取 | 模型管道 | s2o1 <JoyTwoPipeline已加载实例,基于unsloth/Meta-Llama-3.1-8B-Instruct> | → s3 | |||
| s3 | 将 缩放图像 送入 ComfyUI 反推,得到 提示词 文本 | 主体生成 | 图像 | 缩放图像 | <封面花田草地音符彩色数字插画,已缩放至1024x1024保持原始比例> | ← s1o1 | ComfyUI | 提取/化学提取/反推 | 程序控制类型/指令/提示词 | s3o1 digital art, pastel colors, blue sky, fluffy clouds, musical notes, floating notes, white clouds, yellow clouds, green grass, colorful flowers, dandelions, white dandelions, pink flowers, orange flowers, yellow flowers, blue sky gradient, soft lighting, whimsical style, dreamy atmosphere, nature, field, meadow, spring, summer, light breeze, delicate petals, gentle wind, musical theme, peaceful, serene, background music notes, nature elements, bright colors, fantasy, surreal, landscape, ethereal, whimsical, tranquil scene | → s4 | ||
| 模型管道 | <JoyTwoPipeline已加载实例,基于unsloth/Meta-Llama-3.1-8B-Instruct> | ← s2o1 | |||||||||||
| 程序控制类型/参数/生成参数 | caption_type: MidJourney caption_length: long low_vram: false | ← 工序输入 | |||||||||||
| s4 | 以 提示词 为输入,用 ComfyUI 元素生成 得到 成品图 | 主体生成 | 图像 | 程序控制类型/指令/提示词 | digital art, pastel colors, blue sky, fluffy clouds, musical notes, floating notes, white clouds, yellow clouds, green grass, colorful flowers, dandelions, white dandelions, pink flowers, orange flowers, yellow flowers, blue sky gradient, soft lighting, whimsical style, dreamy atmosphere, nature, field, meadow, spring, summer, light breeze, delicate petals, gentle wind, musical theme, peaceful, serene, background music notes, nature elements, bright colors, fantasy, surreal, landscape, ethereal, whimsical, tranquil scene | ← s3o1 | ComfyUI | 生成/元素生成 | 去掉lora节点就可以了 | 内容类型/成品/成品图 | s4o1 <使用反推提示词生成的草地云天场景图,dreamshaper/primemix模型效果> | → 返回 成品图 | |
| SD模型 | 模型使用我们前面用到的dreamshaper 和 promemix。如果不会,可以这篇文章。去掉lora节点就可以了。 | ← 工序输入 | |||||||||||