animagine-xl-2.0 / README.md
Linaqruf's picture
Update README.md
044e028
|
raw
history blame
No virus
16.6 kB
metadata
library_name: diffusers
license: openrail++
language:
  - en
tags:
  - text-to-image
  - stable-diffusion
  - safetensors
  - stable-diffusion-xl
base_model: stabilityai/stable-diffusion-xl-base-1.0
widget:
  - text: >-
      face focus, cute, masterpiece, best quality, 1girl, green hair, sweater,
      looking at viewer, upper body, beanie, outdoors, night, turtleneck
    parameter:
      negative_prompt: >-
        lowres, bad anatomy, bad hands, text, error, missing fingers, extra
        digit, fewer digits, cropped, worst quality, low quality, normal
        quality, jpeg artifacts, signature, watermark, username, blurry
    output:
      url: >-
        https://cdn-uploads.huggingface.co/production/uploads/6365c8dbf31ef76df4042821/cR_r0k0CSapphAaFrkN1h.png
    example_title: 1girl
  - text: >-
      face focus, bishounen, masterpiece, best quality, 1boy, green hair,
      sweater, looking at viewer, upper body, beanie, outdoors, night,
      turtleneck
    parameter:
      negative_prompt: >-
        lowres, bad anatomy, bad hands, text, error, missing fingers, extra
        digit, fewer digits, cropped, worst quality, low quality, normal
        quality, jpeg artifacts, signature, watermark, username, blurry
    output:
      url: >-
        https://cdn-uploads.huggingface.co/production/uploads/6365c8dbf31ef76df4042821/EteXoZZN4SwlkqfbPpNak.png
    example_title: 1boy

Animagine XL 2.0

sample1
sample4
sample2
sample3
sample1
sample4

Overview

Animagine XL 2.0 represents the cutting-edge in latent text-to-image diffusion models, specializing in the generation of high-resolution, aesthetically rich, and detailed anime images. This model emerges as an enhancement over its predecessor, Animagine XL 1.0, by incorporating advancements from the Stable Diffusion XL 1.0. Its unique fine-tuning process, leveraging a comprehensive anime-style image dataset, enables Animagine XL 2.0 to adeptly capture the myriad styles inherent in anime art, significantly elevating both image quality and artistic expression.

Model Details

  • Developed by: Linaqruf
  • Model type: Diffusion-based text-to-image generative model
  • Model Description: This is a model that excels in creating detailed and high-quality anime images from text descriptions. It's fine-tuned to understand and interpret a wide range of descriptive prompts, turning them into stunning visual art.
  • License: CreativeML Open RAIL++-M License
  • Finetuned from model: Stable Diffusion XL 1.0

LoRA Collection

Gradio & Colab Integration

Animagine XL is accessible via Gradio Web UI and Google Colab, offering user-friendly interfaces for image generation:

  • Gradio Web UI: Open In Spaces
  • Google Colab: Open In Colab

🧨 Diffusers Installation

Ensure the installation of the latest diffusers library, along with other essential packages:

pip install diffusers --upgrade
pip install transformers accelerate safetensors

The following Python script demonstrates how to do inference with Animagine XL 2.0. The default scheduler in the model config is EulerAncestralDiscreteScheduler, but it can be explicitly defined for clarity.

import torch
from diffusers import (
    StableDiffusionXLPipeline, 
    EulerAncestralDiscreteScheduler,
    AutoencoderKL
)

# Load VAE component
vae = AutoencoderKL.from_pretrained(
    "madebyollin/sdxl-vae-fp16-fix", 
    torch_dtype=torch.float16
)

# Configure the pipeline
pipe = StableDiffusionXLPipeline.from_pretrained(
    "Linaqruf/animagine-xl-2.0", 
    vae=vae,
    torch_dtype=torch.float16, 
    use_safetensors=True, 
    variant="fp16"
)
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
pipe.to('cuda')

# Define prompts and generate image
prompt = "face focus, cute, masterpiece, best quality, 1girl, green hair, sweater, looking at viewer, upper body, beanie, outdoors, night, turtleneck"
negative_prompt = "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry"

image = pipe(
    prompt, 
    negative_prompt=negative_prompt, 
    width=1024,
    height=1024,
    guidance_scale=12,
    num_inference_steps=50
).images[0]

Usage Guidelines

Prompt Guidelines

Animagine XL 2.0 responds effectively to natural language descriptions for image generation. For example:

A girl with mesmerizing blue eyes looks at the viewer. Her long, white hair is adorned with blue butterfly hair ornaments.

However, to achieve optimal results, it's recommended to use Danbooru-style tagging in your prompts, as the model is trained with images labeled using these tags. For instance:

1girl, green hair, sweater, looking at viewer, upper body, beanie, outdoors, night, turtleneck

This model incorporates quality and rating modifiers during dataset processing, influencing image generation based on specified criteria:

Quality Modifiers

Quality Modifier Score Criterion
masterpiece >150
best quality 100-150
high quality 75-100
medium quality 25-75
normal quality 0-25
low quality -5-0
worst quality <-5

Rating Modifiers

Rating Modifier Rating Criterion
- general
- sensitive
nsfw questionable
nsfw explicit

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

lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry

For higher quality outcomes, prepend prompts with:

masterpiece, best quality

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 was trained on a 1x A100 GPU with 80GB memory. The training process encompassed two stages:
    • Feature Alignment Stage: Utilized 170k images to acquaint the model with basic anime concepts.
    • Aesthetic Tuning Stage: Employed 83k high-quality synthetic datasets to refine the model's art style.

Hyperparameters

  • Global Epochs: 20
  • Learning Rate: 1e-6
  • Batch Size: 32
  • Train Text Encoder: True
  • Image Resolution: 1024 (2048 x 512)
  • Mixed-Precision: fp16

Note: The model's training configuration is subject to future enhancements.

Direct Use

The Animagine XL 2.0 model, with its advanced text-to-image diffusion capabilities, is highly versatile and can be applied in various fields:

  • Art and Design: This model is a powerful tool for artists and designers, enabling the creation of unique and high-quality anime-style artworks. It can serve as a source of inspiration and a means to enhance creative processes.
  • Education: In educational contexts, Animagine XL 2.0 can be used to develop engaging visual content, assisting in teaching concepts related to art, technology, and media.
  • Entertainment and Media: The model's ability to generate detailed anime images makes it ideal for use in animation, graphic novels, and other media production, offering a new avenue for storytelling.
  • Research: Academics and researchers can leverage Animagine XL 2.0 to explore the frontiers of AI-driven art generation, study the intricacies of generative models, and assess the model's capabilities and limitations.
  • Personal Use: Anime enthusiasts can use Animagine XL 2.0 to bring their imaginative concepts to life, creating personalized artwork based on their favorite genres and styles.

Limitations

The Animagine XL 2.0 model, while advanced in its capabilities, has certain limitations that users should be aware of:

  • Style Bias: The model exhibits a bias towards a specific art style, as it was fine-tuned using approximately 80,000 images with a similar aesthetic. This may limit the diversity in the styles of generated images.
  • Rendering Challenges: There are occasional inaccuracies in rendering hands or feet, which may not always be depicted with high fidelity.
  • Realism Constraint: Animagine XL 2.0 is not designed for generating realistic images, given its focus on anime-style content.
  • Natural Language Limitations: The model may not perform optimally when prompted with natural language descriptions, as it is tailored more towards anime-specific terminologies and styles.
  • Dataset Scope: Currently, the model is primarily effective in generating content related to the 'Honkai' series and 'Genshin Impact' due to the dataset's scope. Expansion to include more diverse concepts is planned for future iterations.
  • NSFW Content Generation: The model is not proficient in generating NSFW content, as it was not a focus during the training process, aligning with the intention to promote safe and appropriate content generation.

Acknowledgements

We extend our gratitude to:

  • Chai AI: For the open-source grant (Chai AI) supporting our research.
  • Kohya SS: For providing the essential training script.
  • Camenduru Server Community: For invaluable insights and support.
  • NovelAI: For inspiring the Quality Tags feature.
  • Waifu DIffusion Team: for inspiring the optimal training pipeline with bigger datasets.
  • Shadow Lilac: For the image classification model (Hugging Face - shadowlilac/aesthetic-shadow) crucial in our quality assessment process.