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