Asahina2K commited on
Commit
f612a15
1 Parent(s): 46cf819

Update README.md

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