animagine xl 4.0

Providercagliostrolab
Categorytext-to-image
Licenseopenrail++
Downloads9.7K
Stars10

Overview

Animagine XL 4.0 is a specialized diffusion model optimized for high-fidelity anime and manga style generation. Unlike general-purpose models, it is fine-tuned on a massive dataset of tagged illustrations, allowing for precise control over character consistency, art styles, and complex compositions via Danbooru-style tagging. For developers, it offers a significant upgrade in anatomical accuracy and prompt adherence over previous iterations. It integrates seamlessly into existing Stable Diffusion XL pipelines, making it a drop-in replacement for projects requiring stylized visual assets, AI-driven character design, or synthetic dataset generation for creative apps. It bridges the gap between raw generative power and the specific aesthetic requirements of the ACG (Anime, Comic, Games) industry.

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
# Install Hugging Face transformers
pip install transformers torch
SDK Usage
# 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:

Guidance
pip install -U huggingface_hub

CLI Download

Download the full repository

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)

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

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 Download
git lfs install
git clone https://huggingface.co/cagliostrolab/animagine-xl-4.0

To skip LFS large-file downloads, use:

Skip LFS
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

Install Transformers
pip install -U transformers torch

Load the model and run inference

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:

Guidance
pip install modelscope

CLI Download

Download the full repository

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)

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

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 Download
git lfs install
git clone https://www.modelscope.cn/cagliostrolab/animagine-xl-4.0.git

To skip LFS large-file downloads, use:

Skip LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/cagliostrolab/animagine-xl-4.0.git

ModelScope 模型页直接下载模型文件;无需将模型文件放在本站服务器。

Notebook Quickstart

Install the ModelScope library

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

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

来源: HuggingFace

---
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

!image/png

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
- Better stability for more consistent outputs - Enhanced anatomy with more accurate proportions - Reduced noise and artifacts in generations - Fixed low saturation issues, resulting in richer colors - Improved color accuracy for more visually appealing results
  • 2025-01-24 – Initial release

Model Details

  • Model type: Diffusion-based text-to-image generative model
  • Model Description: This is a model that can be used to generate and modify specifically anime-themed images based on text prompt

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

bash
pip install diffusers transformers accelerate safetensors --upgrade

2. Example Code

The example below uses lpw_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.
python
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.

!image/png

1. Prompt Structure

The model was trained with tag-based captions and the tag-ordering method. Use this structured template:
code
1girl/1boy/1other, character name, from which series, rating, everything else in any order and end with quality enhancement

2. Quality Enhancement Tags

Add these tags at the end of your prompt:
code
masterpiece, high score, great score, absurdres

3. Recommended Negative Prompt

code
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. 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

code
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

Special 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

Join our Telegram