Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey Gadi!
This PR adds
patchmatch
outpainting support a la stablediffusion-infinity to this image 🪄 ✨The actual PyPatchMatch code is not mine, I have lifted it from the amazing Jiayuan Mao, who in turn lifted the C code from Younesse Andam. See more info in
PyPatchMatch/README.md
. I only removed some code that was related to compiling on travis, as well as the examples directory.Implementation Notes
I don't really do python or ML development, so take all of this with boatloads of grains of salt.
This feature adds a dependency to OpenCV, which is rather heavy. You need to install
libopencv-dev
for your platform. I have added it to the docker image. Maybe this could be added torequirements.txt
instead?It also adds an additional build step, you have to
cd PyPatchMatch && make
before executing the code (this is documented in the updatedREADME.md
). It's really quick though and only needs to be done once.The patchmatch step requires the
init_image
to be a PNG with alpha channel (the default when callinghtmlCanvasElement.toDataURL
). Amask_image
is not needed, as patchmatch generates it for us. I have left the output format of the inference function as JPEG to not break your existing UI, but it might make sense to change it to PNG down the road.To enable patchmatch and outpainting, pass
INIT_MODE: "patchmatch"
andPIPELINE: "StableDiffusionInpaintPipeline"
incallInputs
.I have verified that this code works in my private fork of banana-sd-base (that includes my API keys) and copied the changes over, so there's a chance that something is missing/broken. Since I don't have a machine capable of running SD it's quite cumbersome for me to test and I need my banana model to work since I'm actively developing against it. So please test this locally and let me know if anything breaks. Sorry for the inconvenience.
Oh and BTW thanks for all your work on
banana-sd-base
and kiri.art!Cheers ✌️