r/StableDiffusion • • 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.

5 Upvotes

40 comments sorted by

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.

1

u/johntheguyperson1 3d ago

Do you think it would even need two epochs? I was kind of thinking 1 pass over each image would gather up the style pretty pretty well gathered over so many images. But not sure.

I've never used Fizgig, do you think it's better than ai-tookit?

1

u/No_Drag8242 3d ago edited 3d ago

I think Fizgig is better yes, I used ai-toolkit before and still use it on runpod but on my local PC I prefer Fizgig. For a style I wouldn't do two epochs as it might begin picking up subjects and setting from the images too strongly in addition to the style. For a concept I think two is acceptable as you want some details to stick in the weights. The low LR others have mentioned may make two epochs safer but perhaps unnecessary still. Idk.

0

u/hurrdurrimanaccount 2d ago

fizgig is fully vibecoded to the max and is inherently wack

1

u/No_Drag8242 2d ago

I don't inherently distrust vibecoded apps. Fizgig works well for me.

3

u/JayoTree 3d ago

That might take weeks on a 4090

4

u/no_witty_username 3d ago

nah 20k on Korea 2 on a 4090 at 768 is around 1.5 sec per step.. it takes like 12 hours i think.. the long part is image and text cashing...that shit takes hours for such a data set but once it gets going like 8 hours of training 1 epoch or whatever

1

u/johntheguyperson1 1d ago

I did it at 1024 and it took around 4-6 sec per step.

1

u/no_witty_username 1d ago

off top of my head that looks wrong. i would expect a 50% jump at most on the 1024 so something might be off, though thats just a hunch as ive not run at 1024. one way you can verify is running a small test at 768 and see if you getting the 1.5 - 1.6 sec/step... if not then something in your setup is wonky if you are also running on a 4090

4

u/No_Drag8242 3d ago

It won't. I am training on 1600 images right now, and get 1.6s/it on a 4090 and I am not using all my VRAM (19.5gb). My 10 epochs are going to take 6'ish hours. Working with 0.5mp.

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/johntheguyperson1 3d ago

Ok I'm going down a path you've already tread it seems. What captioning model did you use? I've been messing around with using Gemma and its vision model locally. Seems to give better results than qwen3-vl-8b-instruct-abliterated. But I use ai-toolkit to train and its not supported there.

Basically I captioned them all with with the qwen model and now I'm thinking about recaptioning them all with gemma before I waist time training.

Have you messed with lokr vs lora? As far as I know you want to use lora on styles and lokr is better at character but I haven't tested any of that.

2

u/no_witty_username 3d ago

I tried many vllms and Gemma 26b 4b moe was best imo. The heretic version qat 4q is what I used. I turned thinking off for speed but you can get slightly better performance with thinking on but at 2x slower speed. I don't think its worth the tradeoff. reason I like this model is the uncensored version can be prompted very well, it will describe anything and with grungy language if you want for nsfw stuff. way better then joycaption models. I tried me all Lora, Dora, whatever... a simple Lora was fine as I saw no benefit to the other variants. but that was on my data set.. a lot of this I strongly recommend lots of experimentation and iteration with Claude, neon or whatever to save a lot of your own time... I used to do all this manually by hand a few years a go and by god never again....

1

u/Left_Success422 3d ago

Could you please share the prompt for Gemma 26b that you use?

1

u/No_Drag8242 3d ago edited 3d ago

LFM3-VL-2B

Super fast, very capable. Doesn't mind spicy captions. I'm very impressed by LFM3 models in general. This one creates hundreds of captions in seconds. Don't know how they did it with such a tiny model but it works. Much better than Gemma for sure. You might need to steer it to mention spicy stuff accurately as it uses vague speech by default.

Had to use ChatGPT to hook it up to my own photo crop captioning app but ChatGPT can create a comfy UI node for you no problem.

1

u/johntheguyperson1 3d ago

Did you do 1 epoch or what do you think?

I'm kind of trying to relearn how to train good loras. I had a good recipe back in the SD1 days but things have changed lol.

1

u/no_witty_username 3d ago

yes 1 epoch was enough, I've done up to 4 but you might run in to issues at higher epochs and have to be careful also have to lower Lora strength at inference even more at more epochs.

1

u/johntheguyperson1 3d ago

Do you train on windows native or within wsl?

1

u/no_witty_username 3d ago

linux on my machine. tough i have trained on windows before for large image set loras. i reccomend getting of windows though all ai work is just better on linux

1

u/johntheguyperson1 1d ago

I would if I didn't game as well. 100% I would be using ubuntu.

One question I had and I know I'm spreading them out across different threads here, but how do you select the best checkpoint?
I have 9 of them from 2800 and then every 1600 steps onward, and I've done about 6 grids with the lora at 2 strength so I can tell what its actually changing from the base model (certain prompts the base model was already good at show nothing at 1 strength). I have a hard time determining which one should be the 'official' one. It seems like different checkpoints are better on some prompts and worse at others. Wish there was an objective best.

2

u/No_Drag8242 3d ago

Can't you just use adaptive LR?

2

u/no_witty_username 3d ago

not for such a large data set. the lr for prodigy goes up first n steps and never comes done... that will fry the Lora for such large data sets. so I use Adam dw with low lr like 0.00005 or lower with some other safeguards.. I also have gradient watcher script that watches spikes and restarts from earlier checkpoints if things get iffy

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/johntheguyperson1 3d ago

Idk. I've done it before with really slow learning on a lot of images and seemed to be the best lora I've ever made.

1

u/LawfulnessLow0 3d ago

Can you say what kind of style it is?
I've trained - lemme check - exactly 35 Styles for Krea2 now (and about 50 characters), and multiple times that for SD and SDXL, and the highest I ever went was like 2k images but just bc I couldn't be bothered to prune the set.

Most styles are 100-200 samples.

My suggestion would be to do 100 hand-picked, then 400 images and see if the 4x makes a big difference.

OTOH, doing 16k is a cool experiment - I've thought about doing all my styles inside 1 lora :)

1

u/hurrdurrimanaccount 2d ago

16k for a single style is completely overkill. especially if you say "mediocre captions". you'd get a better result with 100 amazing captions.

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/johntheguyperson1 1d ago

See but sometimes you want a little blur and such in your dataset. I think the bigger thing is maybe figuring out an objective way to figure out which checkpoint is best. I have 10 of them now after training and I don't know way other than brute forcing with grids and prompts to find the best checkpoint to be the 'official' one for this lora. Like I'd honestly say its either my 3rd or 9th one. Which is weird. You'd think it would be a middle one or the end one. I suppose when its training on 16k images in a random order certain concepts get randomly more important or less important throughout the training when it only sees each image once.

1

u/Ill-Ant-9489 1d ago

Keeping some soft shots is fair, variety beats a sterile set, and the scoring ranks rather than force-deletes so you keep the ones you want. The checkpoint pick is the part I'd stop brute-forcing though. The test studio in the thing I built (https://github.com/perfectgf/lora-dataset-studio) renders the epochs you choose on one fixed seed with the same prompt batch, so only the checkpoint changes, then you vote and it ranks them by Wilson score, plus face similarity if it's a character. And 3rd or 9th beating the last epoch is normal, loss doesn't track identity.

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.

1

u/johntheguyperson1 3d ago

With 16000 images doing 1 pass per image I find that it doesn't overlearn anything as bad as style loras with 400 images. The problem I run into is image captioning models tend to be pretty shit at small details (partially because of the resolution and partially because they don't know specific things because they weren't trained on them). Like trying to get accurate jewelry details is giving me a struggle right now.

1

u/Upper-Reflection7997 3d ago

You have to use the latest SOTA models. Of course you do have to review the Captions models spit out. The small local open source under 30B models aren't really smart getting accurate descriptions about images. Your better off using Gemini or a heretic abliteration version of deepseek v4.1.

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/johntheguyperson1 1d ago

I think moss is better at following instructions, but worse at photorealism. Which makes sense because it has a bigger text encoder and smaller image model as far as parameters go. So it feels like it listens better, but its realism is worse.

1

u/ellipsesmrk 1d ago

What?!?! Nah dude. It handles amateur, professional, candid, street photography so much better than any other model. Even ideogram. I'll post some t2i images here in a bit.

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.