Ben Brand LoRA
基于FLUX.1-dev训练的PEFT LoRA模型,专注于文本生成图像任务,支持特定艺术风格转换。
下载量 253
发布时间 : 2/19/2025
模型简介
这是一个基于FLUX.1-dev基础模型训练的标准PEFT LoRA模型,主要用于文本生成图像任务,能够根据文本描述生成具有特定艺术风格的图像。
模型特点
艺术风格转换
能够根据文本描述生成具有特定艺术风格的图像,如示例中的b3nbr4nd画风。
高分辨率输出
支持最高1024x1024分辨率的图像生成。
高效微调
采用LoRA技术进行参数高效微调,仅训练少量参数即可实现风格迁移。
模型能力
文本生成图像
艺术风格转换
高分辨率图像生成
使用案例
创意设计
概念艺术创作
根据文字描述快速生成概念艺术图像
如示例中盘绕在方尖碑上的巨型绿蛇图像
风格化图像生成
将普通描述转换为特定艺术风格的图像
如b3nbr4nd画风的图像生成
游戏开发
游戏场景概念设计
快速生成游戏场景的概念图
如示例中部分掩埋的古代遗迹场景
🚀 Ben-Brand-LoRA
Ben-Brand-LoRA 是一个标准的 PEFT LoRA,它源自 black-forest-labs/FLUX.1-dev。本项目在训练过程中未使用验证提示。
🚀 快速开始
推理示例
以下是使用该 LoRA 进行推理的示例代码:
import torch
from diffusers import DiffusionPipeline
model_id = 'black-forest-labs/FLUX.1-dev'
adapter_id = 'davidrd123/Ben-Brand-LoRA'
pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) # loading directly in bf16
pipeline.load_lora_weights(adapter_id)
prompt = "An astronaut is riding a horse through the jungles of Thailand."
## Optional: quantise the model to save on vram.
## Note: The model was quantised during training, and so it is recommended to do the same during inference time.
from optimum.quanto import quantize, freeze, qint8
quantize(pipeline.transformer, weights=qint8)
freeze(pipeline.transformer)
pipeline.to('cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu') # the pipeline is already in its target precision level
image = pipeline(
prompt=prompt,
num_inference_steps=20,
generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(42),
width=1024,
height=1024,
guidance_scale=3.0,
).images[0]
image.save("output.png", format="PNG")
✨ 主要特性
- 基于
black-forest-labs/FLUX.1-dev
模型派生的标准 PEFT LoRA。 - 文本编码器未进行训练,推理时可复用基础模型的文本编码器。
📦 安装指南
文档未提及具体安装步骤,可参考推理示例代码中的依赖导入部分,确保安装以下库:
torch
diffusers
optimum.quanto
💻 使用示例
基础用法
import torch
from diffusers import DiffusionPipeline
model_id = 'black-forest-labs/FLUX.1-dev'
adapter_id = 'davidrd123/Ben-Brand-LoRA'
pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) # loading directly in bf16
pipeline.load_lora_weights(adapter_id)
prompt = "An astronaut is riding a horse through the jungles of Thailand."
pipeline.to('cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu') # the pipeline is already in its target precision level
image = pipeline(
prompt=prompt,
num_inference_steps=20,
generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(42),
width=1024,
height=1024,
guidance_scale=3.0,
).images[0]
image.save("output.png", format="PNG")
高级用法
import torch
from diffusers import DiffusionPipeline
model_id = 'black-forest-labs/FLUX.1-dev'
adapter_id = 'davidrd123/Ben-Brand-LoRA'
pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) # loading directly in bf16
pipeline.load_lora_weights(adapter_id)
prompt = "An astronaut is riding a horse through the jungles of Thailand."
## Optional: quantise the model to save on vram.
## Note: The model was quantised during training, and so it is recommended to do the same during inference time.
from optimum.quanto import quantize, freeze, qint8
quantize(pipeline.transformer, weights=qint8)
freeze(pipeline.transformer)
pipeline.to('cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu') # the pipeline is already in its target precision level
image = pipeline(
prompt=prompt,
num_inference_steps=20,
generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(42),
width=1024,
height=1024,
guidance_scale=3.0,
).images[0]
image.save("output.png", format="PNG")
📚 详细文档
验证设置
设置项 | 详情 |
---|---|
CFG | 3.0 |
CFG Rescale | 0.0 |
步数 | 20 |
采样器 | FlowMatchEulerDiscreteScheduler |
种子 | 42 |
分辨率 | 1024x1024 |
跳过层引导 | 无 |
注意:验证设置不一定与训练设置相同。
训练设置
设置项 | 详情 |
---|---|
训练轮数 | 2 |
训练步数 | 3750 |
学习率 | 0.00015 - 学习率调度:常数 - 热身步数:100 |
最大梯度范数 | 0.1 |
有效批量大小 | 6 - 微批量大小:2 - 梯度累积步数:3 - GPU 数量:1 |
梯度检查点 | True |
预测类型 | flow-matching (额外参数=['shift=3', 'flux_guidance_mode=constant', 'flux_guidance_value=1.0', 'flow_matching_loss=compatible', 'flux_lora_target=all']) |
优化器 | adamw_bf16 |
可训练参数精度 | Pure BF16 |
字幕丢弃概率 | 10.0% |
LoRA 秩 | 64 |
LoRA Alpha | None |
LoRA 丢弃率 | 0.1 |
LoRA 初始化风格 | 默认 |
数据集
数据集名称 | 重复次数 | 图像总数 | 宽高比桶总数 | 分辨率 | 裁剪 | 裁剪风格 | 裁剪宽高比 | 是否用于正则化数据 |
---|---|---|---|---|---|---|---|---|
ben-brand-256 | 10 | 98 | 3 | 0.065536 兆像素 | 否 | 无 | 无 | 否 |
ben-brand-crop-256 | 10 | 98 | 1 | 0.065536 兆像素 | 是 | 中心裁剪 | 方形 | 否 |
ben-brand-512 | 10 | 98 | 3 | 0.262144 兆像素 | 否 | 无 | 无 | 否 |
ben-brand-crop-512 | 10 | 98 | 1 | 0.262144 兆像素 | 是 | 中心裁剪 | 方形 | 否 |
ben-brand-768 | 10 | 98 | 3 | 0.589824 兆像素 | 否 | 无 | 无 | 否 |
ben-brand-crop-768 | 10 | 98 | 1 | 0.589824 兆像素 | 是 | 中心裁剪 | 方形 | 否 |
ben-brand-1024 | 10 | 98 | 4 | 1.048576 兆像素 | 否 | 无 | 无 | 否 |
ben-brand-crop-1024 | 10 | 98 | 1 | 1.048576 兆像素 | 是 | 中心裁剪 | 方形 | 否 |
ben-brand-1440 | 10 | 98 | 2 | 2.0736 兆像素 | 否 | 无 | 无 | 否 |
ben-brand-crop-1440 | 10 | 98 | 1 | 2.0736 兆像素 | 是 | 中心裁剪 | 方形 | 否 |
🔧 技术细节
- 文本编码器在训练过程中未进行训练,推理时可复用基础模型的文本编码器。
- 模型在训练过程中进行了量化,推理时建议进行相同的量化操作以节省显存。
📄 许可证
许可证类型:other
Stable Diffusion V1 5
Openrail
稳定扩散是一种潜在的文本到图像扩散模型,能够根据任何文本输入生成逼真的图像。
图像生成
S
stable-diffusion-v1-5
3.7M
518
Stable Diffusion Inpainting
Openrail
基于稳定扩散的文本到图像生成模型,具备图像修复能力
图像生成
S
stable-diffusion-v1-5
3.3M
56
Stable Diffusion Xl Base 1.0
SDXL 1.0是基于扩散的文本生成图像模型,采用专家集成的潜在扩散流程,支持高分辨率图像生成
图像生成
S
stabilityai
2.4M
6,545
Stable Diffusion V1 4
Openrail
稳定扩散是一种潜在文本到图像扩散模型,能够根据任意文本输入生成逼真图像。
图像生成
S
CompVis
1.7M
6,778
Stable Diffusion Xl Refiner 1.0
SD-XL 1.0优化器模型是Stability AI开发的图像生成模型,专为提升SDXL基础模型生成的图像质量而设计,特别擅长最终去噪步骤处理。
图像生成
S
stabilityai
1.1M
1,882
Stable Diffusion 2 1
基于扩散的文本生成图像模型,支持通过文本提示生成和修改图像
图像生成
S
stabilityai
948.75k
3,966
Stable Diffusion Xl 1.0 Inpainting 0.1
基于Stable Diffusion XL的潜在文本到图像扩散模型,具备通过遮罩进行图像修复的功能
图像生成
S
diffusers
673.14k
334
Stable Diffusion 2 Base
基于扩散的文生图模型,可根据文本提示生成高质量图像
图像生成
S
stabilityai
613.60k
349
Playground V2.5 1024px Aesthetic
其他
开源文生图模型,能生成1024x1024分辨率及多种纵横比的美学图像,在美学质量上处于开源领域领先地位。
图像生成
P
playgroundai
554.94k
723
Sd Turbo
SD-Turbo是一款高速文本生成图像模型,仅需单次网络推理即可根据文本提示生成逼真图像。该模型作为研究原型发布,旨在探索小型蒸馏文本生成图像模型。
图像生成
S
stabilityai
502.82k
380
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98