animagine xl 4.0
Overview
Highlights
- High-precision character rendering using Danbooru tagging
- Seamless integration with SDXL-based deployment pipelines
- Superior anatomical accuracy for stylized human figures
- Optimized for consistent anime and manga aesthetics
- OpenRail++ license for flexible commercial integration
Usage
# Install Hugging Face transformers
pip install transformers torch
# Load model with transformers
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("cagliostrolab/animagine-xl-4.0")
tokenizer = AutoTokenizer.from_pretrained("cagliostrolab/animagine-xl-4.0")
Hugging Face Download
We recommend downloading the model via the Hugging Face CLI or Hub SDK.
Guidance:Before downloading, install huggingface_hub with:
pip install -U huggingface_hub
CLI Download
Download the full repository
huggingface-cli download cagliostrolab/animagine-xl-4.0
Download a single file to a local folder (e.g. config.json into ./dir)
huggingface-cli download cagliostrolab/animagine-xl-4.0 config.json --local-dir ./dir
See the official docs for more CLI options
SDK Download
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('cagliostrolab/animagine-xl-4.0')
Git Download
Make sure git-lfs is installed first
git lfs install
git clone https://huggingface.co/cagliostrolab/animagine-xl-4.0
To skip LFS large-file downloads, use:
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/cagliostrolab/animagine-xl-4.0
Model files are hosted on the Hugging Face Hub — download directly via HF CLI / SDK / Git, not through this site.
PyTorch / Transformers Usage
Install Transformers
pip install -U transformers torch
Load the model and run inference
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('cagliostrolab/animagine-xl-4.0')
tokenizer = AutoTokenizer.from_pretrained('cagliostrolab/animagine-xl-4.0')
Model Download
We recommend downloading the model via the ModelScope CLI or SDK.
Guidance:Before downloading, install ModelScope with:
pip install modelscope
CLI Download
Download the full repository
modelscope download --model cagliostrolab/animagine-xl-4.0
Download a single file to a local folder (e.g. README.md into ./dir)
modelscope download --model cagliostrolab/animagine-xl-4.0 README.md --local_dir ./dir
See the docs for more CLI options
SDK Download
# 模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('cagliostrolab/animagine-xl-4.0')
Git Download
Make sure git-lfs is installed first
git lfs install
git clone https://www.modelscope.cn/cagliostrolab/animagine-xl-4.0.git
To skip LFS large-file downloads, use:
GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/cagliostrolab/animagine-xl-4.0.git
ModelScope 模型页直接下载模型文件;无需将模型文件放在本站服务器。
Notebook Quickstart
Install the ModelScope library
pip install "modelscope[audio,cv,nlp,multi-modal,science]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
Load the model and run inference
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
p = pipeline('text-generation', 'cagliostrolab/animagine-xl-4.0')
Full Documentation
---
language:
- en
tags:
- text-to-image
- stable-diffusion
- safetensors
- stable-diffusion-xl
widget:
- text: >-
1girl, green hair, sweater, looking at viewer, upper body, beanie, outdoors,
night, turtleneck, masterpiece, high score, great score, absurdres
parameter:
negative_prompt: >-
lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit,
fewer digits, cropped, worst quality, low quality, low score, bad score,
average score, signature, watermark, username, blurry
example_title: 1girl
- text: >-
1boy, male focus, green hair, sweater, looking at viewer, upper body,
beanie, outdoors, night, turtleneck, masterpiece, high score, great score,
absurdres
parameter:
negative_prompt: >-
lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit,
fewer digits, cropped, worst quality, low quality, low score, bad score,
average score, signature, watermark, username, blurry
example_title: 1boy
license: openrail++
base_model:
- stabilityai/stable-diffusion-xl-base-1.0
---
Animagine XL 4.0
Overview
Animagine XL 4.0, also stylized as Anim4gine, is the ultimate anime-themed finetuned SDXL model and the latest installment of Animagine XL series. Despite being a continuation, the model was retrained from Stable Diffusion XL 1.0 with a massive dataset of 8.4M diverse anime-style images from various sources with the knowledge cut-off of January 7th 2025 and finetuned for approximately 2650 GPU hours. Similar to the previous version, this model was trained using tag ordering method for the identity and style training.
With the release of Animagine XL 4.0 Opt (Optimized), the model has been further refined with an additional dataset, improving stability, anatomy accuracy, noise reduction, color saturation, and overall color accuracy. These enhancements make Animagine XL 4.0 Opt more consistent and visually appealing while maintaining the signature quality of the series.
Changelog
- 2025-02-13 – Added Animagine XL 4.0 Opt
- 2025-01-24 – Initial release
Model Details
- Developed by: Cagliostro Research Lab
- Model type: Diffusion-based text-to-image generative model
- License: CreativeML Open RAIL++-M
- Model Description: This is a model that can be used to generate and modify specifically anime-themed images based on text prompt
- Fine-tuned from: Stable Diffusion XL 1.0
Downstream Use
1. Use this model in our Hugging Face Spaces
2. Use it in ComfyUI or Stable Diffusion Webui
3. Use it with 🧨 diffusers
🧨 Diffusers Installation
1. Install Required Libraries
pip install diffusers transformers accelerate safetensors --upgrade2. Example Code
The example below useslpw_stable_diffusion_xl pipeline which enables better handling of long, weighted and detailed prompts. The model is already uploaded in FP16 format, so there's no need to specify variant="fp16" in the from_pretrained call.
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")
Usage Guidelines
The summary can be seen in the image for the prompt guideline.
1. Prompt Structure
The model was trained with tag-based captions and the tag-ordering method. Use this structured template:1girl/1boy/1other, character name, from which series, rating, everything else in any order and end with quality enhancement2. Quality Enhancement Tags
Add these tags at the end of your prompt:masterpiece, high score, great score, absurdres3. Recommended 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, blurry4. Optimal Settings
- CFG Scale: 4-7 (5 Recommended)
- Sampling Steps: 25-28 (28 Recommended)
- Preferred Sampler: Euler Ancestral (Euler a)
5. Recommended Resolutions
| Orientation | Dimensions | Aspect Ratio |
|------------|------------|--------------|
| Square | 1024 x 1024| 1:1 |
| Landscape | 1152 x 896 | 9:7 |
| | 1216 x 832 | 3:2 |
| | 1344 x 768 | 7:4 |
| | 1536 x 640 | 12:5 |
| Portrait | 896 x 1152 | 7:9 |
| | 832 x 1216 | 2:3 |
| | 768 x 1344 | 4:7 |
| | 640 x 1536 | 5:12 |
6. Final Prompt Structure Example
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, absurdresSpecial Tags
The model supports various special tags that can be used to control different aspects of the image generation process. These tags are carefully weighted and tested to provide consistent results across different prompts.
Quality Tags
Quality tags are fundamental controls that directly influence the overall image quality and detail level. Available quality tags:masterpiece
best quality
low quality
worst quality
| <img src="https://cdn-uploads.huggingface.co/production/uploads/6365c8dbf31ef76df4042821/bDdKraYxjiReKknlYJepR.png" width="100%" style="max-height: 400px; object-fit: contain;"> | <img src="https://cdn-uploads.huggingface.co/production/uploads/6365c8dbf31ef76df4042821/mAgMMKL2tBj8oBuWHTYUz.png" width="100%" style="max-height: 400px; object-fit: contain;"> |
|---|---|
| Sample image using "masterpiece, best quality" quality tags with negative prompt left empty. | Sample image using "low quality, worst quality" quality tags with negative prompt left empty. |
Score Tags
Score tags provide a more nuanced control over image quality compared to basic quality tags. They have a stronger impact on steering output quality in this model. Available score tags:high score
great score
good score
average score
bad score
low score
| <img src="https://cdn-uploads.huggingface.co