kohya-ss / sd-scripts

Apache License 2.0
4.93k stars 825 forks source link

Question about resample #1089

Open dill-shower opened 7 months ago

dill-shower commented 7 months ago

Can we just change

https://github.com/kohya-ss/sd-scripts/blob/cd19df49cd512e13ac90db115c424d19c0e8868a/library/train_util.py#L2209

To _cv2.INTERLANCZOS4 on this line in this file so that the lanczos4 algorithm is used to downscale the size of the training images?

feffy380 commented 7 months ago

Why? Lanczos4 is slower (which matters when datasets can contain tens of thousands of images) and OpenCV's own documentation says INTER_AREA is preferred for downscaling:

INTER_AREA Python: cv.INTER_AREA

resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire'-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method.