Skip to content

refactor: migrate generation pipeline to sd::Tensor#1373

Merged
leejet merged 1 commit intomasterfrom
sd_tensor
Mar 29, 2026
Merged

refactor: migrate generation pipeline to sd::Tensor#1373
leejet merged 1 commit intomasterfrom
sd_tensor

Conversation

@leejet
Copy link
Copy Markdown
Owner

@leejet leejet commented Mar 29, 2026

No description provided.

@leejet leejet merged commit f16a110 into master Mar 29, 2026
15 checks passed
This was referenced Mar 29, 2026
Comment on lines +2958 to +2959
if (sd_version_is_inpaint(sd_ctx->sd->version)) {
latents.denoise_mask = std::move(latent_mask);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it should be if (!sd_version_is_inpaint(sd_ctx->sd->version)) here instead, Otherwise inpainting with non-inpaint models becomes impossible, and it adds some slight artifacts to the outputs of inpaint models (#1357 will hopefully fix that once I'm done rebasing it on the new codebase)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we change it this way, the inpaint model won’t be able to apply the mask. Perhaps we should always use a denoise mask whenever a mask image is specified.

Copy link
Copy Markdown
Contributor

@stduhpf stduhpf Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inpaint models have access to the mask via the concat_latent.
Without the denoise_mask , the inpaint models are still able to keep the unmasked area approximately intact, but there can be some slight color shift. With the denoise_mask, there can be some more or less noricable artifacts near the edges of the masked areas. When I first implemented inpainting I concluded that it was overall perferable to have sometimes some color shifting across all the image rather than artifacts.

In #1357 I found a way to deal with the artifats (by inflating the denoise_mask by 1 latent pixel) so Inpaint models can use both the concat_latent and denoise_mask and get rid of the color shift.

@stduhpf stduhpf mentioned this pull request Mar 30, 2026
@leejet leejet deleted the sd_tensor branch March 31, 2026 15:13
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.

2 participants