towhee.models.visualization.transformer_visualization.show_image_heatmap

towhee.models.visualization.transformer_visualization.show_image_heatmap(model: ~torch.nn.modules.module.Module, pil_img: <module 'PIL.Image' from '/home/docs/checkouts/readthedocs.org/user_builds/towhee/envs/main/lib/python3.9/site-packages/PIL/Image.py'>, method: str = 'transformer_attribution', transform: ~typing.Optional[~typing.Any] = None, device: ~typing.Optional[str] = None)[source]

Show image heatmap for transformer model. :param model: Transformer model. :type model: nn.Module :param pil_img: Pil Image. :type pil_img: Image :param method: full, rollout or transformer_attribution.

Algorithm for attention vis, default is transformer_attribution

Parameters:
  • transform (Any) – Pytorch transforms or function, can be None by default.

  • device (str) – model device.