eric-ai-lab / photoswap

Official implementation of the NeurIPS 2023 paper "Photoswap: Personalized Subject Swapping in Images"
https://photoswap.github.io
MIT License
342 stars 24 forks source link

[cross_map_replace_steps not used?] #12

Open tomguluson92 opened 11 months ago

tomguluson92 commented 11 months ago

Dear authors,

Thanks for your brilliant work! I am wondering that when I dive into the swapping_class.py https://github.com/eric-ai-lab/photoswap/blob/main/swapping_class.py#L179 for understanding the usage of

I didn't find the usage of these parameters in either self.replace_cross_attention(xxx) or self.replace_self_attention(xxx).

And I also want to know that the usage of self.local_blend, I didn't find it has been used in the code anywhere.

Could you please tell me the meaning of these settings and how it actually influence the generated result?

Thanks.

image

justin biber checkpoint

image

image

g-jing commented 11 months ago

cross_map_replace_steps and self_output_replace_steps are two parameters of controller, which will be used in this function: https://github.com/eric-ai-lab/photoswap/blob/d631e8ec6bc1b9260f80fdcd983a602d9299aef0/utils.py#L214. You should be able to reason out if you follow the tracing of the controller. self.local_blend is used for whether the some of latent image at each diffusion step of the generated image directly got swapped from the latent of the source image, so that the background pixel could be directly borrowed from the original image.

tomguluson92 commented 11 months ago

Thanks for quick reply:

But I still don't find anything that inside swapping_class.py used cross_map_replace_steps and self_output_replace_steps.

The only used member functions are replace_cross_attention & replace_self_attention

https://github.com/eric-ai-lab/photoswap/blob/d631e8ec6bc1b9260f80fdcd983a602d9299aef0/swapping_class.py#L164

I have also check multiple times the code snippet in utils.py.

Nothing called in self.replace_cross_attention(xxx) and self.replace_self_attention(xxx). local_blend is not used during inference either.

nancy6o6 commented 2 months ago

I think the cross-attention replacing threshold is actually defined by:

https://github.com/eric-ai-lab/photoswap/blob/570ca0de4866ed2f01ca274c1d016c0af01c119d/swapping_class.py#L157

which takes cross_replace_steps as the parameter. self.cross_replace_alpha plays a role in

https://github.com/eric-ai-lab/photoswap/blob/570ca0de4866ed2f01ca274c1d016c0af01c119d/swapping_class.py#L136-L139