Flux 是什么?
Flux 是由 Black Forest Labs 开发的开源 AI 图像生成模型,以其出色的细节表现和 prompt 遵循能力著称。
Flux 优势
- 完全开源免费
- 对英文 prompt 理解精准
- 细节表现优秀
- 可本地部署
- 商业可用
快速开始
方法一:在线平台
Replicate(推荐新手)
- 访问 replicate.com/flux
- 注册账号
- 输入 prompt,点击生成
Fal.ai
- 访问 fal.ai/models/fal-ai/flux
- 同样简单易用
方法二:API 调用
import replicate
# 使用 Flux 模型
output = replicate.run(
"black-forest-labs/flux-schnell",
input={
"prompt": "a cute cat wearing a hat, soft lighting, photorealistic",
"num_inference_steps": 4, # Schnell 模型只需 4 步
"guidance_scale": 0,
}
)
print(output[0]) # 输出图片 URL方法三:本地部署
使用 ComfyUI
- 下载 ComfyUI
- 下载 Flux 工作流
- 下载模型文件(约 10GB)
- 加载工作流即可使用
使用秋叶启动器
- 下载「秋叶整合包」
- 一键启动
- 下载 Flux 模型
- 开始使用
Flux 模型对比
| 模型 | 特点 | 生成速度 | 适用场景 | |------|------|----------|----------| | Flux.1 Dev | 质量最高 | 慢 | 专业创作 | | Flux.1 Schnell | 速度最快 | 快(4步) | 日常使用 | | Flux.1 Pro | 综合最强 | 中 | 商业应用 |
# Dev 模型 - 高质量
/replicate run black-forest-labs/flux-dev \
--prompt "your prompt"
# Schnell 模型 - 快速生成
/replicate run black-forest-labs/flux-schnell \
--prompt "your prompt"
基础使用技巧
Prompt 写法
Flux 对英文 prompt 的理解非常好,建议直接用英文描述:
基础版:
a cat sitting on a couch
进阶版:
A fluffy orange tabby cat lounging on a modern gray velvet couch, soft afternoon sunlight streaming through sheer curtains, minimalist Scandinavian living room, cozy atmosphere, shot on Sony A7R IV, 85mm lens, f/1.8 aperture, 8K resolution
参数设置
| 参数 | 说明 | 建议值 |
|------|------|--------|
| num_inference_steps | 推理步数 | Dev: 20-30, Schnell: 1-4 |
| guidance_scale | 提示词引导强度 | 3.5-7 |
| prompt | 图像描述 | 英文最佳 |
| aspect_ratio | 宽高比 | 1:1, 16:9, 9:16 |
负向提示词
# Replicate API 使用负向提示
output = replicate.run(
"black-forest-labs/flux-dev",
input={
"prompt": "a beautiful landscape",
"negative_prompt": "blurry, low quality, distorted, watermark"
}
)实用场景
1. 产品图生成
A minimalist product photography of [产品名], white background, soft studio lighting, centered composition, high-end luxury feel, shot on Phase One camera, 100 megapixels
2. 人物肖像
Professional headshot portrait of a [种族/性别], neutral expression, studio lighting, shallow depth of field, captured with Canon EOS R5, 85mm lens, natural skin tones, clean background
3. 场景概念图
A cozy coffee shop interior, warm amber lighting, exposed brick walls, wooden furniture, steam rising from cups, rain visible through large windows, inviting atmosphere, cinematic composition
4. 动漫/插画风格
Anime illustration style, a young girl with long flowing hair standing in a cherry blossom garden, soft pink petals in the wind, detailed background, Studio Ghibli inspired, vibrant colors
ComfyUI 工作流
基础 Flux 工作流
Load Checkpoint (flux model)
↓
CLIP Text Encode (positive prompt)
↓
CLIP Text Encode (negative prompt)
↓
Empty Latent Image (设置尺寸和步数)
↓
KSampler (采样器)
↓
VAE Decode
↓
Preview Image
局部重绘工作流
Load Checkpoint
↓
Load Image (上传原图)
↓
CLIP Text Encode
↓
VAE Encode (将图片编码)
↓
Inpaint (局部重绘)
↓
KSampler
↓
VAE Decode
↓
Preview Image
Flux 与其他工具对比
| 方面 | Flux | Midjourney | DALL-E 3 | |------|------|------------|-----------| | 价格 | 免费 | $10/月起 | ChatGPT Plus | | 细节 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ | | Prompt 遵循 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | | 速度 | ⭐⭐⭐(本地) | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | | 艺术风格 | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | | 中文支持 | ⭐⭐ | ⭐⭐ | ⭐⭐⭐⭐ |
选择建议
Flux 适合追求高质量细节、愿意使用英文提示词、想要免费使用的用户。
常见问题
Q:生成的图片模糊怎么办?
A:
- 增加
num_inference_steps(Dev 模型建议 25-30) - 使用更详细的 prompt
- 检查模型文件是否完整下载
Q:提示词没有被遵循?
A:
- 简化提示词,一次描述一个主体
- 使用更具体的词汇而非抽象描述
- 尝试不同的权重设置
Q:本地部署需要什么配置?
A:
- 最低:12GB 显存(RTX 3060)
- 推荐:24GB 显存(RTX 4090)
- 硬盘:至少 20GB 空间
Q:如何生成中文?
A:Flux 对中文支持较差,建议:
- 用英文描述
- 或者生成后再用其他工具添加中文
注意
AI 生成图片的版权归属较为复杂,商业使用前请确认当地法规和平台政策。
进阶技巧
1. 权重调整
使用 () 增强权重,[] 减弱权重
(cat):1.2 增强猫
[cat]:0.8 减弱猫
2. 风格融合
在 prompt 中组合不同风格
anime + photorealistic style, a futuristic city
3. 参考图片(Img2Img)
# 使用参考图
output = replicate.run(
"black-forest-labs/flux-dev",
input={
"prompt": "same scene, but it's nighttime with neon lights",
"image": "https://example.com/reference.jpg",
"strength": 0.6 # 变化强度 0-1
}
)总结
Flux 是一个强大且免费的 AI 图像生成工具:
- 适合:想免费使用、追求高质量、有英文基础的用户
- 不适合:需要中文支持、追求极致速度的入门用户
- 推荐用法:本地部署 ComfyUI + Flux 模型,配合其他工具使用