animagine-xl-3.1 / README.md
ItsMeBell's picture
Update README.md
c325cfb verified
|
raw
history blame
21.2 kB
metadata
license: other
license_name: faipl-1.0-sd
license_link: https://freedevproject.org/faipl-1.0-sd/
language:
  - en
tags:
  - text-to-image
  - stable-diffusion
  - safetensors
  - stable-diffusion-xl
base_model: cagliostrolab/animagine-xl-3.0
widget:
  - text: >-
      1girl, green hair, sweater, looking at viewer, upper body, beanie,
      outdoors, night, turtleneck, masterpiece, best quality, very aesthetic,
      absurdes
    parameter:
      negative_prompt: >-
        nsfw, lowres, (bad), text, error, fewer, extra, missing, worst quality,
        jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest,
        early, chromatic aberration, signature, extra digits, artistic error,
        username, scan, [abstract]
    example_title: 1girl
  - text: >-
      1boy, male focus, green hair, sweater, looking at viewer, upper body,
      beanie, outdoors, night, turtleneck, masterpiece, best quality, very
      aesthetic, absurdes
    parameter:
      negative_prompt: >-
        nsfw, lowres, (bad), text, error, fewer, extra, missing, worst quality,
        jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest,
        early, chromatic aberration, signature, extra digits, artistic error,
        username, scan, [abstract]
    example_title: 1boy

Animagine XL 3.1

Imagine Beyond 3.0

sample1
sample4
sample2
sample3
sample1
sample4

Animagine XL 3.1 is the latest version of the sophisticated open-source anime text-to-image model, building upon the capabilities of its predecessor, Animagine XL 3.0. Developed based on Stable Diffusion XL, this iteration boasts superior image generation with notable improvements in hand anatomy, efficient tag ordering, and enhanced knowledge about anime concepts. Unlike the previous iteration, we focused to make the model learn concepts rather than aesthetic.

What’s New in Animagine XL 3.1 ?

Aesthetic Tags

In addition to special tags, we would like to introduce aesthetic tags based on ShadowLilac’s Aesthetic Shadow V2. This tag, combined with quality tag, can be used to guide the model to generate better results. Below is the list of aesthetic tag that we include in this model, sorted from the best to the worst:

  • very aesthetic
  • aesthetic
  • displeasing
  • very displeasing

Anime-focused Dataset Additions

On Animagine XL 3.0, we mostly added characters from popular gacha games. Based on users’ feedbacks, we are adding plenty of popular anime franchises into our dataset for this model. We will release the full list of the characters that might be generated by this iteration to our HuggingFace soon, be sure to check it out when it’s up!

Model Details

  • Developed by: Cagliostro Research Lab
  • Sponsored by Seaart
  • Model type: Diffusion-based text-to-image generative model
  • Model Description: Animagine XL 3.1 is engineered to generate high-quality anime images from textual prompts. It features enhanced hand anatomy, better concept understanding, and prompt interpretation, making it the most advanced model in its series.
  • License: Fair AI Public License 1.0-SD
  • Finetuned from model: Animagine XL 3.0

Gradio & Colab Integration

Animagine XL 3.1 is accessible through user-friendly platforms such as Gradio and Google Colab:

🧨 Diffusers Installation

To use Animagine XL 3.1, install the required libraries as follows:

pip install diffusers transformers accelerate safetensors --upgrade

Example script for generating images with Animagine XL 3.1:

import torch
from diffusers import DiffusionPipeline, 

pipe = DiffusionPipeline.from_pretrained(
    "cagliostrolab/animagine-xl-3.1", 
    torch_dtype=torch.float16, 
    use_safetensors=True, 
)
pipe.to('cuda')

prompt = "1girl, souryuu asuka langley, neon genesis evangelion, solo, upper body, v, smile, looking at viewer, outdoors, night"
negative_prompt = "nsfw, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, [abstract]"
image = pipe(
    prompt, 
    negative_prompt=negative_prompt, 
    width=832,
    height=1216,
    guidance_scale=7,
    num_inference_steps=28
).images[0]

image.save("./asuka_test.png")

Usage Guidelines

Tag Ordering

For optimal results, it's recommended to follow the structured prompt template because we train the model like this:

1girl/1boy, character name, from what series, everything else in any order.

Special Tags

Like the previous iteration, this model was trained with some special tags to steer the result toward quality, rating and when the posts was created. The model can still do the job without these special tags, but it’s recommended to use them if we want to make the model easier to handle.

Quality Modifiers

Quality tags now consider both scores and post ratings to ensure a balanced quality distribution. We've refined labels for greater clarity, such as changing 'high quality' to 'great quality'.

Quality Modifier Score Criterion
masterpiece > 95%
best quality > 85% & ≤ 95%
great quality > 75% & ≤ 85%
good quality > 50% & ≤ 75%
normal quality > 25% & ≤ 50%
low quality > 10% & ≤ 25%
worst quality ≤ 10%

Rating Modifiers

We've also streamlined our rating tags for simplicity and clarity, aiming to establish global rules that can be applied across different models. For example, the tag 'rating: general' is now simply 'general', and 'rating: sensitive' has been condensed to 'sensitive'.

Rating Modifier Rating Criterion
general General
sensitive Sensitive
nsfw Questionable
explicit, nsfw Explicit

Year Modifier

We've also redefined the year range to steer results towards specific modern or vintage anime art styles more accurately. This update simplifies the range, focusing on relevance to current and past eras.

Year Tag Year Range
newest 2021 to 2024
recent 2018 to 2020
mid 2015 to 2017
early 2011 to 2014
oldest 2005 to 2010

Aesthetic Tags

We've enhanced our tagging system with aesthetic tags to refine content categorization based on visual appeal. These tags—very aesthetic, aesthetic, displeasing, and very displeasing—are derived from evaluations made by a specialized ViT (Vision Transformer) image classification model, specifically trained on anime data. For this purpose, we utilized the model shadowlilac/aesthetic-shadow-v2, which assesses the aesthetic value of content before it undergoes training. This ensures that each piece of content is not only relevant and accurate but also visually appealing.

Aesthetic Tag Score Range
very aesthetic > 0.71
aesthetic > 0.45 & < 0.71
displeasing > 0.27 & < 0.45
very displeasing ≤ 0.27

Recommended settings

To guide the model towards generating high-aesthetic images, use negative prompts like:

nsfw, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, [abstract]

For higher quality outcomes, prepend prompts with:

masterpiece, best quality, very aesthetic, absurdres

it’s recommended to use a lower classifier-free guidance (CFG Scale) of around 5-7, sampling steps below 30, and to use Euler Ancestral (Euler a) as a sampler.

Multi Aspect Resolution

This model supports generating images at the following dimensions:

Dimensions Aspect Ratio
1024 x 1024 1:1 Square
1152 x 896 9:7
896 x 1152 7:9
1216 x 832 19:13
832 x 1216 13:19
1344 x 768 7:4 Horizontal
768 x 1344 4:7 Vertical
1536 x 640 12:5 Horizontal
640 x 1536 5:12 Vertical

Training and Hyperparameters

  • Animagine XL 3.1 was trained on a 2x A100 GPU 80GB for roughly 15 days or over 350 gpu hours (pretraining stage). The training process encompassed three stages:
    • Continual Pretraining:
      • Pretraining Stage: Utilize data-rich collection of images, this consists of 870k ordered, tagged images, to increase Animagine XL 3.0 model knowledge.
    • Finetuning:
      • First Stage: Utilize labeled and curated aesthetic datasets to refine broken U-Net after pretraining
      • Second Stage: Utilize labeled and curated aesthetic datasets to refine the model's art style and fixing bad hands and anatomy

Hyperparameters

Stage Epochs UNet lr Train Text Encoder Batch Size Noise Offset Optimizer LR Scheduler Grad Acc Steps GPUs
Pretraining Stage 10 1e-5 True 16 N/A AdamW Cosine Annealing Warm Restart 3 2
First Stage 10 2e-6 False 48 0.0357 Adafactor Constant with Warmup 1 1
Second Stage 15 1e-6 False 48 0.0357 Adafactor Constant with Warmup 1 1

Model Comparison (Pretraining only)

Training Config

Configuration Item Animagine XL 3.0 Animagine XL 3.1
GPU 2 x A100 80G 2 x A100 80G
Dataset 1,271,990 873,504
Shuffle Separator True True
Num Epochs 10 10
Learning Rate 7.5e-6 1e-5
Text Encoder Learning Rate 3.75e-6 1e-5
Effective Batch Size 48 x 1 x 2 16 x 3 x 2
Optimizer Adafactor AdamW
Optimizer Args Scale Parameter: False, Relative Step: False, Warmup Init: False Weight Decay: 0.1, Betas: (0.9, 0.99)
LR Scheduler Constant with Warmup Cosine Annealing Warm Restart
LR Scheduler Args Warmup Steps: 100 Num Cycles: 10, Min LR: 1e-6, LR Decay: 0.9, First Cycle Steps: 9,099

Source code and training config are available here: https://github.com/cagliostrolab/sd-scripts/tree/main/notebook

Limitations

While "Animagine XL 3.1" represents a significant advancement in anime text-to-image generation, it's important to acknowledge its limitations to understand its best use cases and potential areas for future improvement.

  1. Concept Over Artstyle Focus: The model prioritizes learning concepts rather than specific art styles, which might lead to variations in aesthetic appeal compared to its predecessor.
  2. Non-Photorealistic Design: Animagine XL 3.0 is not designed for generating photorealistic or realistic images, focusing instead on anime-style artwork.
  3. Anatomical Challenges: Despite improvements, the model can still struggle with complex anatomical structures, particularly in dynamic poses, resulting in occasional inaccuracies.
  4. Dataset Limitations: The training dataset of 1.2 million images may not encompass all anime characters or series, limiting the model's ability to generate less known or newer characters.
  5. Natural Language Processing: The model is not optimized for interpreting natural language, requiring more structured and specific prompts for best results.
  6. NSFW Content Risk: Using high-quality tags like 'masterpiece' or 'best quality' carries a risk of generating NSFW content inadvertently, due to the prevalence of such images in high-scoring training datasets.

These limitations highlight areas for potential refinement in future iterations and underscore the importance of careful prompt crafting for optimal results. Understanding these constraints can help users better navigate the model's capabilities and tailor their expectations accordingly.

Acknowledgements

We extend our gratitude to the entire team and community that contributed to the development of Animagine XL 3.0, including our partners and collaborators who provided resources and insights crucial for this iteration, and most importantly Seaart who provide compute power for model training. Without them we would not be able to Train this model properly.

  • Main: Seaart For the for the Sponsorship.
  • Cagliostro Lab Collaborator: For helping quality checking during pretraining and curating datasets during fine-tuning.
  • Kohya SS: For providing the training scripts for model training, project, and data management
  • Camenduru Server Community: For invaluable insights and support and quality checking
  • NovelAI: For inspiring how to build the datasets and label it using tag ordering and Aesthetic Tags
  • Shadow lilac: For classification models.
  • Derrian Distro: for lr scheduler

Collaborators

License

Based on Animagine XL 3.0, Animagine XL 3.1 falls under Fair AI Public License 1.0-SD, compatible with Stable Diffusion models. Key points:

  1. Modification Sharing: If you modify Animagine XL 3.1, you must share both your changes and the original license.
  2. Source Code Accessibility: If your modified version is network-accessible, provide a way (like a download link) for others to get the source code. This applies to derived models too.
  3. Distribution Terms: Any distribution must be under this license or another with similar rules.
  4. Compliance: Non-compliance must be fixed within 30 days to avoid license termination, emphasizing transparency and adherence to open-source values.

The choice of this license aims to keep Animagine XL 3.1 open and modifiable, aligning with open source community spirit. It protects contributors and users, encouraging a collaborative, ethical open-source community. This ensures the model not only benefits from communal input but also respects open-source development freedoms.