Open LuminousPath opened 2 days ago
Do you want the alpha to be treated as a mask?
The image that gets saved with "open in mask editor" uses the alpha for the mask (as far as I know), I just assumed the functionality that's in:
could work similarly when those same objects are set in set_previewbridge_image
I was mistaken about the code.
Your explanation of the PR is a bit confusing.
In the existing implementation, if the image resolution doesn't change, the previously stored mask remains intact even if the source image changes.
Are you saying this functionality isn't working?
Right, this isn't working in the case of:
The issue I found was that the mask isn't saved into the preview_bridge_last_mask_cache
or preview_bridge_cache
objects when you edit the mask using comfy's mask editor. It does get saved into preview_bridge_image_id_map
and preview_bridge_image_name_map
but there's no functionality in doit
that tries to see if a previous mask exists from these objects.
The code only tests preview_bridge_last_mask_cache
:
and preview_bridge_cache
:
I'm not sure of the intended functionality, but because neither of these things are set when the mask editor returns, the mask doesn't exist as far as doit
is concerned.
I don't see any issues on my side. Could you show exactly what situation you're referring to by recording a video?
This code contains the logic to restore the previous image when the input image changes. (The restoration condition is met if a previously saved mask exists and the restore option is enabled.)
This is where the mask is actually cached. If it is not an empty mask, it will always be cached. https://github.com/ltdrdata/ComfyUI-Impact-Pack/blob/24de5a846bb9b1c1830af0218f76266c375cc904/modules/impact/bridge_nodes.py#L132
Sure: (sorry for the long/slow video, my computer isn't that powerful so recording and genning at the same time takes some time)
This is the mask effect without my change: showing_preview_bridge_issue.webm
and this is the effect after my change: after_change.webm
This is where the mask is actually cached. If it is not an empty mask, it will always be cached.
This code only fires when the node actually runs during processing, and is not cached when the mask is actually edited.
I'm not really sure if this is a bug or if it's outside the intended functionality
Oh, so you want to include in the restore even the masks that have never run a node.
When I applied your PR, I encountered this issue. Please consider this aspect as well.
This only occurs if if_same_size
mode.
https://github.com/user-attachments/assets/51eb800c-cca7-4bb7-8ff9-6d6928570779
Additionally, the patch also affects PreviewBridge (Latent)
, so please check if it has any impact on that as well.
@ltdrdata I believe the change should fix the problem with the size comparison (I forgot to put unsqueeze
so the returned dimensionality was too low and the comparison broke)
I also tested it with the latent preview and didn't run into any issues.
Let me know if there's anything else you want me to change!
When using the
restore_mask
functionality, it only works if the image already had a mask attached, as "Open in MaskEditor" doesn't save the mask to the cache set specifically for masks, so when the next generation fires, if the image is different, the cache misses and the mask doesn't get restored.In order to facilitate the
restore_mask
functionality better, one needs to save the mask to the cache when the mask is edited.