But like... how? Where is that VRAM coming from? I wish I understood what actually goes into memory during finetuning that it becomes so many times the model size.
The main point of a finetune is to have it as a new base for training loras (thus retaining accuracy of the lora). Unfortunately merging loras into it doesn't work the same way.
You use prodigy not adamw, then do at least 3000. Then run it again from those resulting weights for another 3000. Then you can experiment with the d_coef and shorter steps.
I will say I have refined the Klein fast 512 run at 1024 as well with prodigy and with no negatives it takes the realism of the dataset quite well. Doing negatives breaks it though, it starts to remove that realism it learned from the image and breaks the likeness too. The new realism is actually really good, unfortunately the issues with broken hands remains. Likeness is a bit behind ZIB still but that could just be finding the right d_coef.
I think the model is really flexible. So I can definitely see how it can work really well. It takes more "learning" to achieve likeness and I don't understand why many of the common negative words interfere so heavily with the training that it ruins the image but it can get there. The main problem I was having seems to be learning rate related, ZIB just converges in less steps both with a fixed rate adaw and with prodigy. Klein has to learn the dataset so much it completely takes over its art style for it to learn a character.
That rule of thumb is very optional. It's not about your steps, more about your learning rate being low.
I don't mess with distilled models like ZIT but for ZIB/Klein 9B base I managed to get a 214 image set done well in around 3000+3000 with prodigy optimizer. First ~3000 at 512, then another run of ~3000 at 1024 resolution.
Quality matters but so does quantity. You'll get a much better model out of many images and them having differing backgrounds/angles is going to make sure your model doesn't learn some incidental associations. Also reduces the chance of any confusing image polluting the model, since it will be a smaller part of the training now.
Body likeness especially needs a lot of angles and clothes to be accurate. You'll probably get a good enough facial likeness out of 20 images or less, but it will be a bit stiff.
300 is definitely overkill though. I'd say 50-100 is a good enough amount for a good lora. It's more important that the images are varied though. 300 of pretty much the same image is still just 1.
Me having made 300 images character loras before... No, that's kind of cope because it lines up with wanting to put in less effort. Even if your dataset might have bad images, with enough learning rate the model would sort of "average them". So the result would be a consistent face, but a bit off.
You never did a model that was a combination with several characters in the dataset? If you did enough to learn the character it would just average them. So that means there wasn't enough learning to actually converge a character if you're getting inconsistent results.
Very inconsistent faces means there wasn't enough learning. Since you ran 5000 steps, it means learning rate was overall too low. I don't know what the default would be on AI toolkit, I don't use it, but just as a general rule.
Well you should adjust that by the total number of steps you intend to use.
I am still figuring out Klein myself but if you're gonna use AdamW I have no idea, depends on your learning rate. I would try to get at least 2000-3000 steps? So repeats 1, epochs 40-60? No clue what the learning rate should be though, my experiments with AdamW at 2e-4 to 4e-4 turned out pretty bad and it's not learning well enough.
Klein is a bit of a pain. Using Prodigy optimizer at d_coef 1.0 seemed to generate an okay point around 3000 steps 512 resolution. Then you can further refine that at 1024 resolution with another prodigy run on top of it (I pushed d_coef to 1.2 with this one). Might be worth testing higher d_coef in the 512 run.
Did you seriously suggest someone not use gradient checkpointing... on a "5070" which he has a 5070 Ti thankfully or else he'd be really screwed with a 5070 at 12Gb.
Another thing I notice is that your num_repeats = 1 and num_epoches=20, that’s a very inefficient way to train flux2 loras. Try repeat 10 and epoches 5, you shall get better results and way faster speed.
So instead of 20 times per image, do 50... and somehow it will be "faster speed"?
Another thing is you set batch_size = 1 in both dataset config and training, but in flux trainer, only the value in training matters. Try set it to 2, 5070 can definitely handle it, so you can half the time spend.
Also not how that works. Batch isn't just going to 2x your training speed. It may not even make a speed gain at all and just increase your vram. The speed gains from batching are generally incremental and small.
Literally this whole post has major ??? energy. What are you even talking about, do you even train?
You definitely need blocks to swap to some extend (512 res maybe 4 blocks?) on 16Gb. So remove lowvram and do that. Also why is enable bucket false? Not sure that does anything if all your images are 512x512 but why?
Yes, because at 2048 you are doing highly detailed training images at many steps so the model learns to be highly detailed from them. Doing them with smaller images means the model has to learn the concept or character and just make up the rest like you said, which leaves the poor defaults as a fallback. ZIB seems to respond a lot better to lower resolution images and just fills in the blanks but obviously higher helps.
It was a similar thing with SDXL based models, if you did like a dataset from a video game or something and it was of poorer quality. There noise perturbation helped a lot by drowning out some of those poor quality artifacts and the model wouldn't learn to be blurry as a result.
No, distilled versions don't take negatives but I don't mess with distilled anyway. I was using no negative or a giant negative wall of text I used for zimage that I got off reddit, bringing me back to SD 1.5 days lol. I'll have to refine that as well at some point.
I mean, it took a lot of refining to get there and not all checkpoints are good as a base (TAME 2.5, JibIllustrious_v30Rapture for example are good) and if you use another checkpoint it just won't work well at all. If you train on SDXL/Pony base you don't understand loras lol. Krea wasn't terrible but it wasn't perfect likeness and Flux just sucked. All loras of Flux1 I've seen from other people also sucked in likeness. I'm no expert but I think it's the fact they're distilled models. ZIB now is pushing results that are potentially above old Pony based models like TAME though.
I will say that stacking another lora for realism does improve klein's image quality by a lot, so a finetuned klein as a new base for training could be amazing. I tested other people's loras for both klein and ZIB out of curiosity (malcolm rey, he has terrible body likeness by design but I was mostly trying to see how it looked). One of them on Klein still looked pretty plastic, another looked better. His ZIB ones were not better likeness wise but they looked more realistic.
What I'm thinking is that Klein by default is so plastic and "Flux-looking" (nowhere near as bad as Flux1 is though) that if it doesn't learn realism from your dataset it doesn't actually do it at all. A finetune would be great, or I have another thing I want to test which is starting from a trained realistic lora as starting network weights (idk if that would even keep anything of the starting weights but its worth a shot). There's also clearly some lacking learning rate with my prodigy config of it at default d_coef or perhaps some timestep or noise insertion nonsense going on, not sure. It's unfortunately way more censored than ZIB which makes it do some weird body horror.
ZIB is just good. Like I refined and ran prodigy training twice in a row for a lora and the results are ridiculously good. It could still use a finetuned start but the base is quite good on its own. Considering I used a hard dataset for SDXL, it actually overtook it in likeness. Way different training times of course, but still.
Do you have any particular negatives you're using for Klein on the actual inference end?
To be clear that is a finetune of Pony or Illustrious as a base for the lora and done properly, with the correct workflow and everything. The likeness for face is way better, it's not censored and it trains like a billion times faster.
Honestly the confounding part is why Klein gives me such plasticky quality despite the better VAE if others are achieving great results out of it. The "configs" don't really exist for musubi but this is the command I used for the 11k steps with just the folder links to the models removed since that's irrelevant. Dataset was 512x512 buckets no upscale, batch 1.
I don't know if the constant was better than cosine or simply the less steps one was better overall and this ran too long and learned wrong. Cosine used to be better in SDXL so I'm sticking to it now in ZIB.
I may try OneTrainer soon, assuming it lets you use local safetensors for models and isn't another idiotic runpod advert like ai toolkit. I feel like it may be something with noise perturbation, noise offset, etc and maybe increasing the d_coef of prodigy.
Just fyi, the training config does matter quite a lot. I'm still figuring it out but for example if you're just doing AdamW8bit and guessing a learning rate you will get much worse results than with Prodigy in ZIB. There's lots of things for SDXL in good old kohya gui that were optimal like random crop, noise offset, noise perturbation, etc. It's gonna be the same for this.
Out of curiosity, why not Flux.1 Dev or Krea? Both work well for characters. They are well established, so it'd be a good trouble shooting step. If it doesn't work there, its your dataset for sure.
They do not. SDXL based models (Pony/Illustrious Realistic ones especially) work better. I'm seeing some promise in ZIB, but we need a finetune to come out (no, not merging a lora into it ffs).
I mean the shape is there but the likeness is really bad. I didn't even run it through face analyzing because it's deep in uncanny valley. It's like 80% likeness. Same with a 11k step prodigy run I ran last night, also the body likeness was bad, it gave me a super elongated body. Actually I think the likeness of the 2000 step lokr is better. I did run constant instead of cosine for that one I think? Problem with moving to musubi for these new models from kohya is I haven't figured out how to save a configuration to the lora or somewhere automatically so I forget what I did for older runs. Best I can figure is prodigy is simply falling short of the ideal learning rate and estimating it too low no matter what.
Where as SDXL based models were extreme likeness and only issue was overall quality and a tiny bit of body sameness bias.
Running the same set through zimage at 2800 steps with prodigy, regular lora not lokr and the result is really good. Good quality, skin texture is good and not plastic like every klein generation, not elongated. For a 512 resolution run that actually worked great.
Right I see, thanks. I tested prodigy lokr for 2000 steps and it's very undertrained. I will put in a 512x512 long 15000 steps prodigy run, see what happens. I don't use that ai toolkit crap, I use musubi. I also don't have the hardware to do 15000 steps at 2048 buckets lol, if zimage can work faster that would definitely a plus. It also depends which finetunes end up better as a baseline.
Maybe, I can't say how much they would alter the result. For example DMD2 for SDXL actually increased likeness when used properly for some finalizing steps. Haven't seen the point to get speed loras for image generation, but if something has a DMD2 effect that'd be interesting.
But like... how? Where is that VRAM coming from? I wish I understood what actually goes into memory during finetuning that it becomes so many times the model size.
The main point of a finetune is to have it as a new base for training loras (thus retaining accuracy of the lora). Unfortunately merging loras into it doesn't work the same way.
Does it? How much VRAM does it actually take? I thought an RTX Pro 6000 might cut it.
You use prodigy not adamw, then do at least 3000. Then run it again from those resulting weights for another 3000. Then you can experiment with the d_coef and shorter steps.
adamw8bit sucks though? On all models. Prodigy is way easier to use.
Klein is like 50% bigger so it would take more to finetune it.
I will say I have refined the Klein fast 512 run at 1024 as well with prodigy and with no negatives it takes the realism of the dataset quite well. Doing negatives breaks it though, it starts to remove that realism it learned from the image and breaks the likeness too. The new realism is actually really good, unfortunately the issues with broken hands remains. Likeness is a bit behind ZIB still but that could just be finding the right d_coef.
I think the model is really flexible. So I can definitely see how it can work really well. It takes more "learning" to achieve likeness and I don't understand why many of the common negative words interfere so heavily with the training that it ruins the image but it can get there. The main problem I was having seems to be learning rate related, ZIB just converges in less steps both with a fixed rate adaw and with prodigy. Klein has to learn the dataset so much it completely takes over its art style for it to learn a character.
That rule of thumb is very optional. It's not about your steps, more about your learning rate being low.
I don't mess with distilled models like ZIT but for ZIB/Klein 9B base I managed to get a 214 image set done well in around 3000+3000 with prodigy optimizer. First ~3000 at 512, then another run of ~3000 at 1024 resolution.
Quality matters but so does quantity. You'll get a much better model out of many images and them having differing backgrounds/angles is going to make sure your model doesn't learn some incidental associations. Also reduces the chance of any confusing image polluting the model, since it will be a smaller part of the training now.
Body likeness especially needs a lot of angles and clothes to be accurate. You'll probably get a good enough facial likeness out of 20 images or less, but it will be a bit stiff.
300 is definitely overkill though. I'd say 50-100 is a good enough amount for a good lora. It's more important that the images are varied though. 300 of pretty much the same image is still just 1.
Me having made 300 images character loras before... No, that's kind of cope because it lines up with wanting to put in less effort. Even if your dataset might have bad images, with enough learning rate the model would sort of "average them". So the result would be a consistent face, but a bit off.
You never did a model that was a combination with several characters in the dataset? If you did enough to learn the character it would just average them. So that means there wasn't enough learning to actually converge a character if you're getting inconsistent results.
Very inconsistent faces means there wasn't enough learning. Since you ran 5000 steps, it means learning rate was overall too low. I don't know what the default would be on AI toolkit, I don't use it, but just as a general rule.
Well you should adjust that by the total number of steps you intend to use.
I am still figuring out Klein myself but if you're gonna use AdamW I have no idea, depends on your learning rate. I would try to get at least 2000-3000 steps? So repeats 1, epochs 40-60? No clue what the learning rate should be though, my experiments with AdamW at 2e-4 to 4e-4 turned out pretty bad and it's not learning well enough.
Klein is a bit of a pain. Using Prodigy optimizer at d_coef 1.0 seemed to generate an okay point around 3000 steps 512 resolution. Then you can further refine that at 1024 resolution with another prodigy run on top of it (I pushed d_coef to 1.2 with this one). Might be worth testing higher d_coef in the 512 run.
Did you seriously suggest someone not use gradient checkpointing... on a "5070" which he has a 5070 Ti thankfully or else he'd be really screwed with a 5070 at 12Gb.
So instead of 20 times per image, do 50... and somehow it will be "faster speed"?
Also not how that works. Batch isn't just going to 2x your training speed. It may not even make a speed gain at all and just increase your vram. The speed gains from batching are generally incremental and small.
Literally this whole post has major ??? energy. What are you even talking about, do you even train?
You definitely need blocks to swap to some extend (512 res maybe 4 blocks?) on 16Gb. So remove lowvram and do that. Also why is enable bucket false? Not sure that does anything if all your images are 512x512 but why?
Yes, because at 2048 you are doing highly detailed training images at many steps so the model learns to be highly detailed from them. Doing them with smaller images means the model has to learn the concept or character and just make up the rest like you said, which leaves the poor defaults as a fallback. ZIB seems to respond a lot better to lower resolution images and just fills in the blanks but obviously higher helps.
It was a similar thing with SDXL based models, if you did like a dataset from a video game or something and it was of poorer quality. There noise perturbation helped a lot by drowning out some of those poor quality artifacts and the model wouldn't learn to be blurry as a result.
No, distilled versions don't take negatives but I don't mess with distilled anyway. I was using no negative or a giant negative wall of text I used for zimage that I got off reddit, bringing me back to SD 1.5 days lol. I'll have to refine that as well at some point.
I mean, it took a lot of refining to get there and not all checkpoints are good as a base (TAME 2.5, JibIllustrious_v30Rapture for example are good) and if you use another checkpoint it just won't work well at all. If you train on SDXL/Pony base you don't understand loras lol. Krea wasn't terrible but it wasn't perfect likeness and Flux just sucked. All loras of Flux1 I've seen from other people also sucked in likeness. I'm no expert but I think it's the fact they're distilled models. ZIB now is pushing results that are potentially above old Pony based models like TAME though.
I will say that stacking another lora for realism does improve klein's image quality by a lot, so a finetuned klein as a new base for training could be amazing. I tested other people's loras for both klein and ZIB out of curiosity (malcolm rey, he has terrible body likeness by design but I was mostly trying to see how it looked). One of them on Klein still looked pretty plastic, another looked better. His ZIB ones were not better likeness wise but they looked more realistic.
What I'm thinking is that Klein by default is so plastic and "Flux-looking" (nowhere near as bad as Flux1 is though) that if it doesn't learn realism from your dataset it doesn't actually do it at all. A finetune would be great, or I have another thing I want to test which is starting from a trained realistic lora as starting network weights (idk if that would even keep anything of the starting weights but its worth a shot). There's also clearly some lacking learning rate with my prodigy config of it at default d_coef or perhaps some timestep or noise insertion nonsense going on, not sure. It's unfortunately way more censored than ZIB which makes it do some weird body horror.
ZIB is just good. Like I refined and ran prodigy training twice in a row for a lora and the results are ridiculously good. It could still use a finetuned start but the base is quite good on its own. Considering I used a hard dataset for SDXL, it actually overtook it in likeness. Way different training times of course, but still.
Do you have any particular negatives you're using for Klein on the actual inference end?
To be clear that is a finetune of Pony or Illustrious as a base for the lora and done properly, with the correct workflow and everything. The likeness for face is way better, it's not censored and it trains like a billion times faster.
Honestly the confounding part is why Klein gives me such plasticky quality despite the better VAE if others are achieving great results out of it. The "configs" don't really exist for musubi but this is the command I used for the 11k steps with just the folder links to the models removed since that's irrelevant. Dataset was 512x512 buckets no upscale, batch 1.
--sdpa --mixed_precision bf16 --timestep_sampling flux2_shift --weighting_scheme none --optimizer_type="prodigyopt.Prodigy" --optimizer_args "weight_decay=0.05" "betas=(0.9,0.99)" "safeguard_warmup=True" "use_bias_correction=False" --lr_scheduler="cosine" --learning_rate 1.0 --gradient_checkpointing --max_data_loader_n_workers 2 --persistent_data_loader_workers --network_module networks.lora_flux_2 --network_dim 32 --max_train_epochs 110 --save_every_n_epochs 10 --seed 0 --fp8_base --fp8_scaled --fp8_text_encoder
I don't know if the constant was better than cosine or simply the less steps one was better overall and this ran too long and learned wrong. Cosine used to be better in SDXL so I'm sticking to it now in ZIB.
I may try OneTrainer soon, assuming it lets you use local safetensors for models and isn't another idiotic runpod advert like ai toolkit. I feel like it may be something with noise perturbation, noise offset, etc and maybe increasing the d_coef of prodigy.
Those are able to get perfect facial likeness pretty much. Flux1Dev or Krea are always just a bit off. Plus censored. Plus take way longer to train.
Just fyi, the training config does matter quite a lot. I'm still figuring it out but for example if you're just doing AdamW8bit and guessing a learning rate you will get much worse results than with Prodigy in ZIB. There's lots of things for SDXL in good old kohya gui that were optimal like random crop, noise offset, noise perturbation, etc. It's gonna be the same for this.
They do not. SDXL based models (Pony/Illustrious Realistic ones especially) work better. I'm seeing some promise in ZIB, but we need a finetune to come out (no, not merging a lora into it ffs).
I mean the shape is there but the likeness is really bad. I didn't even run it through face analyzing because it's deep in uncanny valley. It's like 80% likeness. Same with a 11k step prodigy run I ran last night, also the body likeness was bad, it gave me a super elongated body. Actually I think the likeness of the 2000 step lokr is better. I did run constant instead of cosine for that one I think? Problem with moving to musubi for these new models from kohya is I haven't figured out how to save a configuration to the lora or somewhere automatically so I forget what I did for older runs. Best I can figure is prodigy is simply falling short of the ideal learning rate and estimating it too low no matter what.
Where as SDXL based models were extreme likeness and only issue was overall quality and a tiny bit of body sameness bias.
Running the same set through zimage at 2800 steps with prodigy, regular lora not lokr and the result is really good. Good quality, skin texture is good and not plastic like every klein generation, not elongated. For a 512 resolution run that actually worked great.
Right I see, thanks. I tested prodigy lokr for 2000 steps and it's very undertrained. I will put in a 512x512 long 15000 steps prodigy run, see what happens. I don't use that ai toolkit crap, I use musubi. I also don't have the hardware to do 15000 steps at 2048 buckets lol, if zimage can work faster that would definitely a plus. It also depends which finetunes end up better as a baseline.
Maybe, I can't say how much they would alter the result. For example DMD2 for SDXL actually increased likeness when used properly for some finalizing steps. Haven't seen the point to get speed loras for image generation, but if something has a DMD2 effect that'd be interesting.