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

[bug]: Seamless Tile not seamless on certain colors #6340

Closed
1 task done
KingsmanZer0 opened this issue May 10, 2024 · 9 comments · Fixed by #6344
Closed
1 task done

[bug]: Seamless Tile not seamless on certain colors #6340

KingsmanZer0 opened this issue May 10, 2024 · 9 comments · Fixed by #6344
Labels
bug Something isn't working

Comments

@KingsmanZer0
Copy link

KingsmanZer0 commented May 10, 2024

Is there an existing issue for this problem?

  • I have searched the existing issues

Operating system

Windows

GPU vendor

Nvidia (CUDA)

GPU model

rtx 4090

GPU VRAM

24

Version number

4.2

Browser

chrome 124.0.6367

Python dependencies

No response

What happened

trying to generate seamless tiles but when generating images with light red/pink/blue colors there is a visible light brown line going down the seams after i try the tile in photoshop. tried generating a couple that has light reds/blues and issue still persist.
also tried a couple of other colors like white or dark colors but seams were fine and seamless
seams1

What you expected to happen

should be seamless transitions in colors

How to reproduce the problem

Prompt used: red flower watercolor
Model: juggernautxl9
size: 1024 x 1024
Enabled: X and Y seamless tile

Additional context

When trying to generate seamless tile an images with light red/pink/blue colors a visible light brown seam is visible. tried some other colors like white or dark colors but they seemed fine.
seams2

Discord username

tuanny87

@KingsmanZer0 KingsmanZer0 added the bug Something isn't working label May 10, 2024
@psychedelicious
Copy link
Collaborator

I can't seem to reproduce this, or maybe I just don't see the issue. I've made dozens of images with x & y seamless, the same model and same or similar prompts. Can't see the line on any of them.

Here's a selection where the petals cross the central vertical axis of the image, where the line is visible:

Do you see any lines on these?

@KingsmanZer0
Copy link
Author

KingsmanZer0 commented May 10, 2024

I can't seem to reproduce this, or maybe I just don't see the issue. I've made dozens of images with x & y seamless, the same model and same or similar prompts. Can't see the line on any of them.

Here's a selection where the petals cross the central vertical axis of the image, where the line is visible:

you have to join the tile in photoshop to see the seam issue it. here i took your first image you generated and made a duplicate and joined the pattern and you can see the brown line on the flower. tried this in like auto1111 and does not have this issue.
seam line

@psychedelicious
Copy link
Collaborator

Ahh, sorry, I misunderstood the issue.

@RyanJDick @blessedcoolant I wonder if our seamless isn't quite right yet. I noticed that A1111 appears to do fully-circular tiling only. It's done by patching torch.nn.Conv2d's constructor. Very simple, but doesn't support tiling on individual axes.

There's a long-running diffusers issue about seamless, and here's the implementation that apparently was settled-on as working: huggingface/diffusers#556 (comment)

This is similar to ours, with some notable changes:

  • We skip some layers
  • We also patch nn.ConvTranspose2d
  • The diffusers implementation has special handling for LoRACompatibleConv layers

I don't understand this well enough to making any changes that aren't just guesses/experimentation.

@blessedcoolant
Copy link
Collaborator

@psychedelicious #6344 Implemented here. Seems to be working. Give it a run.

@psychedelicious
Copy link
Collaborator

@blessedcoolant I'm asking why we skip a layer and handle the transpose layer, because the comments in the code seem to indicate that is important. At some point in the past, our implementation was like the diffusers one and we changed it to what we have now.

@blessedcoolant
Copy link
Collaborator

blessedcoolant commented May 10, 2024

@blessedcoolant I'm asking why we skip a layer and handle the transpose layer, because the comments in the code seem to indicate that is important. At some point in the past, our implementation was like the diffusers one and we changed it to what we have now.

@psychedelicious Because technically we also need to change the layers in the text_encoder for seamless .. but we just do UNet and VAE. So I'm guessing skipping the last layer was a sort of "fix" to mitigate some of the prompt importance in favor of seamlessness. I cannot really tell why it was done that way.

So far in my testing, I haven't found any cases where this new/old algo has failed. It's a lot simpler and clearer on what it does.

And I don't know why there was even a check for the transposed layers coz there's none in the UNet or the VAE.

@psychedelicious
Copy link
Collaborator

Ok. What if we patch torch directly like A1111 does? That would automatically apply to every model.

@blessedcoolant
Copy link
Collaborator

blessedcoolant commented May 10, 2024

@psychedelicious He doesn't actually use that function. He just applies circular padding to the layers as per requirement of the generation which is what needs be done and what we are doing right now. https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/1c0a0c4c26f78c32095ebc7f8af82f5c04fca8c0/modules/sd_hijack.py#L311

@psychedelicious
Copy link
Collaborator

@blessedcoolant Ahhh I see. Thanks for clearing that up.

@psychedelicious psychedelicious linked a pull request May 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants