k4d3
/

English
Not-For-All-Audiences
k4d3 commited on
Commit
806ca56
β€’
1 Parent(s): b96a922

Signed-off-by: Balazs Horvath <acsipont@gmail.com>

README.md CHANGED
@@ -30,17 +30,18 @@ The Yiff Toolkit is a comprehensive set of tools designed to enhance your creati
30
  - [Pony Training](#pony-training)
31
  - [Download Pony in Diffusers Format](#download-pony-in-diffusers-format)
32
  - [Sample Prompt File](#sample-prompt-file)
33
- - [`--lowram`](#--lowram)
34
- - [`--pretrained_model_name_or_path`](#--pretrained_model_name_or_path)
35
- - [`--output_dir`](#--output_dir)
36
- - [`--train_data_dir`](#--train_data_dir)
37
- - [`--resolution`](#--resolution)
38
- - [`--enable_bucket`](#--enable_bucket)
39
- - [`--min_bucket_reso` and `--max_bucket_reso`](#--min_bucket_reso-and---max_bucket_reso)
40
- - [`--optimizer_type`](#--optimizer_type)
41
- - [`--dataset_repeats`](#--dataset_repeats)
42
- - [`--max_train_steps`](#--max_train_steps)
43
- - [`--shuffle_caption`](#--shuffle_caption)
 
44
  - [`--sdpa` or `--xformers` or `--mem_eff_attn`](#--sdpa-or---xformers-or---mem_eff_attn)
45
  - [`--sample_prompts` and `--sample_sampler` and `--sample_every_n_steps`](#--sample_prompts-and---sample_sampler-and---sample_every_n_steps)
46
  - [CosXL Training](#cosxl-training)
@@ -141,18 +142,24 @@ A sample prompt file is used during training to sample images. A sample prompt f
141
 
142
  ```py
143
  # anthro female kindred
144
- score_9, score_8_up, score_7_up, score_6_up, rating_explicit, source_furry, solo, female anthro kindred presenting, white pillow, bedroom, looking at viewer, detailed background, amazing_background, scenery porn, realistic, photo, photo (medium), photography (artwork) --n blurry, blurred background, simple background, low quality, worst quality --w 1024 --h 1024 --d 1 --l 6.0 --s 40
145
  # anthro female wolf
146
- score_9, score_8_up, score_7_up, score_6_up, rating_explicit, source_furry, solo, anthro female wolf, sexy pose, standing, gray fur, brown fur, canine pussy, black nose, presenting pussy, blue eyes, pink areola, pink nipples, detailed background, amazing_background, scenery porn, realistic, photo, photo (medium), photography (artwork) --n low quality, worst quality --w 1024 --h 1024 --d 1 --l 6.0 --s 40
147
- # anthro male fox
148
- score_9, score_8_up, score_7_up, score_6_up, rating_explicit, source_furry, solo, anthro male fox, glowing yellow eyes, night, crescent moon, tibetan necklace, gold bracers, blue and gold adorned loincloth, canine genitalia, knot, amazing_background, scenery porn, white marble ruins in the background, realistic, photo, photo (medium), photography (artwork) --n low quality, worst quality --w 1024 --h 1024 --d 1 --l 6.0 --s 40
149
  ```
150
 
151
- #### `--lowram`
 
 
 
 
 
 
152
 
153
  If you are running running out of RAM like I do with 2 GPUs and a really fat model, this option will help you save a bit of it and might get you out of OOM hell.
154
 
155
- #### `--pretrained_model_name_or_path`
 
 
156
 
157
  The directory containing the checkpoint you just downloaded. I recommend closing the path if you are using a local model with a `/`.
158
 
@@ -160,7 +167,9 @@ The directory containing the checkpoint you just downloaded. I recommend closing
160
  --pretrained_model_name_or_path="/ponydiffusers/" \
161
  ```
162
 
163
- #### `--output_dir`
 
 
164
 
165
  This is where all the saved epochs or steps will be saved, including the last one. If y
166
 
@@ -168,7 +177,9 @@ This is where all the saved epochs or steps will be saved, including the last on
168
  --output_dir="/output_dir" \
169
  ```
170
 
171
- #### `--train_data_dir`
 
 
172
 
173
  The directory containing the dataset. We prepared this earlier together.
174
 
@@ -176,7 +187,9 @@ The directory containing the dataset. We prepared this earlier together.
176
  --train_data_dir="/training_dir" \
177
  ```
178
 
179
- #### `--resolution`
 
 
180
 
181
  Always set this to match the model's resolution, which in Pony's case it is 1024x1024. If you can't fit into the VRAM, you can decrease it to `512,512` as a last resort.
182
 
@@ -184,7 +197,9 @@ Always set this to match the model's resolution, which in Pony's case it is 1024
184
  --resolution="1024,1024" \
185
  ```
186
 
187
- #### `--enable_bucket`
 
 
188
 
189
  ⚠️
190
 
@@ -192,7 +207,9 @@ Always set this to match the model's resolution, which in Pony's case it is 1024
192
  --enable_bucket \
193
  ```
194
 
195
- #### `--min_bucket_reso` and `--max_bucket_reso`
 
 
196
 
197
  ⚠️
198
 
@@ -201,15 +218,19 @@ Always set this to match the model's resolution, which in Pony's case it is 1024
201
  --max_bucket_reso=1024 \
202
  ```
203
 
204
- #### `--optimizer_type`
 
 
205
 
206
- The default optimizer is `AdamW` and there are a bunch of them added every month or so, therefore I'm not listing it. You can find the list if you really want. But `AdamW` is the best as of this writing so we use that!
207
 
208
  ```py
209
  --optimizer_type="AdamW" \
210
  ```
211
 
212
- #### `--dataset_repeats`
 
 
213
 
214
  Repeats the dataset when training with captions, by default it is set to `1` so we'll set this to `0` with:
215
 
@@ -217,7 +238,9 @@ Repeats the dataset when training with captions, by default it is set to `1` so
217
  --dataset_repeats=0 \
218
  ```
219
 
220
- #### `--max_train_steps`
 
 
221
 
222
  Specify the number of steps or epochs to train. If both `--max_train_steps` and `--max_train_epochs` are specified, the number of epochs takes precedence.
223
 
@@ -225,7 +248,9 @@ Specify the number of steps or epochs to train. If both `--max_train_steps` and
225
  --max_train_steps=500 \
226
  ```
227
 
228
- #### `--shuffle_caption`
 
 
229
 
230
  Shuffles the captions set by `--caption_separator`, it is a comma `,` by default which will work perfectly for our case since our captions look like this:
231
 
@@ -233,6 +258,10 @@ Shuffles the captions set by `--caption_separator`, it is a comma `,` by default
233
 
234
  As you can tell, I have separated the caption part not just the tags with a `,` to make sure everything gets shuffled. I'm at this point pretty certain this is beneficial especially when your caption file contains more than 77 tokens.
235
 
 
 
 
 
236
  #### `--sdpa` or `--xformers` or `--mem_eff_attn`
237
 
238
  The choice between `--xformers` or `--mem_eff_attn` and `--spda` will depend on your GPU. You can benchmark it by repeating a training with them!
 
30
  - [Pony Training](#pony-training)
31
  - [Download Pony in Diffusers Format](#download-pony-in-diffusers-format)
32
  - [Sample Prompt File](#sample-prompt-file)
33
+ - [Training Commands](#training-commands)
34
+ - [`--lowram`](#--lowram)
35
+ - [`--pretrained_model_name_or_path`](#--pretrained_model_name_or_path)
36
+ - [`--output_dir`](#--output_dir)
37
+ - [`--train_data_dir`](#--train_data_dir)
38
+ - [`--resolution`](#--resolution)
39
+ - [`--enable_bucket`](#--enable_bucket)
40
+ - [`--min_bucket_reso` and `--max_bucket_reso`](#--min_bucket_reso-and---max_bucket_reso)
41
+ - [`--optimizer_type`](#--optimizer_type)
42
+ - [`--dataset_repeats`](#--dataset_repeats)
43
+ - [`--max_train_steps`](#--max_train_steps)
44
+ - [`--shuffle_caption`](#--shuffle_caption)
45
  - [`--sdpa` or `--xformers` or `--mem_eff_attn`](#--sdpa-or---xformers-or---mem_eff_attn)
46
  - [`--sample_prompts` and `--sample_sampler` and `--sample_every_n_steps`](#--sample_prompts-and---sample_sampler-and---sample_every_n_steps)
47
  - [CosXL Training](#cosxl-training)
 
142
 
143
  ```py
144
  # anthro female kindred
145
+ score_9, score_8_up, score_7_up, score_6_up, rating_explicit, source_furry, solo, female anthro kindred presenting, white pillow, bedroom, looking at viewer, detailed background, amazing_background, scenery porn, realistic, photo --n low quality, worst quality, blurred background, blurry, simple background --w 1024 --h 1024 --d 1 --l 6.0 --s 40
146
  # anthro female wolf
147
+ score_9, score_8_up, score_7_up, score_6_up, rating_explicit, source_furry, solo, anthro female wolf, sexy pose, standing, gray fur, brown fur, canine pussy, black nose, blue eyes, pink areola, pink nipples, detailed background, amazing_background, realistic, photo --n low quality, worst quality, blurred background, blurry, simple background --w 1024 --h 1024 --d 1 --l 6.0 --s 40
 
 
148
  ```
149
 
150
+ Please note that sample prompts should not exceed 77 tokens, you can use
151
+
152
+ ---
153
+
154
+ #### Training Commands
155
+
156
+ ##### `--lowram`
157
 
158
  If you are running running out of RAM like I do with 2 GPUs and a really fat model, this option will help you save a bit of it and might get you out of OOM hell.
159
 
160
+ ---
161
+
162
+ ##### `--pretrained_model_name_or_path`
163
 
164
  The directory containing the checkpoint you just downloaded. I recommend closing the path if you are using a local model with a `/`.
165
 
 
167
  --pretrained_model_name_or_path="/ponydiffusers/" \
168
  ```
169
 
170
+ ---
171
+
172
+ ##### `--output_dir`
173
 
174
  This is where all the saved epochs or steps will be saved, including the last one. If y
175
 
 
177
  --output_dir="/output_dir" \
178
  ```
179
 
180
+ ---
181
+
182
+ ##### `--train_data_dir`
183
 
184
  The directory containing the dataset. We prepared this earlier together.
185
 
 
187
  --train_data_dir="/training_dir" \
188
  ```
189
 
190
+ ---
191
+
192
+ ##### `--resolution`
193
 
194
  Always set this to match the model's resolution, which in Pony's case it is 1024x1024. If you can't fit into the VRAM, you can decrease it to `512,512` as a last resort.
195
 
 
197
  --resolution="1024,1024" \
198
  ```
199
 
200
+ ---
201
+
202
+ ##### `--enable_bucket`
203
 
204
  ⚠️
205
 
 
207
  --enable_bucket \
208
  ```
209
 
210
+ ---
211
+
212
+ ##### `--min_bucket_reso` and `--max_bucket_reso`
213
 
214
  ⚠️
215
 
 
218
  --max_bucket_reso=1024 \
219
  ```
220
 
221
+ ---
222
+
223
+ ##### `--optimizer_type`
224
 
225
+ The default optimizer is `AdamW` and there are a bunch of them added every month or so, therefore I'm not listing them all, you can find the list if you really want, but `AdamW` is the best as of this writing so we use that!
226
 
227
  ```py
228
  --optimizer_type="AdamW" \
229
  ```
230
 
231
+ ---
232
+
233
+ ##### `--dataset_repeats`
234
 
235
  Repeats the dataset when training with captions, by default it is set to `1` so we'll set this to `0` with:
236
 
 
238
  --dataset_repeats=0 \
239
  ```
240
 
241
+ ---
242
+
243
+ ##### `--max_train_steps`
244
 
245
  Specify the number of steps or epochs to train. If both `--max_train_steps` and `--max_train_epochs` are specified, the number of epochs takes precedence.
246
 
 
248
  --max_train_steps=500 \
249
  ```
250
 
251
+ ---
252
+
253
+ ##### `--shuffle_caption`
254
 
255
  Shuffles the captions set by `--caption_separator`, it is a comma `,` by default which will work perfectly for our case since our captions look like this:
256
 
 
258
 
259
  As you can tell, I have separated the caption part not just the tags with a `,` to make sure everything gets shuffled. I'm at this point pretty certain this is beneficial especially when your caption file contains more than 77 tokens.
260
 
261
+ NOTE: `--cache_text_encoder_outputs` and `--cache_text_encoder_outputs_to_disk` can't be used together with `--shuffle_caption`. Both of these aim to reduce VRAM usage, you will need to decide between these yourself!
262
+
263
+ ---
264
+
265
  #### `--sdpa` or `--xformers` or `--mem_eff_attn`
266
 
267
  The choice between `--xformers` or `--mem_eff_attn` and `--spda` will depend on your GPU. You can benchmark it by repeating a training with them!
dataset_tools/Count Tokens in Sample Prompts.ipynb ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 4,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "data": {
10
+ "text/html": [
11
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-style: italic\"> Prompt Analysis </span>\n",
12
+ "┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓\n",
13
+ "┃<span style=\"font-weight: bold\"> Prompt Type </span>┃<span style=\"font-weight: bold\"> Prompt </span>┃<span style=\"font-weight: bold\"> Token Count </span>┃\n",
14
+ "┑━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩\n",
15
+ "β”‚ Positive β”‚ score_9, score_8_up, score_7_up, score_6_up, rating_explicit, source_furry, solo, β”‚ 57 β”‚\n",
16
+ "β”‚ β”‚ female anthro kindred presenting, white pillow, bedroom, looking at viewer, β”‚ β”‚\n",
17
+ "β”‚ β”‚ detailed background, amazing_background, scenery porn, realistic, photo β”‚ β”‚\n",
18
+ "β”‚ Negative β”‚ low quality, worst quality, blurred background, blurry, simple background β”‚ 13 β”‚\n",
19
+ "β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜\n",
20
+ "</pre>\n"
21
+ ],
22
+ "text/plain": [
23
+ "\u001b[3m Prompt Analysis \u001b[0m\n",
24
+ "┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓\n",
25
+ "┃\u001b[1m \u001b[0m\u001b[1mPrompt Type\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mPrompt \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mToken Count\u001b[0m\u001b[1m \u001b[0m┃\n",
26
+ "┑━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩\n",
27
+ "β”‚ Positive β”‚ score_9, score_8_up, score_7_up, score_6_up, rating_explicit, source_furry, solo, β”‚ 57 β”‚\n",
28
+ "β”‚ β”‚ female anthro kindred presenting, white pillow, bedroom, looking at viewer, β”‚ β”‚\n",
29
+ "β”‚ β”‚ detailed background, amazing_background, scenery porn, realistic, photo β”‚ β”‚\n",
30
+ "β”‚ Negative β”‚ low quality, worst quality, blurred background, blurry, simple background β”‚ 13 β”‚\n",
31
+ "β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜\n"
32
+ ]
33
+ },
34
+ "metadata": {},
35
+ "output_type": "display_data"
36
+ },
37
+ {
38
+ "data": {
39
+ "text/html": [
40
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-style: italic\"> Prompt Analysis </span>\n",
41
+ "┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓\n",
42
+ "┃<span style=\"font-weight: bold\"> Prompt Type </span>┃<span style=\"font-weight: bold\"> Prompt </span>┃<span style=\"font-weight: bold\"> Token Count </span>┃\n",
43
+ "┑━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩\n",
44
+ "β”‚ Positive β”‚ score_9, score_8_up, score_7_up, score_6_up, rating_explicit, source_furry, solo, β”‚ 70 β”‚\n",
45
+ "β”‚ β”‚ anthro female wolf, sexy pose, standing, gray fur, brown fur, canine pussy, black β”‚ β”‚\n",
46
+ "β”‚ β”‚ nose, blue eyes, pink areola, pink nipples, detailed background, β”‚ β”‚\n",
47
+ "β”‚ β”‚ amazing_background, realistic, photo β”‚ β”‚\n",
48
+ "β”‚ Negative β”‚ low quality, worst quality, blurred background, blurry, simple background β”‚ 13 β”‚\n",
49
+ "β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜\n",
50
+ "</pre>\n"
51
+ ],
52
+ "text/plain": [
53
+ "\u001b[3m Prompt Analysis \u001b[0m\n",
54
+ "┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓\n",
55
+ "┃\u001b[1m \u001b[0m\u001b[1mPrompt Type\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mPrompt \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mToken Count\u001b[0m\u001b[1m \u001b[0m┃\n",
56
+ "┑━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩\n",
57
+ "β”‚ Positive β”‚ score_9, score_8_up, score_7_up, score_6_up, rating_explicit, source_furry, solo, β”‚ 70 β”‚\n",
58
+ "β”‚ β”‚ anthro female wolf, sexy pose, standing, gray fur, brown fur, canine pussy, black β”‚ β”‚\n",
59
+ "β”‚ β”‚ nose, blue eyes, pink areola, pink nipples, detailed background, β”‚ β”‚\n",
60
+ "β”‚ β”‚ amazing_background, realistic, photo β”‚ β”‚\n",
61
+ "β”‚ Negative β”‚ low quality, worst quality, blurred background, blurry, simple background β”‚ 13 β”‚\n",
62
+ "β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜\n"
63
+ ]
64
+ },
65
+ "metadata": {},
66
+ "output_type": "display_data"
67
+ },
68
+ {
69
+ "data": {
70
+ "text/html": [
71
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-style: italic\"> Prompt Analysis </span>\n",
72
+ "┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓\n",
73
+ "┃<span style=\"font-weight: bold\"> Prompt Type </span>┃<span style=\"font-weight: bold\"> Prompt </span>┃<span style=\"font-weight: bold\"> Token Count </span>┃\n",
74
+ "┑━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩\n",
75
+ "β”‚ Positive β”‚ score_9, score_8_up, score_7_up, score_6_up, rating_explicit, source_furry, solo, β”‚ 73 β”‚\n",
76
+ "β”‚ β”‚ anthro male fox, glowing yellow eyes, night, crescent moon, gold bracers and β”‚ β”‚\n",
77
+ "β”‚ β”‚ necklace, loincloth, canine genitalia, knot, amazing_background, scenery porn, β”‚ β”‚\n",
78
+ "β”‚ β”‚ white marble ruins, realistic, photo β”‚ β”‚\n",
79
+ "β”‚ Negative β”‚ low quality, worst quality, blurred background, blurry, simple background β”‚ 13 β”‚\n",
80
+ "β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜\n",
81
+ "</pre>\n"
82
+ ],
83
+ "text/plain": [
84
+ "\u001b[3m Prompt Analysis \u001b[0m\n",
85
+ "┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓\n",
86
+ "┃\u001b[1m \u001b[0m\u001b[1mPrompt Type\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mPrompt \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mToken Count\u001b[0m\u001b[1m \u001b[0m┃\n",
87
+ "┑━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩\n",
88
+ "β”‚ Positive β”‚ score_9, score_8_up, score_7_up, score_6_up, rating_explicit, source_furry, solo, β”‚ 73 β”‚\n",
89
+ "β”‚ β”‚ anthro male fox, glowing yellow eyes, night, crescent moon, gold bracers and β”‚ β”‚\n",
90
+ "β”‚ β”‚ necklace, loincloth, canine genitalia, knot, amazing_background, scenery porn, β”‚ β”‚\n",
91
+ "β”‚ β”‚ white marble ruins, realistic, photo β”‚ β”‚\n",
92
+ "β”‚ Negative β”‚ low quality, worst quality, blurred background, blurry, simple background β”‚ 13 β”‚\n",
93
+ "β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜\n"
94
+ ]
95
+ },
96
+ "metadata": {},
97
+ "output_type": "display_data"
98
+ },
99
+ {
100
+ "data": {
101
+ "text/html": [
102
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-style: italic\"> Prompt Analysis </span>\n",
103
+ "┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓\n",
104
+ "┃<span style=\"font-weight: bold\"> Prompt Type </span>┃<span style=\"font-weight: bold\"> Prompt </span>┃<span style=\"font-weight: bold\"> Token Count </span>┃\n",
105
+ "┑━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩\n",
106
+ "β”‚ Positive οΏ½οΏ½οΏ½ score_9, score_8_up, score_7_up, score_6_up, rating_safe, source_furry, solo, β”‚ 74 β”‚\n",
107
+ "β”‚ β”‚ full-length portrait, anthro female red panda, detailed background, β”‚ β”‚\n",
108
+ "β”‚ β”‚ amazing_background, pussy, scenery porn, photo, realistic, looking at viewer, on β”‚ β”‚\n",
109
+ "β”‚ β”‚ back, sexy pose, humanoid hands, claws, pink areola, pink nipples β”‚ β”‚\n",
110
+ "β”‚ Negative β”‚ low quality, worst quality, blurred background, blurry, simple background β”‚ 13 β”‚\n",
111
+ "β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜\n",
112
+ "</pre>\n"
113
+ ],
114
+ "text/plain": [
115
+ "\u001b[3m Prompt Analysis \u001b[0m\n",
116
+ "┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┓\n",
117
+ "┃\u001b[1m \u001b[0m\u001b[1mPrompt Type\u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mPrompt \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mToken Count\u001b[0m\u001b[1m \u001b[0m┃\n",
118
+ "┑━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━┩\n",
119
+ "β”‚ Positive β”‚ score_9, score_8_up, score_7_up, score_6_up, rating_safe, source_furry, solo, β”‚ 74 β”‚\n",
120
+ "β”‚ β”‚ full-length portrait, anthro female red panda, detailed background, β”‚ β”‚\n",
121
+ "β”‚ β”‚ amazing_background, pussy, scenery porn, photo, realistic, looking at viewer, on β”‚ β”‚\n",
122
+ "β”‚ β”‚ back, sexy pose, humanoid hands, claws, pink areola, pink nipples β”‚ β”‚\n",
123
+ "β”‚ Negative β”‚ low quality, worst quality, blurred background, blurry, simple background β”‚ 13 β”‚\n",
124
+ "β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜\n"
125
+ ]
126
+ },
127
+ "metadata": {},
128
+ "output_type": "display_data"
129
+ }
130
+ ],
131
+ "source": [
132
+ "import tiktoken\n",
133
+ "from rich.console import Console\n",
134
+ "from rich.table import Table\n",
135
+ "\n",
136
+ "def count_tokens(text):\n",
137
+ " enc = tiktoken.get_encoding(\"cl100k_base\")\n",
138
+ " tokens = enc.encode(text)\n",
139
+ " return len(tokens)\n",
140
+ "\n",
141
+ "console = Console()\n",
142
+ "\n",
143
+ "with open(\"C:\\\\Users\\\\kade\\\\Desktop\\\\training_dir_staging\\\\sample-prompts.txt\", \"r\") as file:\n",
144
+ " lines = file.readlines()\n",
145
+ "\n",
146
+ "for line in lines:\n",
147
+ " if line.startswith(\"#\"):\n",
148
+ " continue\n",
149
+ "\n",
150
+ " parts = line.split(\"--n\")\n",
151
+ " positive_prompt = parts[0].strip()\n",
152
+ " negative_prompt = parts[1].strip().split(\" --\")[0]\n",
153
+ "\n",
154
+ " positive_token_count = count_tokens(positive_prompt)\n",
155
+ " negative_token_count = count_tokens(negative_prompt)\n",
156
+ "\n",
157
+ " table = Table(title=\"Prompt Analysis\")\n",
158
+ " table.add_column(\"Prompt Type\", justify=\"left\")\n",
159
+ " table.add_column(\"Prompt\", justify=\"left\")\n",
160
+ " table.add_column(\"Token Count\", justify=\"right\")\n",
161
+ "\n",
162
+ " table.add_row(\"Positive\", positive_prompt, str(positive_token_count))\n",
163
+ " table.add_row(\"Negative\", negative_prompt, str(negative_token_count))\n",
164
+ "\n",
165
+ " console.print(table)\n",
166
+ "\n",
167
+ " if positive_token_count > 77:\n",
168
+ " console.print(f\"[bold red]Warning: Positive prompt token count exceeds 75.[/bold red]\")"
169
+ ]
170
+ }
171
+ ],
172
+ "metadata": {
173
+ "kernelspec": {
174
+ "display_name": "base",
175
+ "language": "python",
176
+ "name": "python3"
177
+ },
178
+ "language_info": {
179
+ "codemirror_mode": {
180
+ "name": "ipython",
181
+ "version": 3
182
+ },
183
+ "file_extension": ".py",
184
+ "mimetype": "text/x-python",
185
+ "name": "python",
186
+ "nbconvert_exporter": "python",
187
+ "pygments_lexer": "ipython3",
188
+ "version": "3.12.2"
189
+ }
190
+ },
191
+ "nbformat": 4,
192
+ "nbformat_minor": 2
193
+ }