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

Img2img mask can be filled with zeroes #610

Closed
wants to merge 2 commits into from

Conversation

vmobilis
Copy link
Contributor

When using -O3 optimization, a mask can be filled with zeroes.
It looks (I didn't use debugger) like buffer with 0xFFs is ignored by some compilers and filled with 0x00. In my case, Clang does it.
This completely masks img2img result.

Also, this commit omits mask creation for txt2img and reduces memory usage.

Fixes #606.

Or else it can be filled with zeroes instead of 0xFF, with -O3 optimization.
@vmobilis vmobilis mentioned this pull request Feb 28, 2025
@vmobilis
Copy link
Contributor Author

@leejet, @stduhpf, could you please help, to not make needless commits, do I need to include util.h into main.cpp if I want to use LOG_DEBUG()?

I built successfully locally, but all GitHub Windows builds seem to fail.

@stduhpf
Copy link
Contributor

stduhpf commented Mar 1, 2025

It would work to include utils.h in the main example, but It would probably be best to either call sd_log_cb() directly, or to just use printf() instead of the logger.

@leejet
Copy link
Owner

leejet commented Mar 1, 2025

This is tricky and not very intuitive, or we could use a for loop to assign the value 255 to arr's elements.

@leejet
Copy link
Owner

leejet commented Mar 1, 2025

There is a dangling pointer issue here, arr memory is released after going out of scope, but it is still referenced by mask_image_buffer. I fixed this issue in master, please try it if it can solve your problem.

@vmobilis
Copy link
Contributor Author

vmobilis commented Mar 1, 2025

@stduhpf, using sd_log_cb() directly would require copying log_printf() functionality, I'll try to use util.h.
But I haven't figured out how yet, linker of all Windows builds can not find log_printf() body, which should be compiled in libstable-diffusion.a.
Maybe I need to unmangle its name.

@leejet, will LOG_DEBUG() with notice to not remove it be more convenient? I'll try your fix, thank you very much.

@vmobilis
Copy link
Contributor Author

vmobilis commented Mar 1, 2025

@leejet, yes, your commit fixed the issue, thank you very much!

@vmobilis vmobilis closed this Mar 1, 2025
@vmobilis vmobilis deleted the patch-1 branch March 1, 2025 10:34
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.

img2img is broken
3 participants