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

batch data , token and map #8

Open
Wtandford opened this issue Jul 28, 2024 · 4 comments
Open

batch data , token and map #8

Wtandford opened this issue Jul 28, 2024 · 4 comments

Comments

@Wtandford
Copy link

hello ! How to save batch data and how to ensure the correspondence between token and map

@wooyeolBaek
Copy link
Owner

@Wtandford
Sorry for the late reply. Even for a single image, too many intermediate results are saved at each layer and timestep, so I haven’t yet implemented attention map extraction and storage for batch data. Therefore, I recommend using this approach only for inference on a single image for now. Regarding token and map matching, the prompt is processed through the tokenizer and text encoder, resulting in a text embedding with 77 tokens. To keep things simple, I didn’t fetch tokens directly from the pipeline. Instead, I re-tokenized the prompt to match the tokens.

@shashankg7
Copy link

Hi @wooyeolBaek! Any suggestions to extend this approach to get attention map for batched data?

@wooyeolBaek
Copy link
Owner

wooyeolBaek commented Nov 4, 2024

@shashankg7
I was planning to extend it to batched data using AttnProcess2_0, but I've been busy lately, so it might take a while before I can get to it. Since AttnProcess2_0 can process batched data simultaneously, unlike AttnProcess, it should be sufficient to modify register_cross_attention_hook in utils.py and lines 767-772 in modules.py.

@wooyeolBaek
Copy link
Owner

@shashankg7
I've also added feature to support batch operations. So feel free to refer to it if needed.

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

No branches or pull requests

3 participants