Skip to content

Does not generate a heatmap - no error output to console #33

Description

@AdamWelch1

Ok, I'm a C++ developer, not a python developer so I was only able to identify where in the code the issue lies, but I don't know how to fix it.

So even though I've filled in the attention text field in the "Attention Heatmap" accordion box, DAAM does not show a heatmap and no heatmap image is saved to the output folder. Doing some "print" debugging, I was able to determine the issue occurs in daam_script.py on line 285:

try:
    global_heat_map = tracer.compute_global_heat_map(self.prompt_analyzer, styled_prompot, batch_pos)
except:
    continue

That compute_global_heat_map call raises an exception. By removing the try...except block, I can get the default output from the exception, which is as follows:

*** Error executing callback before_image_saved_callback for /home/user/stable-diffusion-webui/extensions/stable-diffusion-webui-daam/scripts/daam_script.py
    Traceback (most recent call last):
      File "/home/user/stable-diffusion-webui/modules/script_callbacks.py", line 309, in before_image_saved_callback
        c.callback(params)
      File "/home/user/stable-diffusion-webui/extensions/stable-diffusion-webui-daam/scripts/daam_script.py", line 332, in handle_before_image_saved
        before_image_saved_handler(params)
      File "/home/user/stable-diffusion-webui/extensions/stable-diffusion-webui-daam/scripts/daam_script.py", line 168, in <lambda>
        before_image_saved_handler = lambda params : self.before_image_saved(params)
                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/user/stable-diffusion-webui/extensions/stable-diffusion-webui-daam/scripts/daam_script.py", line 285, in before_image_saved
        global_heat_map = tracer.compute_global_heat_map(self.prompt_analyzer, styled_prompot, batch_pos)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/user/stable-diffusion-webui/extensions/stable-diffusion-webui-daam/scripts/daam/trace.py", line 182, in compute_global_heat_map
        maps = torch.stack([torch.stack(x, 0) for x in all_merges], dim=0)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    RuntimeError: stack expects a non-empty TensorList

I'm really not sure how to fix this, so I'm hoping you'll be able to help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions