Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add outpainting support #1

Merged
merged 1 commit into from
Oct 14, 2022

Conversation

msuess
Copy link
Contributor

@msuess msuess commented Oct 13, 2022

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 to requirements.txt instead?

It also adds an additional build step, you have to cd PyPatchMatch && make before executing the code (this is documented in the updated README.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 calling htmlCanvasElement.toDataURL). A mask_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" and PIPELINE: "StableDiffusionInpaintPipeline" in callInputs.

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 ✌️

@gadicc
Copy link
Collaborator

gadicc commented Oct 14, 2022

Hey @msuess!

This is awesome... thanks so, so much for this contribution. This is such an exciting space right now and it's great to be collaborating with others in open source to bring more and more magic which just would not be possible by one person alone.

This all looks great. I'll need a bit of time to play around with it a bit before I can merge to main, but I'm going to make a new patchmatch branch on here in the meantime and will keep you posted. Regrettably I won't have any time over the weekend, but I expect I'll be in touch early next week.

In the meantime, have a lovely weekend, and thanks again for this greatly appreciated contribution! 🙌

@gadicc gadicc changed the base branch from main to feat/patchmatch October 14, 2022 08:49
@gadicc gadicc merged this pull request into kiri-art:feat/patchmatch Oct 14, 2022
@gadicc
Copy link
Collaborator

gadicc commented Oct 14, 2022

Not possible to leave a PR open after merge, but I'll still post back here once I've had a time to work on it 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants