-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Image output tiling for seamless textures with Stable Diffusion #556
Comments
Hi @torrinworx! As the Sygil-Dev/sygil-webui#911 PR suggests, you can make the Stable Diffusion models tile-able by patching the # add global options to models
def patch_conv(**patch):
cls = torch.nn.Conv2d
init = cls.__init__
def __init__(self, *args, **kwargs):
return init(self, *args, **kwargs, **patch)
cls.__init__ = __init__
patch_conv(padding_mode='circular')
print("patched for tiling") Native support for tiling in |
FYI: |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
Could we make this a community pipeline maybe? :-) |
is it possible for flax |
hello, i follow your advice , add this snippet before loading the pipeline, but there is an error when loading pipeline:
can you tell me why? |
@anton-l, I think we can allow to adapt the conv mode with a nice diffusers API here no? |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
Linking some first PRs here: |
cc @patil-suraj @anton-l does any of you have time to look into tiling? |
Note this must be applied to both the diffusion model and the decoder (VAE). |
That's the plan @keturn, still experimenting with it. |
begone, stalebot! |
I didn't know that PR existed, very nice! Even so, If you don't want to add this code the the SD pipelines, I think it would be better to just write it as a technique in the new section since is just like 20 lines of code and it wouldn't need to be maintained or updated which is a known issue with community pipelines. |
My 2 cents (maintainer of Easy Diffusion) - I'd also request that tiling be included in the main code, because tiling is a feature present in pretty much every Stable Diffusion software (including Easy Diffusion). InvokeAI has it, auto1111 has it, and it's a very common use-case. I genuinely understand that it's a tricky balance between keeping the project lean vs empowering users. But in this particular case, given the context, I believe it makes sense to tilt towards including it. But that's obviously your call. It's a regular task for me to fix our tiling code every few releases of diffusers, because something changed that broke tiling. I don't see that changing with making it a community pipeline. People keep patching the code in this ticket, and people will keep patching the code in a community pipeline. But the bottom line is that tiling will keep breaking every few releases (because it isn't a core feature with automated tests). So to me it doesn't really matter whether the code is here in this ticket, or in a community pipeline. If it isn't in the core, it'll very likely continue breaking every few releases. And given the number of people maintaining the code in this ticket for so long (to keep tiling updated with diffusers), I'd say it signals the utility of this feature. I'm not sure tiling is a different pipeline in the first place. It's an option for an image, using the same pipeline. Regardless of whether we're doing SDXL or Img2Img or Inpaint etc. But anyway, that's semantics. :) |
@asomoza @cmdr2 I just realized that we merged this PR #6031 I think we can add it to
|
hey sorry guys I looked into this and really can't come up with a clean way to support this feature from diffusers Also I now agree it does not make too much sense to make community pipelines for it since it should be a feature every single SD pipeline can use; so I added it to the "community script" section in the community folder for now #7358. This will also most likely be added to our docs later |
Thanks @yiyixuxu ! That sounds fair enough, thanks for trying! Just curious, what's the complication with adding a |
I think we would be able to support it if it's just to modify the |
@yiyixuxu Yeah, that makes sense. I don't have a good suggestion either, still thinking about it. Maybe a wrapper class (like the LoRA Conv class), that is applied when seamless-tiling is enabled, and removed when disabled? Not sure yet whether this will play well with the LoRA Conv class, and whether it'll work well with I agree that hacks should be avoided, so brainstorming about ways to make this happen without bad code. Because this feature is really useful, especially when it comes to 3D models and game-dev. For e.g. here's a tweet by Adobe Substance 3D (from yesterday), which shows its ability to generate seamless textures using prompts - https://twitter.com/Substance3D/status/1769778370227683514 |
Should work as expected. If not, please let us know. Would be more than happy to investigate :) |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
cc @asomoza here |
I can get good looking examples from sdxl with a lot of experimentation, but one big issue that we are seeing is that lower resolutions (e.g. here 512x512) result in these very much destroyed and artefacted images. They are always looking similar, and you can see the patterns also emerge in the last example I posted. Here's the artefacted examples: |
SDXL wasn't trained in 512x512 images or even in 768x768, the results will almost always be bad. You'll need to use 1024x1024 or some of the resolutions in which SDXL was trained. |
yeah, I don't know the "true" answer to that, but probably you'll get the same answer I gave you anywhere you ask, not many people might spend time and resources in understanding why a model doesn't work well when you use it in some specific way outside of its domain. But in the meantime, we can safely assume that this is not a diffusers issue, maybe you can try asking in the Stability AI repo since they trained the model and maybe they did some experiments with it about this. Edit: I forgot about this, if you need to work with lower resolutions, maybe this will work: https://github.com/bytedance/res-adapter |
Yes, I agree, it's definitively not a diffusers issue, sorry for highjacking the thread, I found it on my quest to understand :) Thanks for the link, I'll check the adapter out! |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
Cc: @asomoza WDYT about this? |
we can close this now, we added it as a community script with this PR |
Is your feature request related to a problem? Please describe.
Currently there is no way to create seamless textures with Stable Diffusion, a crucial feature that is missing.
Describe the solution you'd like
Something similar to this pull on the sd-webui repo: Sygil-Dev/sygil-webui#911
A simple argument in the
StableDiffusionPipeline
that would enable seamless texture generation for 3D applications.The text was updated successfully, but these errors were encountered: