File size: 5,100 Bytes
3142da9
 
44101d7
 
 
 
 
 
 
 
 
3142da9
44973a7
44101d7
 
 
 
0dbe0c8
44101d7
 
 
 
 
 
 
0dbe0c8
44101d7
0dbe0c8
44101d7
 
 
 
0dbe0c8
 
44101d7
 
 
 
 
 
2e02758
 
 
 
 
 
 
 
 
 
 
 
c2ef5a0
 
2e02758
0dbe0c8
2e02758
0dbe0c8
2e02758
0dbe0c8
5280ffd
 
b7c0002
 
 
 
12bdaba
 
d94e421
 
 
 
 
 
 
5280ffd
 
 
 
 
 
 
 
44973a7
5280ffd
44973a7
5280ffd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0dbe0c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e2ae672
 
0dbe0c8
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
license: apache-2.0
tags:
- anime
- diffusion
- text-to-image
- image-generation
library_name: diffusers
pipeline_tag: text-to-image
language:
- en
---
![Aniimage-2 Samples](https://huggingface.co/8BitStudio/Aniimage-2/resolve/main/assets/collage.png)

# Aniimage-2

Aniimage-2 is the second public model in the Aniimage series.
The model is a 512x512 anime image generation model trained from scratch using a UNet + VAE + CLIP architecture with 441.9 million parameters.
Aniimage-2 has been trained on 1.2M anime images from [Danbooru](https://danbooru.donmai.us/) and other sources.
It is not based on any existing models, the UNet is trained from scratch.

## Model Details

| | |
|---|---|
| **Resolution** | 512x512 |
| **Architecture** | Latent Diffusion (UNet + VAE + CLIP) |
| **Parameters** | 441.9M |
| **Training Steps** | 70,000 |
| **Batch Size** | 64 |
| **Dataset** | ~1.2 million curated anime images from Danbooru |
| **GPU** | NVIDIA RTX 5060 Ti 16GB |
| **Scheduler** | DPM++ SDE |
| **Step count** | 50 using DPM++ SDE|

## Requirements

- **GPU**: ~6 GB VRAM minimum (recommend 8+ GB)
- **CPU**: ~7 GB RAM. Image generation is extremely slow on CPU. (recommend 10+ GB)

## Prompting

Aniimage uses plain text captions as well as Danbooru tags.

An example of acceptable captions:

"A smiling anime girl with red hair and a school uniform"

"1girl, solo, smile, red_hair, school_uniform, anime_coloring"

Long prompts and enhanced prompts usually result in worse overall results. Try to keep your prompts short.

Although you can use Danbooru tags, you will get the best results with plain text captions

Adding a negative prompt is required for a good output. The one used during inference in the preview image is
"low quality, ugly, blurry, distorted, deformed, bad anatomy, bad proportions, extra limbs, missing limbs, watermark, text, signature, washed out, flat colors, manga panel, disfigured, poorly drawn, jpeg artifacts, cropped, out of frame"

For the best quality, use DPM++ SDE at 50 steps.

**Important:** If you do not include “NSFW” in the negative prompt, the model may generate NSFW images


## Run

[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/#fileId=https://huggingface.co/8BitStudio/Aniimage-2/blob/main/Aniimage_2_Interactive_Colab.ipynb)

[![Download Generator](https://img.shields.io/badge/Download-generate__images.py-blue?style=for-the-badge)](https://huggingface.co/8BitStudio/Aniimage-2/resolve/main/generate_images.py)

after downloading, install the dependencies.

```bash
pip install torch torchvision diffusers transformers safetensors pillow huggingface_hub
python generate_hf.py
```

## Capabilities

Aniimage-2 has significantly higher capabilities than [Aniimage-1](https://huggingface.co/8BitStudio/Aniimage-1). Especially when it comes to backgrounds.

<table width="700">
  <tr>
    <td colspan="2">
      <img
        src="https://huggingface.co/8BitStudio/Aniimage-2/resolve/main/assets/Softly%20lit%20forest%20at%20midday%2C%20peaceful%20atmosphere%2C%20no%20people.png"
        width="700"
        alt="Forest comparison between Aniimage-1 and Aniimage-2"
      >
    </td>
  </tr>

  <tr>
    <td align="center" width="50%">
      <b>Aniimage-1</b>
    </td>
    <td align="center" width="50%">
      <b>Aniimage-2</b>
    </td>
  </tr>

  <tr>
    <td colspan="2">
      <sub>Prompt: Softly lit forest at midday, peaceful atmosphere, no people.</sub>
    </td>
  </tr>
</table>

<table width="700">
  <tr>
    <td colspan="2">
      <img
        src="https://huggingface.co/8BitStudio/Aniimage-2/resolve/main/assets/anime-boy.png"
        width="700"
        alt="Anime boy comparison between Aniimage-1 and Aniimage-2"
      >
    </td>
  </tr>

  <tr>
    <td align="center" width="50%">
      <b>Aniimage-1</b>
    </td>
    <td align="center" width="50%">
      <b>Aniimage-2</b>
    </td>
  </tr>

Aniimage-2 produces male characters much more reliably than Aniimage-1.

  <tr>
    <td colspan="2">
      <sub>Prompt: An anime boy with black hair and green eyes.</sub>
    </td>
  </tr>
</table>

## Limitations

Aniimage-2 is bad at generating hands. It may generate hands but they often melt into surfaces if they are similar colors and usually have more or fewer than five fingers.
The model generates male characters less reliably than female characters, it may take many images to find a good image like above.

## What's Next

Aniimage-3 is currently in the works and will have a much higher parameter count: 738.1M parameters compared to aniimage-2 and aniimage-1's 441.9M parameters.
The model will also have 1.5 million unique images, 25% more than the 1.2 million Aniimage-2 has.
Aniimage-2 used incorrect Min-SNR loss weighting with its v-prediction objective, causing near-pure-noise timesteps to receive excessive emphasis. This has been corrected for Aniimage-3.
Aniimage-3 also uses a much higher-quality dataset with improved filtering. More than 100,000 low-quality images from the Aniimage-2 dataset were removed.


## License

Apache 2.0