Linaqruf commited on
Commit
0cc1b53
1 Parent(s): b27a802

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +393 -0
README.md ADDED
@@ -0,0 +1,393 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: faipl-1.0-sd
4
+ license_link: https://freedevproject.org/faipl-1.0-sd/
5
+ language:
6
+ - en
7
+ tags:
8
+ - text-to-image
9
+ - stable-diffusion
10
+ - safetensors
11
+ - stable-diffusion-xl
12
+ base_model: Linaqruf/animagine-xl-2.0
13
+ widget:
14
+ - text: 1girl, green hair, sweater, looking at viewer, upper body, beanie, outdoors, night, turtleneck, masterpiece, best quality
15
+ parameter:
16
+ negative_prompt: nsfw, 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, artist name
17
+ example_title: 1girl
18
+ - text: 1boy, male focus, green hair, sweater, looking at viewer, upper body, beanie, outdoors, night, turtleneck, masterpiece, best quality
19
+ parameter:
20
+ negative_prompt: nsfw, 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, artist name
21
+ example_title: 1boy
22
+ ---
23
+
24
+ <style>
25
+ .title-container {
26
+ display: flex;
27
+ justify-content: center;
28
+ align-items: center;
29
+ height: 100vh; /* Adjust this value to position the title vertically */
30
+ }
31
+
32
+ .title {
33
+ font-size: 2.5em;
34
+ text-align: center;
35
+ color: #333;
36
+ font-family: 'Helvetica Neue', sans-serif;
37
+ text-transform: uppercase;
38
+ letter-spacing: 0.1em;
39
+ padding: 0.5em 0;
40
+ background: transparent;
41
+ }
42
+
43
+ .title span {
44
+ background: -webkit-linear-gradient(45deg, #7ed56f, #28b485);
45
+ -webkit-background-clip: text;
46
+ -webkit-text-fill-color: transparent;
47
+ }
48
+
49
+ .custom-table {
50
+ table-layout: fixed;
51
+ width: 100%;
52
+ border-collapse: collapse;
53
+ margin-top: 2em;
54
+ }
55
+
56
+ .custom-table td {
57
+ width: 50%;
58
+ vertical-align: top;
59
+ padding: 10px;
60
+ box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.15);
61
+ }
62
+
63
+ .custom-image-container {
64
+ position: relative;
65
+ width: 100%;
66
+ margin-bottom: 0em;
67
+ overflow: hidden;
68
+ border-radius: 10px;
69
+ transition: transform .7s;
70
+ /* Smooth transition for the container */
71
+ }
72
+
73
+ .custom-image-container:hover {
74
+ transform: scale(1.05);
75
+ /* Scale the container on hover */
76
+ }
77
+
78
+ .custom-image {
79
+ width: 100%;
80
+ height: auto;
81
+ object-fit: cover;
82
+ border-radius: 10px;
83
+ transition: transform .7s;
84
+ margin-bottom: 0em;
85
+ }
86
+
87
+ .nsfw-filter {
88
+ filter: blur(8px); /* Apply a blur effect */
89
+ transition: filter 0.3s ease; /* Smooth transition for the blur effect */
90
+ }
91
+
92
+ .custom-image-container:hover .nsfw-filter {
93
+ filter: none; /* Remove the blur effect on hover */
94
+ }
95
+
96
+ .overlay {
97
+ position: absolute;
98
+ bottom: 0;
99
+ left: 0;
100
+ right: 0;
101
+ color: white;
102
+ width: 100%;
103
+ height: 40%;
104
+ display: flex;
105
+ flex-direction: column;
106
+ justify-content: center;
107
+ align-items: center;
108
+ font-size: 1vw;
109
+ font-style: bold;
110
+ text-align: center;
111
+ opacity: 0;
112
+ /* Keep the text fully opaque */
113
+ background: linear-gradient(0deg, rgba(0, 0, 0, 0.8) 60%, rgba(0, 0, 0, 0) 100%);
114
+ transition: opacity .5s;
115
+ }
116
+ .custom-image-container:hover .overlay {
117
+ opacity: 1;
118
+ /* Make the overlay always visible */
119
+ }
120
+ .overlay-text {
121
+ background: linear-gradient(45deg, #7ed56f, #28b485);
122
+ -webkit-background-clip: text;
123
+ color: transparent;
124
+ /* Fallback for browsers that do not support this effect */
125
+ text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
126
+ /* Enhanced text shadow for better legibility */
127
+
128
+ .overlay-subtext {
129
+ font-size: 0.75em;
130
+ margin-top: 0.5em;
131
+ font-style: italic;
132
+ }
133
+
134
+ .overlay,
135
+ .overlay-subtext {
136
+ text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
137
+ }
138
+
139
+ </style>
140
+
141
+ <h1 class="title">
142
+ <span>Animagine XL 3.0</span>
143
+ </h1>
144
+ <table class="custom-table">
145
+ <tr>
146
+ <td>
147
+ <div class="custom-image-container">
148
+ <img class="custom-image" src="https://cdn-uploads.huggingface.co/production/uploads/6365c8dbf31ef76df4042821/ep_oy_NVSMQaU162w8Gwp.png" alt="sample1">
149
+ </div>
150
+ <div class="custom-image-container">
151
+ <img class="custom-image" src="https://cdn-uploads.huggingface.co/production/uploads/6365c8dbf31ef76df4042821/FGFZgsqrhOcor5mid5eap.png" alt="sample4">
152
+ </div>
153
+ </td>
154
+ <td>
155
+ <div class="custom-image-container">
156
+ <img class="custom-image" src="https://cdn-uploads.huggingface.co/production/uploads/6365c8dbf31ef76df4042821/EuvINvBsCKZQuspZHN-uF.png" alt="sample2">
157
+ </div>
158
+ <div class="custom-image-container">
159
+ <img class="custom-image" src="https://cdn-uploads.huggingface.co/production/uploads/6365c8dbf31ef76df4042821/yyRqdHJfePKl7ytB6ieX9.png" alt="sample3">
160
+ </td>
161
+ <td>
162
+ <div class="custom-image-container">
163
+ <img class="custom-image" src="https://cdn-uploads.huggingface.co/production/uploads/6365c8dbf31ef76df4042821/2oWmFh728T0hzEkUtSmgy.png" alt="sample1">
164
+ </div>
165
+ <div class="custom-image-container">
166
+ <img class="custom-image" src="https://cdn-uploads.huggingface.co/production/uploads/6365c8dbf31ef76df4042821/3yaZxWkUOenZSSNtGQR_3.png" alt="sample4">
167
+ </div>
168
+ </td>
169
+ </tr>
170
+ </table>
171
+
172
+ **Animagine XL 3.0** is the latest version of the sophisticated open-source anime text-to-image model, building upon the capabilities of its predecessor, Animagine XL 2.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.
173
+
174
+ ## Model Details
175
+ - **Developed by**: [Cagliostro Research Lab](https://huggingface.co/cagliostrolab)
176
+ - **Model type**: Diffusion-based text-to-image generative model
177
+ - **Model Description**: Animagine XL 3.0 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.
178
+ - **License**: [Fair AI Public License 1.0-SD](https://freedevproject.org/faipl-1.0-sd/)
179
+ - **Finetuned from model**: [Animagine XL 2.0](https://huggingface.co/Linaqruf/animagine-xl-2.0)
180
+
181
+ ## Gradio & Colab Integration
182
+
183
+ Animagine XL 3.0 is accessible through user-friendly platforms such as Gradio and Google Colab:
184
+
185
+ - **Gradio Web UI**: [Open In Spaces](https://huggingface.co/spaces/Linaqruf/Animagine-XL)
186
+ - **Google Colab**: [Open In Colab](https://colab.research.google.com/#fileId=https%3A//huggingface.co/Linaqruf/animagine-xl/blob/main/Animagine_XL_demo.ipynb)
187
+
188
+ ## 🧨 Diffusers Installation
189
+
190
+ To use Animagine XL 3.0, install the required libraries as follows:
191
+
192
+ ```bash
193
+ pip install diffusers --upgrade
194
+ pip install transformers accelerate safetensors
195
+ ```
196
+
197
+ Example script for generating images with Animagine XL 3.0:
198
+
199
+ ```python
200
+ import torch
201
+ from diffusers import (
202
+ StableDiffusionXLPipeline,
203
+ EulerAncestralDiscreteScheduler,
204
+ AutoencoderKL
205
+ )
206
+
207
+ # Load VAE component
208
+ vae = AutoencoderKL.from_pretrained(
209
+ "cagliostrolab/animagine-xl-3.0",
210
+ torch_dtype=torch.float16
211
+ )
212
+
213
+ # Configure the pipeline
214
+ pipe = StableDiffusionXLPipeline.from_pretrained(
215
+ "cagliostrolab/animagine-xl-3.0",
216
+ vae=vae,
217
+ torch_dtype=torch.float16,
218
+ use_safetensors=True,
219
+ variant="fp16"
220
+ )
221
+ pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
222
+ pipe.to('cuda')
223
+
224
+ # Define prompts and generate image
225
+ prompt = "1girl, arima kana, oshi no ko, solo, upper body, v, smile, looking at viewer, outdoors, night"
226
+ negative_prompt = "nsfw, 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, artist name"
227
+
228
+ image = pipe(
229
+ prompt,
230
+ negative_prompt=negative_prompt,
231
+ width=832,
232
+ height=1216,
233
+ guidance_scale=7,
234
+ num_inference_steps=28
235
+ ).images[0]
236
+ ```
237
+
238
+ ## Usage Guidelines
239
+
240
+ ### Tag Ordering
241
+
242
+ Prompting is a bit different in this iteration, for optimal results, it's recommended to follow the structured prompt template because we train the model like this:
243
+
244
+ ```
245
+ 1girl/1boy, character name, from what series, everything else in any order.
246
+ ```
247
+
248
+ ## Special Tags
249
+
250
+ 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.
251
+
252
+ ### Quality Modifiers
253
+
254
+ | Quality Modifier | Score Criterion |
255
+ | ---------------- | --------------- |
256
+ | `masterpiece` | >150 |
257
+ | `best quality` | 100-150 |
258
+ | `high quality` | 75-100 |
259
+ | `medium quality` | 25-75 |
260
+ | `normal quality` | 0-25 |
261
+ | `low quality` | -5-0 |
262
+ | `worst quality` | <-5 |
263
+
264
+ ### Rating Modifiers
265
+
266
+ | Rating Modifier | Rating Criterion |
267
+ | ------------------------------| ------------------------- |
268
+ | `rating: general` | General |
269
+ | `rating: sensitive` | Sensitive |
270
+ | `rating: questionable`, `nsfw`| Questionable |
271
+ | `rating: explicit`, `nsfw` | Explicit |
272
+
273
+ ### Year Modifier
274
+
275
+ These tags help to steer the result toward modern or vintage anime art styles, ranging from `newest` to `oldest`.
276
+
277
+ | Year Tag | Year Range |
278
+ | -------- | ---------------- |
279
+ | `newest` | 2022 to 2023 |
280
+ | `late` | 2019 to 2021 |
281
+ | `mid` | 2015 to 2018 |
282
+ | `early` | 2011 to 2014 |
283
+ | `oldest` | 2005 to 2010 |
284
+
285
+ ## Recommended settings
286
+
287
+ To guide the model towards generating high-aesthetic images, use negative prompts like:
288
+
289
+ ```
290
+ nsfw, 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, artist name
291
+ ```
292
+
293
+ For higher quality outcomes, prepend prompts with:
294
+
295
+ ```
296
+ masterpiece, best quality
297
+ ```
298
+
299
+ However, be careful to use `masterpiece`, `best quality` because many high-scored datasets are NSFW. It’s better to add `nsfw`, `rating: sensitive` to the negative prompt and `rating: general` to the positive prompt. 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.
300
+
301
+ ### Multi Aspect Resolution
302
+
303
+ This model supports generating images at the following dimensions:
304
+
305
+ | Dimensions | Aspect Ratio |
306
+ |-------------------|-----------------|
307
+ | `1024 x 1024` | 1:1 Square |
308
+ | `1152 x 896` | 9:7 |
309
+ | `896 x 1152` | 7:9 |
310
+ | `1216 x 832` | 19:13 |
311
+ | `832 x 1216` | 13:19 |
312
+ | `1344 x 768` | 7:4 Horizontal |
313
+ | `768 x 1344` | 4:7 Vertical |
314
+ | `1536 x 640` | 12:5 Horizontal |
315
+ | `640 x 1536` | 5:12 Vertical |
316
+
317
+ ## Training and Hyperparameters
318
+
319
+ - **Animagine XL 3.0** was trained on a 2x A100 GPU with 80GB memory for 21 days or over 500 gpu hours. The training process encompassed three stages:
320
+ - Base:
321
+ - **Feature Alignment Stage**: Utilized 1.2m images to acquaint the model with basic anime concepts.
322
+ - **Refining UNet Stage**: Employed 2.5k curated datasets to only fine-tune the UNet.
323
+ - Curated:
324
+ - **Aesthetic Tuning Stage**: Employed 3.5k high-quality curated datasets to refine the model's art style.
325
+
326
+ ### Hyperparameters
327
+
328
+ | Stage | Epochs | UNet Learning Rate | Train Text Encoder | Text Encoder Learning Rate | Batch Size | Mixed Precision | Noise Offset |
329
+ |-----------------------------|--------|--------------------|--------------------|----------------------------|----------------|-----------------|--------------|
330
+ | **Feature Alignment Stage** | 10 | 7.5e-6 | True | 3.75e-6 | 48 x 2 | fp16 | N/A |
331
+ | **Refining UNet Stage** | 10 | 2e-6 | False | N/A | 48 | fp16 | 0.0357 |
332
+ | **Aesthetic Tuning Stage** | 10 | 1e-6 | False | N/A | 48 | fp16 | 0.0357 |
333
+
334
+ ## Model Comparison
335
+
336
+ ### Training Config
337
+
338
+ | Configuration Item | Animagine XL 2.0 | Animagine 3.0 |
339
+ |-----------------------|-------------------------|-------------------------|
340
+ | **GPU** | A100 80G | 2 x A100 80G |
341
+ | **Dataset** | 170k + 83k images | 1271990 + 3500 Images |
342
+ | **Shuffle Separator** | N/A | True |
343
+ | **Global Epochs** | 20 | 20 |
344
+ | **Learning Rate** | 1e-6 | 7.5e-6 |
345
+ | **Batch Size** | 32 | 48 x 2 |
346
+ | **Train Text Encoder**| True | True |
347
+ | **Train Special Tags**| True | True |
348
+ | **Image Resolution** | 1024 | 1024 |
349
+ | **Bucket Resolution** | 2048 x 512 | 2048 x 512 |
350
+
351
+ ## Limitations
352
+
353
+ While "Animagine XL 3.0" 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.
354
+
355
+ 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.
356
+ 2. **Non-Photorealistic Design**: Animagine XL 3.0 is not designed for generating photorealistic or realistic images, focusing instead on anime-style artwork.
357
+ 3. **Anatomical Challenges**: Despite improvements, the model can still struggle with complex anatomical structures, particularly in dynamic poses, resulting in occasional inaccuracies.
358
+ 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.
359
+ 5. **Natural Language Processing**: The model is not optimized for interpreting natural language, requiring more structured and specific prompts for best results.
360
+ 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.
361
+
362
+ 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.
363
+
364
+ ## Acknowledgements
365
+
366
+ 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.
367
+
368
+ - **Main:** For the open source grant supporting our research, thank you so much.
369
+ - **Cagliostro Lab Collaborator:** For helping quality checking during pretraining and curating datasets during fine-tuning.
370
+ - **Kohya SS:** For providing the essential training script and merged our PR about `keep_tokens_separator` or Shuffle Separator.
371
+ - **Camenduru Server Community:** For invaluable insights and support and quality checking
372
+ - **NovelAI:** For inspiring how to build the datasets and label it using tag ordering.
373
+
374
+ ## Collaborators
375
+
376
+ - [Linaqruf](https://huggingface.co/Linaqruf)
377
+ - [DamarJati](https://huggingface.co/DamarJati)
378
+ - [Asahina2K](https://huggingface.co/Asahina2K)
379
+ - [ItsMeBell](https://huggingface.co/ItsMeBell)
380
+ - [Zwicky18](https://huggingface.co/Zwicky18)
381
+ - [NekoFi](https://huggingface.co/NekoFi)
382
+ - [Scipius2121](https://huggingface.co/Scipius2121)
383
+ - [Raelina](https://huggingface.co/Raelina)
384
+
385
+ ## License
386
+
387
+ Animagine XL 3.0 now uses the [Fair AI Public License 1.0-SD](https://freedevproject.org/faipl-1.0-sd/), compatible with Stable Diffusion models. Key points:
388
+ 1. **Modification Sharing:** If you modify Animagine XL 3.0, you must share both your changes and the original license.
389
+ 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.
390
+ 3. **Distribution Terms:** Any distribution must be under this license or another with similar rules.
391
+ 4. **Compliance:** Non-compliance must be fixed within 30 days to avoid license termination, emphasizing transparency and adherence to open-source values.
392
+
393
+ The choice of this license aims to keep Animagine XL 3.0 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.