Flux.1 是由 Stable Diffusion创始团队开发的一个全新的开源 AI 图像生成模型,于 2024 年 8 月 1 日发布。它能够生成极其逼真的人类图像和视频,其表现甚至超越了许多现有的图像生成模型,如 Midjourney 和 DALL-E。Flux.1 特别擅长处理人类特征的细节,如皮肤、头发和皱纹,解决了许多 AI 模型在生成这些细节时遇到的问题
。
Flux.1 有三个版本:
此外,Flux.1 还被一些平台如 NightCafe 和 Poe 整合,使得用户可以更方便地使用它来生成图像。
https://blackforestlabs.ai/#get-flux
https://github.com/black-forest-labs/flux
https://huggingface.co/black-forest-labs/FLUX.1-schnell
https://replicate.com/black-forest-labs/flux-pro
1、安装Python 环境,参考前面Stable-Diffusion 3
的环境搭建文档:Stable-Diffusion 3 正式开源!附详细的安装教程。
2、创建虚拟环境
conda create -n flux python=3.10.6
# 激活虚拟环境
conda activate flux
3、下载源码
git clone https://github.com/black-forest-labs/flux
cd flux
# 安装依赖
pip install -e '.[all]'
# 运行案例,将自动从 HuggingFace 下载指定到模型
python -m flux --name 'flux-schnell' --loop
如果已经手动下载了模型,则可以通过环境变量指定下载路径:
export FLUX_SCHNELL=<path_to_flux_schnell_sft_file>
export FLUX_DEV=<path_to_flux_dev_sft_file>
export AE=<path_to_ae_sft_file>
步骤:
Pro 文档:https://docs.bfl.ml/api/
。
export BFL_API_KEY="<your key>"
import os
import requests
request = requests.post(
'https://api.bfl.ml/v1/image',
headers={
'accept': 'application/json',
'x-key': os.environ.get("BFL_API_KEY"),
'Content-Type': 'application/json',
},
json={
'prompt': 'A cat on its back legs running like a human is holding a big silver fish with its arms. The cat is running away from the shop owner and has a panicked look on his face. The scene is situated in a crowded market.',
'width': 1024,
'height': 1024,
},
).json()
print(request)
request_id = request["id"]
Flux.1 是一款免费开源的模型,性能可与Midjourney V6媲美,用户可通过ComfyUI调用Flux.1。
本文我将详细介绍其使用流程,即使你是新手小白,只要紧跟我的步骤,相信你也能使用上这款非常强悍的文生图模型。
目前 ComfyUI 已支持此模型,更新到最新版即可使用。
1、ComfyUI 的安装和配置参考前面Stable-Diffusion 3
的环境搭建文档:Stable-Diffusion 3 正式开源!附详细的安装教程。
2、下载 Flux 模型
https://huggingface.co/black-forest-labs/FLUX.1-dev/tree/main
。https://huggingface.co/Kijai/flux-fp8/blob/main/flux1-dev-fp8.safetensors
。https://huggingface.co/black-forest-labs/FLUX.1-schnell/blob/main/flux1-schnell.safetensors
。https://huggingface.co/Kijai/flux-fp8/blob/main/flux1-schnell-fp8.safetensors
。“不管下载上面的哪个模型,都存放在:ComfyUI/models/unet/ 目录下!
3、下载 CLIP 模型
需下载 t5xxl_fp16.safetensors 或 t5xxl_fp8_e4m3fn.safetensors (建议选择fp8 版本,如果你显存超过 32G 可选择 fp16 版本)。
下载地址:https://huggingface.co/comfyanonymous/flux_text_encoders/tree/main
。
“clip_l.safetensors 保存到 ComfyUI/models/clip/ 目录中
4、下载 VAE 模型
下载地址:https://huggingface.co/black-forest-labs/FLUX.1-schnell/blob/main/ae.safetensors
。
“保存到 ComfyUI/models/vae/ 目录
flux_schnell_example 示例获取:https://comfyanonymous.github.io/ComfyUI_examples/flux/
。