Text-to-Image
Diffusers
Safetensors
English
StableDiffusionXLPipeline
art
Inference Endpoints
KBlueLeaf commited on
Commit
206f5af
1 Parent(s): 3f69a66

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +202 -0
README.md CHANGED
@@ -2,4 +2,206 @@
2
  license: other
3
  license_name: fair-ai-public-license-1.0-sd
4
  license_link: https://freedevproject.org/faipl-1.0-sd/
 
 
 
 
 
 
 
 
 
5
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: other
3
  license_name: fair-ai-public-license-1.0-sd
4
  license_link: https://freedevproject.org/faipl-1.0-sd/
5
+ datasets:
6
+ - KBlueLeaf/danbooru2023-webp-4Mpixel
7
+ - KBlueLeaf/danbooru2023-sqlite
8
+ language:
9
+ - en
10
+ library_name: diffusers
11
+ pipeline_tag: text-to-image
12
+ tags:
13
+ - art
14
  ---
15
+
16
+ # Kohaku XL εpsilon
17
+ ***The best example of tuning t2i model at home with consumer-level hardware***
18
+
19
+ ### join us: https://discord.gg/tPBsKDyRR5
20
+
21
+ ---
22
+
23
+ ![banner](https://i.imgur.com/AuSMuRE.png)
24
+
25
+ ## Introduction
26
+ Kohaku XL Epsilon, the fifth major iteration in the Kohaku XL series, features a 5.2 million images dataset, LyCORIS fine-tuning[1], trained on comsumer-level hardware, and is fully open-sourced.
27
+
28
+ ## Benchmark
29
+ CCIP score on 3600 characters
30
+ (0~1, higher is better)
31
+ ![image](https://hackmd.io/_uploads/SJZY0kFgR.png)
32
+ Clearly, Kohaku XL Epsilon is way better than Kohaku XL Delta
33
+
34
+
35
+ ## Usage
36
+ ```
37
+ <1girl/1boy/1other/...>,
38
+ <character>, <series>, <artists>,
39
+
40
+ <general tags>,
41
+ <quality tags>, <year tags>, <meta tags>, <rating tags>
42
+ ```
43
+
44
+ **Kohaku XL Epsilon has mastered more artists' styles then Delta. But it also increases the stablility when combining multiple artist tags together. Users are encouraged to make their own style prompts.**
45
+
46
+ **Some good style prompts**
47
+ ```
48
+ ask \(askzy\), torino aqua, migolu, (jiu ye sang:1.1), (rumoon:0.9), (mizumi zumi:1.1)
49
+ ```
50
+ ```
51
+ ciloranko, maccha \(mochancc\), lobelia \(saclia\), migolu,
52
+ ask \(askzy\), wanke, (jiu ye sang:1.1), (rumoon:0.9), (mizumi zumi:1.1)
53
+ ```
54
+ ```
55
+ shiro9jira, ciloranko, ask \(askzy\), (tianliang duohe fangdongye:0.8)
56
+ ```
57
+ ```
58
+ (azuuru:1.1), (torino aqua:1.2), (azuuru:1.1), kedama milk,
59
+ fuzichoco, ask \(askzy\), chen bin, atdan, hito, mignon
60
+ ```
61
+ ```
62
+ ask \(askzy\), torino aqua, migolu
63
+ ```
64
+
65
+
66
+ #### Tags
67
+ All the danbooru tags with at least 1000 popularity should work.
68
+ All the danbooru tags with at least 100 popularity can possibly work with high emphasis.
69
+
70
+ Remember to remove all the underscore in tags. (Underscores in short tags are not be removed, which are very likely part of emoji tags.)
71
+ Remember to use `xxx\(yyy\)`when tag have bracket and you are using sd-webui.
72
+
73
+ ### Special Tags
74
+ - **Quality tag**s: masterpiece, best quality, great quality, good quality, normal quality, low quality, worst quality
75
+ - **Rating tags**: safe, sensitive, nsfw, explicit
76
+ - **Date tags**: newest, recent, mid, early, old
77
+
78
+ **Quality Tags**
79
+ Quality tags are assigned based on the percentile rankings of the favorite count (fav_count) within each rating category to avoid bias on nsfw content (Animagine XL v3 have met this problem), organized from high to low as follows: ***90th, 75th, 60th, 45th, 30th, and 10th percentiles***. This creates seven distinct quality levels separated by six thresholds.
80
+
81
+ I lower the threshold since I found that the average quality of images in Danbooru is higher than I expected.
82
+
83
+ **Rating tags**
84
+ * **General**: safe
85
+ * **Sensitive**: sensitive
86
+ * **Questionable**: nsfw
87
+ * **Explicit**: nsfw, explicit
88
+
89
+ Note: During training, content tagged as "explicit" is also considered under "nsfw" to ensure a comprehensive understanding.
90
+
91
+ **Date tags**
92
+ Date tags are based on the upload dates of the images, as the metadata does not include the actual creation dates.
93
+ The periods are categorized as follows:
94
+ * 2005~2010: old
95
+ * 2011~2014: early
96
+ * 2015~2017: mid
97
+ * 2018~2020: recent
98
+ * 2021~2024: newest
99
+
100
+
101
+ ### Resolution
102
+ This model is trained for resolutions from ARB 1024x1024 with minimum resolution 256 and maximum resolution 4096. This means you can use the standard SDXL resolution. However, opting for a slightly higher resolution than 1024x1024 is recommended. Applying a hires-fix is also suggested for better results.
103
+
104
+ For more information, please check out the sample images provided.
105
+
106
+
107
+
108
+ ## How This Model Came to Be
109
+
110
+ ### Why Epsilon
111
+ Same as Delta, just a test for new dataset and it is good.
112
+ The outputs are also very different (compare to Delta).
113
+
114
+ ### Dataset
115
+ The dataset for training this model was sourced from [HakuBooru](https://github.com/KohakuBlueleaf/HakuBooru), comprising 5.2 million images selected from the [danbooru2023](https://huggingface.co/datasets/KBlueLeaf/danbooru2023-webp-4Mpixel) dataset.[2][3]
116
+
117
+ A selection process was employed to choose ***1 million posts from IDs 0 to 2,000,000***, another ***2 millions from IDs 2,000,000 to 4,999,999***, and ***all posts after ID 5,000,000***, totaling 5.35 million posts. After filtering out deleted posts, gold account posts and those without images (which could be GIFs or MP4s), the final dataset comprised 5.2 million images.
118
+
119
+ The selection was essentially random, but a fixed seed was utilized to ensure reproducibility.
120
+
121
+ **Further Process**
122
+ * **Shuffle tags**: The order of general tags was shuffled in each step.
123
+ * **Tag dropout**: Randomly, ***15%*** of general tags were dropped in each step.
124
+
125
+ ### Training
126
+
127
+ The training of Kohaku XL Epsilon was facilitated by the [LyCORIS](https://github.com/KohakuBlueleaf/LyCORIS) project and the trainer from [kohya-ss/sd-scripts](https://github.com/kohya-ss/sd-scripts). [1][4]
128
+
129
+ **Algorithm: LoKr**[5]
130
+ The model was trained using the LoKr algorithm with full matrix triggered and a factor of 2~8 for different modules. The aim was to demonstrate the applicability of LoRA/LyCORIS in training base models.
131
+
132
+ The original LoKr file size is under 800MB, and the TE was not frozen. The original LoKr file also be provided as "delta-lokr" version.
133
+
134
+ For detailed settings, refer to the LyCORIS config file from Kohaku XL Delta.
135
+
136
+ **Other Training Details**
137
+ - **Hardware**: Quad RTX 3090s
138
+ - **Num Train Images**: 5,210,319
139
+ - **Batch Size**: 4
140
+ - **Grad Accumulation Step**: 16
141
+ - **Equivalent Batch Size**: 256
142
+ - **Total Epoch**: 1
143
+ - **Total Steps**: 20354
144
+ - **Optimizer**: Lion8bit
145
+ - **Learning Rate**: 2e-5 for UNet / 5e-6 for TE
146
+ - **LR Scheduler**: Constant (with warmup)
147
+ - **Warmup Steps**: 1000
148
+ - **Weight Decay**: 0.1
149
+ - **Betas**: 0.9, 0.95
150
+ - **Min SNR Gamma**: 5
151
+ - **Noise Offset**: 0.0357
152
+ - **Resolution**: 1024x1024
153
+ - **Min Bucket Resolution**: 256
154
+ - **Max Bucket Resolution**: 4096
155
+ - **Mixed Precision**: FP16
156
+
157
+ **Warning**: Versions 0.36.0~0.41.0 of bitsandbytes have significant [bugs](https://github.com/TimDettmers/bitsandbytes/issues/659) in the 8bit optimizer that could compromise training, so updating is essential.[6]
158
+
159
+ **Training Cost**
160
+ Utilizing DDP with four RTX 3090s, completing 1 epoch across the 5.2 million image dataset took approximately 12 to 13 days. Each step for an equivalent batch size of 256 took about 49 to 50 seconds to complete.
161
+
162
+ ### Why I publish 13600step intermediate ckpt
163
+ The training progress have crashed when between 13600step~15300step. And kohya-ss trainer didn't implement resume+step skip before.
164
+
165
+ Although Kohya and I figured out how to do it correctly and did some sanity check on it. I still cannot fully ensure the final result is correct. So I publish the final intermedate ckpt so if anyone want to reproduce the training. They have chance to figure out the problem of final result.
166
+
167
+ ## What's Next
168
+ I am focusing on making new dataset (targeting 10M~15M images), and wait for SD3 to see if it is worth trying.
169
+
170
+ I may also do some small FT on Epsilon and publish them as rev2/3/4... but dataset still my main focus now.
171
+
172
+
173
+ ## Special Thanks
174
+ AngelBottomless & Nyanko7: danbooru2023 dataset[3]
175
+ Kohya-ss: Trainer[4]
176
+
177
+
178
+ ---
179
+
180
+ ***AI art should be looked like AI, not like humans.***
181
+
182
+ ---
183
+
184
+ *(Some fun fact: this slogan come from my personal homepage. Lot of ppl like this one and put it in their model page.)*
185
+
186
+ ## Reference & Resource
187
+
188
+ ### Reference
189
+ [1] **SHIH-YING YEH**, Yu-Guan Hsieh, Zhidong Gao, Bernard B W Yang, Giyeong Oh, & Yanmin Gong (2024). Navigating Text-To-Image Customization: From LyCORIS Fine-Tuning to Model Evaluation. In The Twelfth International Conference on Learning Representations.
190
+
191
+ [2] HakuBooru - text-image dataset maker for booru style image platform. https://github.com/KohakuBlueleaf/HakuBooru
192
+
193
+ [3] Danbooru2023: A Large-Scale Crowdsourced and Tagged Anime Illustration Dataset. https://huggingface.co/datasets/nyanko7/danbooru2023
194
+
195
+ [4] kohya-ss/sd-scripts. https://github.com/kohya-ss/sd-scripts
196
+
197
+ [5] LyCORIS - Lora beYond Conventional methods, Other Rank adaptation Implementations for Stable diffusion. https://github.com/KohakuBlueleaf/LyCORIS/blob/main/docs/Algo-Details.md#lokr
198
+
199
+ [6] TimDettmers/bitsandbytes - issue 659/152/227/262 - Wrong indented lines cause bugs for a long time. https://github.com/TimDettmers/bitsandbytes/issues/659
200
+
201
+ ### Resource
202
+ * Kohaku XL beta. https://civitai.com/models/162577/kohaku-xl-beta
203
+ * Kohaku XL gamma. https://civitai.com/models/270291/kohaku-xl-gamma
204
+ * Kohaku XL delta. https://civitai.com/models/332076/kohaku-xl-delta
205
+
206
+ ## License
207
+ **This model is licensed under "Fair-AI public license 1.0-SD", please refer to the original License for more information: https://freedevproject.org/faipl-1.0-sd/**