The example pano_pattern.png that illusion.py uses by default looks like this
When I ran the script, I got output that didn't match that pattern exactly
A bit of investigation showed that my output had been based instead on this stretched version of the controlnet image - which it does match:
Which is what happens if you take a square center crop of the original controlnet image:
and then just stretch it to cover the target rectangle. This is what the logic of the center_crop_resize seemed to be doing - likely because the upstream code didn't expect to need to handle non-square outputs. I updated this logic to instead take the aspect ratios of the source and destination into account and instead use the largest center crop possible for non-square outputs.
After this change I get output that matches my expectations for the original controlnet image
And also tested it on a sideways version of this image and to check that the logic seems to work as planned for tall images too
The example pano_pattern.png that illusion.py uses by default looks like this
When I ran the script, I got output that didn't match that pattern exactly
A bit of investigation showed that my output had been based instead on this stretched version of the controlnet image - which it does match:
Which is what happens if you take a square center crop of the original controlnet image:
and then just stretch it to cover the target rectangle. This is what the logic of the
center_crop_resize
seemed to be doing - likely because the upstream code didn't expect to need to handle non-square outputs. I updated this logic to instead take the aspect ratios of the source and destination into account and instead use the largest center crop possible for non-square outputs.After this change I get output that matches my expectations for the original controlnet image
And also tested it on a sideways version of this image and to check that the logic seems to work as planned for tall images too