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 is broken #606

Closed
vmobilis opened this issue Feb 28, 2025 · 4 comments
Closed

img2img is broken #606

vmobilis opened this issue Feb 28, 2025 · 4 comments

Comments

@vmobilis
Copy link
Contributor

vmobilis commented Feb 28, 2025

Reference image:

Command line:
./sd --model "dreamshaper_8.safetensors" -o "img2img.png" -p "green apple" --mode img2img -i "horse.jpg" --strength 0.4 --type f16

2eac844cc92a6a8f4ab9a

Result is almost or identical to reference.
F32 and quantized types work same.
Regression is introduced in 8f4ab9a commit.

Model version is Stable Diffusion 1.5.
https://civitai.com/models/4384?modelVersionId=128713

@stduhpf
Copy link
Contributor

stduhpf commented Feb 28, 2025

I can't reproduce this issue with commit 19d876e

Image

8f4ab9a also works for me:

Image

I don't know how this could be hapenning on your end, all I can think is that maybe it runs in inpaint mode with an empty mask? But this shouldn't be possible, if the mask is not specified, it's supposed to be initialized to fill the whole frame.

@vmobilis
Copy link
Contributor Author

@stduhpf, I found the reason: compiler filled mask with zeroes.
If I printed few values from arr, the mask was filled with 0xFF, but otherwise the buffer seemed to be created without fill.
Depending on where I tried to copy data from arr to mask_image, I either got zeroed mask or segmentation fault.

By trials I ended up with #610.

@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

@leejet, moving arr[] to scope of mask_image_buffer fixed the issue, thank you!

@leejet, @stduhpf, will it be acceptable to move mask creation completely to img2img part?
This will save few megabytes for txt2img generation.
Like #612.

@vmobilis vmobilis closed this as completed Mar 1, 2025
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 a pull request may close this issue.

3 participants