ostris / ai-toolkit

Various AI scripts. Mostly Stable Diffusion stuff.
MIT License
3.37k stars 357 forks source link

Does ai-toolkit support training non-square images? ai-toolkit支持训练非正方形图片吗 #180

Open BigPeng opened 1 month ago

BigPeng commented 1 month ago

Does ai-toolkit support training non-square images? I don't want to crop and scale the images.

I am training flux with 7681024 images. On an A100-40G machine, 3000 steps take 2.5 hours. I set buckets=False and resolution=1024, and found that it takes the same time as training with 10241024 images. Is there any logic in the training code that will adjust the rectangular image to a square image?

ai-toolkit支持训练非正方形图片吗,我不想要裁剪和缩放图片。

我在用7681024的图片训练flux,A100-40G的机器,3000步需要2个半小时,设置了buckets=False,resolution=1024,发现跟训练输入10241024的图片需要一样的时间,是不是训练代码有什么逻辑会把长方形图片调整成正方形图片。

tetsuoo-online commented 1 month ago

yes I just did it, I had no issue. But I made my dataset images with resolutions similar to Flux or SDXL, like 768x1024, 1024x1024, 832x1216 etc, just to be safe. Maybe it's not necessary I don't know. Go to Birme website to help with that task (it's a free tool). I would put Buckets=True, as this option is especially what you need to handle non-squared images in training x)

vancyland commented 2 weeks ago

yes, no problem. Go inside ./ai-toolkit-main/toolkit/buckets.py file, edit the resolutions_1024 list and you can simply customize your resolution.