Inzaniak / sd-webui-ranbooru

71 stars 7 forks source link

Img2Img generation size / aspect ratio fix #35

Open Luke2642 opened 5 months ago

Luke2642 commented 5 months ago

If you use img2img it generates 512x768, 768x512 or 768x768 which is not ideal, low res + distorted.

This caps it at 1536 on one side preserving aspect ratio. Maybe the 1536 could be a configurable param, textbox or slider? Or maybe it could get the max value from the interface?

def check_orientation(self, img):
        """Check if image is portrait, landscape or square"""
        x, y = img.size
        maxlength = max(x, y)
        if maxlength > 1536:
            maxlength = 1536
        if x > y:
            return[maxlength, int(maxlength * float(y / x))]
        else:
            return[int(maxlength * float(x / y)), maxlength]

I'm also thinking about how to implement a 'loopback' feature that preserves prompt + resolution to do N passes at e.g. 30% denoising... better than 1 pass at higher denoising for preserving details like fingers.