r/StableDiffusion • u/johntheguyperson1 • 3d ago
Question - Help Training with 16k Images
Ok, so I've done this before with a LoRa on SDXL and the results were decent, but times have changed and better models have come out so I was wondering what the best method of using my dataset to impact a model would be. Most of the time when I see people talking about training a lora they have a dataset of around 400 images at most. I've spent the last 14 hours captioning these ones so I now have a large dataset with (mediocre) captions and I'm wondering how best to proceed.
I'd like to train Krea2 as I feel its the best photorealistic model right now (seems to have better image results than MOS even though its prompt adherence seems to be a bit lower).
I would appreciate any and all training tips. I have a 4090 that I use when training locally and I use RunPod when I can't fit something on my local machine.
2
u/No_Drag8242 3d ago
Well you want to make a high rank LORA, 128 (Network DIM, Network Alpha) probably to fit all that image data. With 16k images 2 epochs are probably enough (32k steps). Other than that.. just start training on Fizgig.
But idk, there are people with far more knowledge than me.
3
u/JayoTree 3d ago
That might take weeks on a 4090
2
u/no_witty_username 3d ago
On krea 2 ive trained up to 22k images so far no issues. Works amazingly well but you have to use a low lr such as 0.00005. for best results during inferance you will have to lower the strength of the Lora to about 0.5 or .75. I am a big fan of training large loras as if done right results are great. But good captions and proper setup is very important as you are in deep territory when doing so many images and its easy to fuck up if not done right.
1
u/LawfulnessLow0 3d ago
No way do you need 16k for just a style. This would have to contain many different characters, styles and concepts to make it worth the effort. You can train a style with 50 pics, and a few 100 is more than enough.
1
u/Ill-Ant-9489 2d ago
Most of the overkill replies are right, but the catch is you can't eyeball 16k to find the good 1.5k. What actually improved my results was scoring the whole pool, grouping near-dupes, and cutting the blurry or low-detail frames before captioning anything. Mediocre captions across 16k hurt more than a tight set with careful ones. That big-folder sort and prune is the reason I built LoRA Dataset Studio (mine, so grain of salt), it scores, flags dupes and junk, and builds a balanced shortlist, then the Krea2 recipe hands off to ai-toolkit the way you're already doing. https://github.com/perfectgf/lora-dataset-studio
1
u/Upper-Reflection7997 3d ago
Better make sure you captioning images properly op. That's going to matter alot when training loras and checkpoint fine-tuning for krea2. 16,000 images is an overkill in my opinion but I'm just more into characters than concepts and styles.
2
u/StableLlama 3d ago
My training is going up to 700+ images, nearly double of your quote but lot less than the total number you are aiming for.
Generally use a trainer that is known to handle such large projects, like SimpleTuner.
For such large projects you might want to do multi GPU training to save time. (n GPUs make the training nearly n times faster; and when you are renting and paying per GPU hour it doesn't make much difference in renting one GPU for 2 hours or 1 GPUs for 1 hour).
Also for such a large project the data handling and storage are something to think about. Especially when training in the cloud you don't want to pay expensive GPU time for the phase when you are uploading 16k images with an old 56k modem. Amazon S3 or Cloudflare R2 (a few gigs for free) can be very handy here.
Then, for large scale training it is important to bump up the batch size as you don't want that each image is fighting with what the optimizer has learned with the last images. A high batch size relates to a high VRAM requirement, so I fear that the 4090 doesn't help here (but it's great to check the intermediate results!).
Similar effects to a large batch size is to use multiple GPUs (see above) and use gradient accumulation. Perhaps you want to use all three options as the same time as they multiply their effect.
Doing that gives you also the advantage to raise the learning rate. Some say that you can raise it linearly (LR = LR_for_single_batch * batch_size), other think the theory says that the square root is more appropriate (LR = LR_for_single_batch * sqrt(batch_size)) - I have done well with the sqrt approach.
You didn't write about it in your post, but I think I read it in the comments that you are trying to train a style. With those I have no experience, but I can imagine that it can work to show images only a few times to the trainer. With my training of clothing and characters (my 700+ image training is training about 30 concepts, mainly different garments) the rule of thumb that every image must be shown about 100 times to the trainer holds. That means that I need to train for about 70k steps (using a single GPU).
The good thing about Krea 2: it trains very well and does hardly overtrain. But that also means that you don't want to stop training early, as every new epoch is making the result still better.
This also leads to the fact that you want a strict measure about your training progress. Loss has never worked for me, that's very little signal for much noise. Using eval (should be described in https://github.com/bghira/SimpleTuner/blob/main/documentation/evaluation/EVAL_LOSS.md - but GitHub is currently broken and doesn't show the content for me to check) is much better, and I can have eval images for ground truth (i.e. how much of the model is being destroyed by the training) as well as eval for the concept to learn. (And for multiple concepts I can have one eval per concepts, so I can see whether my training data is balanced).
And next to any numbers, testing with many different prompts is crucial to learn quickly where you need refinement, to stop the huge training early, fix it, and restart it. This is where your 4090 will shine.
Everything else should be like normal training. For captions to make it universal I'd use multicaptioning. I.e. each image has a few captions and the trainer is randomly selecting one. This can be done easily by using multiple different AIs for auto captioning as each one has a different style. Or giving it different instructions.
As a good caption is exactly like what a user would use as a prompt to generate exactly this image you'll have lots of different caption styles that should be supported.
A style LoRA might be allowed to bend the model, a character or clothing LoRA must not. So it's perhaps not so relevant to use a clear trigger word and also use regularization images. For a high quality training I think those are very relevant - but I don't know how that translates to the style type.
0
u/ellipsesmrk 3d ago
Im the other side. I feel like moss gives me better results.
1
u/Ok-Republic764 3d ago
What is it a dataset of? What do you want to teach the model? Did you use a vlm for captions?
1
u/Enshitification 3d ago edited 3d ago
With a dataset that large, you might consider a finetune instead of a LoRA. You can always extract a LoRA afterwards. Fizgig can do Krea2 finetunes with as low as a 16GB card. With 24GB, it will run faster. The finetune preset LR is 3e-5, but if that is too hot, you can restart the training at 1e-5. It should run around 0.85 seconds per step on a 4090.
1
u/zwischenwelt 3d ago
Well the biggest question is if your dataset also has a lot of different concepts or if its just a few concepts with just many samples. A large dataset doesnt automatically mean you need a huge LORA for it.
If its only a few concepts but with a large variety of samples you will be fine using a smaller lora, but if your 20k images contain like 100 or 200 concepts then you are entering the territory where a full finetune could even make sense... Really depends.
Edit: Also DO NOT use adaptive learning rate for this size of a dataset - just go with good old adamW with a low learningrate like 2.5e-5
0
u/Spoonman915 3d ago
I haven't messed with datasets that large, just around 200 myself, but Fizgigs is a good package and his walkthrough videos are easy to follow. There's also Ostris, which is another good one.
I found fizgigs a little more intuitive, but both are solid.