Skip to content

How can I get attention maps from transformer? #2

Description

@amoeba04

Thank you for releasing your great work!

I'm trying to follow your work, but I face an error below:

Traceback (most recent call last):
  File "train_flux_lora.py", line 467, in <module>
    finetune(args)
  File "train_flux_lora.py", line 403, in finetune
    upper_loss, t_enc_ddpm = calculate_upper_loss(args, batch, compute_text_embeddings, text_encoders, tokenizers, transformer, noise_scheduler_copy, batch["prompts"], vae, criteria, negative_guidance=args.negative_guidance, weight_dtype=weight_dtype, neg_prompts=str(args.prompt_b), start_guidance=3, ddim_steps=28, lamb1=float(args.lamb1), lamb2=float(args.lamb2))
  File "EraseAnything/utils/calc_loss.py", line 374, in calculate_upper_loss
    z, latent_image_ids = latent_sample(transformer,
  File "miniconda3/envs/sd3/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "EraseAnything/utils/esd_utils.py", line 91, in latent_sample
    noise_pred, attn_maps = transformer(
ValueError: not enough values to unpack (expected 2, got 1)

I cannot find options like output_attentions=True in FluxTransformer2DModel, so I wonder how did you implement these lines.

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