模型概述
模型特點
模型能力
使用案例
🚀 Animagine XL 4.0
Animagine XL 4.0 是一款終極動漫主題的微調 SDXL 模型,也是 Animagine XL 系列 的最新版本。它能夠基於文本提示生成和修改動漫風格的圖像,為動漫圖像創作提供了強大的支持。
🚀 快速開始
你可以通過以下幾種方式使用該模型:
- 在我們的
Hugging Face Spaces
中使用此模型。 - 在
ComfyUI
或Stable Diffusion Webui
中使用它。 - 使用 🧨
diffusers
庫來調用模型。
✨ 主要特性
- 強大的圖像生成能力:基於大規模的動漫風格圖像數據集進行訓練,能夠生成高質量、多樣化的動漫主題圖像。
- 持續優化:通過額外的數據集進一步優化了模型,提升了穩定性、解剖學準確性、降噪能力、色彩飽和度和整體色彩準確性。
- 支持特殊標籤:支持各種特殊標籤,可用於控制圖像生成過程的不同方面,如質量、風格、時間等。
📦 安裝指南
1. 安裝所需庫
pip install diffusers transformers accelerate safetensors --upgrade
2. 示例代碼
以下示例使用 lpw_stable_diffusion_xl
管道,它能更好地處理長、加權和詳細的提示。模型已以 FP16 格式上傳,因此在 from_pretrained
調用中無需指定 variant="fp16"
。
import torch
from diffusers import StableDiffusionXLPipeline
pipe = StableDiffusionXLPipeline.from_pretrained(
"cagliostrolab/animagine-xl-4.0",
torch_dtype=torch.float16,
use_safetensors=True,
custom_pipeline="lpw_stable_diffusion_xl",
add_watermarker=False
)
pipe.to('cuda')
prompt = "1girl, arima kana, oshi no ko, hoshimachi suisei, hoshimachi suisei \(1st costume\), cosplay, looking at viewer, smile, outdoors, night, v, masterpiece, high score, great score, absurdres"
negative_prompt = "lowres, bad anatomy, bad hands, text, error, missing finger, extra digits, fewer digits, cropped, worst quality, low quality, low score, bad score, average score, signature, watermark, username, blurry"
image = pipe(
prompt,
negative_prompt=negative_prompt,
width=832,
height=1216,
guidance_scale=5,
num_inference_steps=28
).images[0]
image.save("./arima_kana.png")
💻 使用示例
基礎用法
import torch
from diffusers import StableDiffusionXLPipeline
pipe = StableDiffusionXLPipeline.from_pretrained(
"cagliostrolab/animagine-xl-4.0",
torch_dtype=torch.float16,
use_safetensors=True,
custom_pipeline="lpw_stable_diffusion_xl",
add_watermarker=False
)
pipe.to('cuda')
prompt = "1girl, arima kana, oshi no ko, hoshimachi suisei, hoshimachi suisei \(1st costume\), cosplay, looking at viewer, smile, outdoors, night, v, masterpiece, high score, great score, absurdres"
negative_prompt = "lowres, bad anatomy, bad hands, text, error, missing finger, extra digits, fewer digits, cropped, worst quality, low quality, low score, bad score, average score, signature, watermark, username, blurry"
image = pipe(
prompt,
negative_prompt=negative_prompt,
width=832,
height=1216,
guidance_scale=5,
num_inference_steps=28
).images[0]
image.save("./arima_kana.png")
高級用法
在高級場景中,你可以根據需要調整更多參數,如不同的提示、負提示、圖像尺寸、引導比例和推理步數等,以獲得不同風格和質量的圖像。例如:
import torch
from diffusers import StableDiffusionXLPipeline
pipe = StableDiffusionXLPipeline.from_pretrained(
"cagliostrolab/animagine-xl-4.0",
torch_dtype=torch.float16,
use_safetensors=True,
custom_pipeline="lpw_stable_diffusion_xl",
add_watermarker=False
)
pipe.to('cuda')
# 自定義提示和負提示
prompt = "1boy, male focus, green hair, sweater, looking at viewer, upper body, beanie, outdoors, night, turtleneck, masterpiece, high score, great score, absurdres"
negative_prompt = "lowres, bad anatomy, bad hands, text, error, missing finger, extra digits, fewer digits, cropped, worst quality, low quality, low score, bad score, average score, signature, watermark, username, blurry"
# 調整圖像尺寸、引導比例和推理步數
image = pipe(
prompt,
negative_prompt=negative_prompt,
width=1024,
height=1024,
guidance_scale=6,
num_inference_steps=30
).images[0]
image.save("./custom_image.png")
📚 詳細文檔
使用指南
提示指南的總結可在圖像中查看。
1. 提示結構
該模型使用基於標籤的標題和標籤排序方法進行訓練。請使用以下結構化模板:
1girl/1boy/1other, 角色名稱, 所屬系列, 評級, 其他任意順序的內容,並以質量增強標籤結尾
2. 質量增強標籤
在提示末尾添加以下標籤:
masterpiece, high score, great score, absurdres
3. 推薦的負提示
lowres, bad anatomy, bad hands, text, error, missing finger, extra digits, fewer digits, cropped, worst quality, low quality, low score, bad score, average score, signature, watermark, username, blurry
4. 最佳設置
- CFG 比例:4 - 7(推薦 5)
- 採樣步數:25 - 28(推薦 28)
- 首選採樣器:Euler Ancestral(Euler a)
5. 推薦分辨率
方向 | 尺寸 | 縱橫比 |
---|---|---|
正方形 | 1024 x 1024 | 1:1 |
橫向 | 1152 x 896 | 9:7 |
1216 x 832 | 3:2 | |
1344 x 768 | 7:4 | |
1536 x 640 | 12:5 | |
縱向 | 896 x 1152 | 7:9 |
832 x 1216 | 2:3 | |
768 x 1344 | 4:7 | |
640 x 1536 | 5:12 |
6. 最終提示結構示例
1girl, firefly \(honkai: star rail\), honkai \(series\), honkai: star rail, safe, casual, solo, looking at viewer, outdoors, smile, reaching towards viewer, night, masterpiece, high score, great score, absurdres
特殊標籤
該模型支持各種特殊標籤,可用於控制圖像生成過程的不同方面。這些標籤經過精心加權和測試,以在不同提示下提供一致的結果。
質量標籤
質量標籤是直接影響整體圖像質量和細節水平的基本控制項。可用的質量標籤有:
masterpiece
best quality
low quality
worst quality
![]() |
![]() |
---|---|
使用 "masterpiece, best quality" 質量標籤且負提示為空的示例圖像。 |
使用 "low quality, worst quality" 質量標籤且負提示為空的示例圖像。 |
分數標籤
與基本質量標籤相比,分數標籤能更細緻地控制圖像質量。它們對引導此模型的輸出質量有更強的影響。可用的分數標籤有:
high score
great score
good score
average score
bad score
low score
![]() |
![]() |
---|---|
使用 "high score, great score" 分數標籤且負提示為空的示例圖像。 |
使用 "bad score, low score" 分數標籤且負提示為空的示例圖像。 |
時間標籤
時間標籤允許你根據特定時間段或年份影響藝術風格。這對於生成具有特定時代藝術特徵的圖像很有用。支持的年份標籤有:
year 2005
year {n}
year 2025
![]() |
![]() |
---|---|
帶有 "year 2007" 時間標籤的初音未來示例圖像。 |
帶有 "year 2023" 時間標籤的初音未來示例圖像。 |
評級標籤
評級標籤有助於控制生成圖像的內容安全級別。這些標籤應負責任地使用,並符合適用的法律和平臺政策。支持的評級有:
safe
sensitive
nsfw
explicit
🔧 技術細節
該模型使用了最先進的硬件和優化的超參數進行訓練,以確保輸出的最高質量。以下是訓練過程中使用的詳細技術規格和參數:
參數 | 值 |
---|---|
硬件 | 7 x H100 80GB SXM5 |
圖像數量 | 8,401,464 |
UNet 學習率 | 2.5e-6 |
文本編碼器學習率 | 1.25e-6 |
調度器 | Constant With Warmup |
熱身步數 | 5% |
批量大小 | 32 |
梯度累積步數 | 2 |
訓練分辨率 | 1024x1024 |
優化器 | Adafactor |
輸入擾動噪聲 | 0.1 |
去偏估計損失 | 啟用 |
混合精度 | fp16 |
📄 許可證
該模型採用了 Stability AI 的原始 CreativeML Open RAIL++-M 許可證,未做任何修改或添加額外限制。許可證條款與原始 SDXL 許可證中規定的完全一致,包括:
- ✅ 允許:商業使用、修改、分發、私人使用
- ❌ 禁止:非法活動、有害內容生成、歧視、剝削
- ⚠️ 要求:包含許可證副本、說明更改、保留聲明
- 📝 保證:“按原樣”提供,不提供保證
請參考 原始 SDXL 許可證 獲取完整和權威的條款和條件。
致謝
如果沒有 Stability AI、Novel AI 和 Waifu Diffusion Team 的開創性工作、創新貢獻和全面文檔,這個長期項目是不可能實現的。我們特別感謝 Main 提供的啟動資金,使我們能夠在 V2 版本之後繼續推進。對於這個版本,我們衷心感謝社區中每個人的持續支持,特別是:
- Moescape AI:我們在模型分發和測試方面的寶貴合作伙伴。
- Lesser Rabbit:提供了重要的計算和研究資金。
- Kohya SS:開發了全面的開源訓練框架。
- discus0434:創建了行業領先的開源美學預測器 2.5。
- 早期測試人員:他們致力於提供關鍵反饋和全面的質量保證。
貢獻者
我們衷心感謝為這個項目做出重大貢獻的團隊成員,包括但不限於:
模型
Gradio
關係、財務和質量保證
數據
新的籌款方式!
我們很高興通過 GitHub Sponsors 推出新的籌款方式,以支持訓練、研究和模型開發。您的支持將幫助我們突破人工智能的界限。
您可以通過以下方式幫助我們:
- 捐贈:通過 ETH、USDT 或 USDC 向以下地址捐款,或在 GitHub 上贊助我們。
- 分享:宣傳我們的模型並分享您的創作!
- 反饋:告訴我們如何改進。
捐贈地址:
ETH/USDT/USDC(e): 0xd8A1dA94BA7E6feCe8CfEacc1327f498fCcBFC0C
GitHub 贊助:https://github.com/sponsors/cagliostrolab/
為什麼我們使用加密貨幣?
當我們最初通過 Ko-fi 開啟籌款並使用 PayPal 作為提現方式時,我們的 PayPal 賬戶被標記並最終被封禁,儘管我們努力解釋了項目的目的。不幸的是,這迫使我們退還了所有捐款,並且讓我們沒有可靠的方式來接受支持。為了避免此類問題並確保透明度,我們現在已轉向使用加密貨幣進行籌款。想以非加密貨幣方式捐贈?
雖然我們在使用 Paypal 時有過不愉快的經歷,但如果您想支持我們但不想使用加密貨幣,請隨時通過 [Discord 服務器](https://discord.gg/cqh9tZgbGc) 聯繫我們,瞭解其他捐贈方式。加入我們的 Discord 服務器
歡迎加入我們的 Discord 服務器
侷限性
- 提示格式:僅限於基於標籤的文本提示;自然語言輸入可能效果不佳。
- 解剖學:可能難以處理複雜的解剖學細節,特別是手部姿勢和手指數量。
- 文本生成:目前不支持在圖像中渲染文本,不建議嘗試。
- 新角色:由於訓練數據有限,近期角色的生成準確性可能較低。
- 多角色場景:包含多個角色的場景可能需要精心設計提示。
- 分辨率:由於訓練使用的是原始 SDXL 分辨率,較高分辨率(如 1536x1536)可能會出現質量下降。
- 風格一致性:可能需要特定的風格標籤,因為訓練更側重於身份保留而非風格一致性。

