1.背景 最近,由前Stability AI员工创立的黑森林实验室推出了开源图像生成模型Flux.1,受到了广泛关注,迅速在网络上走红。Flux.1是一款免费开源的模型,其性能可与Midjourney V6相媲美。用户可以通过Comfyui来调用Flux.1。本文将主要介绍如何安装和调试Flux模型。 详情可见网站页面:https://blackforestlabs.ai/ 试用网页:http://hugginface.co/black-forest-labs Flux 模型总共有3个,分别是:Flux Pro、Flux Dev、Flux Schnell,下面是其性能的对照图
[pro] 是最顶级的模型,但是只能通过 API 调用;
[dev] 是由[pro]提炼,开源但非商用,质量和效果与[pro]类似;
[schnell] 是经过蒸馏的 4 步模型,速度比 [dev] 快 10 倍,Apache 2 开源许可。
2. 安装 目前 ComfyUI 已支持此模型,更新到最新版即可使用。
2.1 下载最新版 ComfyUI 1 git clone https://github.com/comfyanonymous/ComfyUI.git
2.2 设置中文语言和插件库 1 2 3 4 5 6 cd ComfyUI/custom_nodesgit clone https://github.com/AIGODLIKE/AIGODLIKE-ComfyUI-Translation.git git clone https://github.com/ltdrdata/ComfyUI-Manager.git
2.3 下载flux模型 FLUX 模型有四个可选,FLUX.1 [dev] 、FLUX.1 [dev] fp8、FLUX.1 [schnell]、FLUX.1 [schnell] fp8⚠️ 注意根据自身显卡配置选择1个模型,以下模型都有huggingface和modelsope的下载地址,一个是国外的社区,一个是国内的社区,模型都是一样的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 cd ComfyUI/models/unet/wget https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/flux1-dev.safetensors wget https://modelscope.cn/models/AI-ModelScope/FLUX.1-dev/resolve/master/flux1-dev.safetensors wget https://huggingface.co/Kijai/flux-fp8/resolve/main/flux1-dev-fp8.safetensors wget https://modelscope.cn/models/livehouse/flux1-dev-fp8/resolve/master/flux1-dev-fp8.safetensors wget https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/flux1-schnell.safetensors wget https://modelscope.cn/models/AI-ModelScope/FLUX.1-schnell/resolve/master/flux1-schnell.safetensors
2.4 下载clip模型 国外huggingface: https://huggingface.co/comfyanonymous/flux_text_encoders/tree/main 国内用魔塔社区: https://modelscope.cn/models/AI-ModelScope/flux_text_encoders/files 需下载 t5xxl_fp16.safetensors 或 t5xxl_fp8_e4m3fn.safetensors (建议选择fp8 版本,如果你显存超过 32G 可选择 fp16 版本),用于文本对齐 需下载 clip_l.safetensors,用于文本对齐
1 2 3 4 5 6 7 8 9 10 11 12 13 14 cd ComfyUI/models/clipwget https://huggingface.co/comfyanonymous/flux_text_encoders/blob/main/clip_l.safetensors wget https://modelscope.cn/models/AI-ModelScope/flux_text_encoders/resolve/master/clip_l.safetensors wget https://huggingface.co/comfyanonymous/flux_text_encoders/blob/main/t5xxl_fp16.safetensors wget https://modelscope.cn/models/AI-ModelScope/flux_text_encoders/resolve/master/t5xxl_fp16.safetensors wget https://huggingface.co/comfyanonymous/flux_text_encoders/blob/main/t5xxl_fp8_e4m3fn.safetensors wget https://modelscope.cn/models/AI-ModelScope/flux_text_encoders/resolve/master/t5xxl_fp8_e4m3fn.safetensors
2.5 下载VAE模型 用于视频解码
1 2 3 4 5 6 cd ComfyUI/models/vae wget https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/ae.safetensors wget https://modelscope.cn/models/AI-ModelScope/FLUX.1-dev/resolve/master/ae.safetensors
2.6 程序启动 1 2 3 cd ComfyUIpython3 main.py --listen XXX.XXX.XXX.XXX
3. 使用 3.1 浏览器初始化 打开浏览器,在网页中输入自己的IP:8188, 比如我的IP是10.229.41.48,则输入:
1 http://10.229.41.48:8188
选择设置-AGL,改成中文,如果没有中文选项,重新在第二步看一下是否正确下载了语言包 下载提示词的示例图片,flux_schnell_example示例获取:
1 https://comfyanonymous.github.io/ComfyUI_examples/flux
比如我用的是flux dev,则下载对应的flux图片 并将这张图保存,直接拖到网页中即可,最终的界面如下,并开始操作: 1)在clip文本编辑器中编写要画的图,比如我编写的是:a beautiful gir 2)选择刚刚下载unet文生图模型,比如我下载的是flux1-dev.safetensors 3) 选择双clip加载器,主要用于将clip进行文本向量化,我下载的是t5xxl_fp8_e4m3fn.safetensors和clip_l.safetensors 4) 选择添加提示词队列,根据设备显卡不同,等待即可在图像区进行图像生成
3.2 提示词参考 1 2 3 一位美丽的亚洲女性手中握着花朵,韩模风格,真实照片风格,全身照。 pretty Asian woman was holding the flowers in her hands, Korean Model, real photo style, full body shot.
1 2 3 一个女孩,长发,模特,白色背景,白色衬衫,卡其色七分裤,卡其色乐福鞋,坐在凳子上,懒散的姿势,稍微歪着头,微笑,亚洲美女,宽松的衣服,双手放在身体前面,脚稍微抬起,半身照,佳能R5相机风格,背景模糊,室内,自然光,一些阳光洒在脸上,9:16。 One girl, long hair, model, white background, white shirt, khaki Capri pants, khaki loafers, sitting on a stool, lazy pose, slightly tilting head, smiling, Asian beauty, loose-fitting clothes, hands placed in front of body, slightly raised foot, half-body shot, Canon R5 camera style, blurred background, indoor, natural light, some sunlight shining on the face,9:16.
1 2 埃隆·马斯克,成功人士,亚洲人,快乐,纯色背景,C4D 渲染,皮克斯风格,9:16。 Elon Musk, successful person, Asian, happy,solid color background, C4D rendering, Pixar,9:16.
1 2 3 4 5 6 7 8 要生成一幅以H.P. 洛夫克拉夫特风格的图像,您可以考虑加入诸如宇宙恐怖、古老神秘生物和阴森景观等元素。以下是您可以使用的生成此类图像的提示: “创建一个黑暗而富有氛围的场景,展现一片广阔的星空,星空中布满奇异的星座。在前景中,描绘一座古老的、崩溃的石庙,被扭曲的藤蔓和苔藓覆盖。月光投下的阴影揭示出一些令人不安的生物在附近潜伏。整体氛围应唤起一种恐惧和未知的感觉,令人想起洛夫克拉夫特的宇宙恐怖主题 To generate an image in the style of H.P. Lovecraft, you might want to include elements such as cosmic horror, ancient mythical beings, and eerie landscapes. Here’s a prompt you could use for generating such an image: "Create a dark and atmospheric scene featuring a vast, starry sky filled with strange constellations. In the foreground, depict an ancient, crumbling stone temple overgrown with twisted vines and moss. Shadows cast by the moonlight reveal hints of unsettling creatures lurking nearby. The overall mood should evoke a sense of dread and the unknown, reminiscent of Lovecraftian themes of cosmic horror." !
1 2 3 在深邃的太空中,背景有小星球,一架宇宙飞船在画面正中心 In the depths of space, with small planets in the background, a spacecraft is at the center of the scene.