sayakpaul HF staff commited on
Commit
4191f84
1 Parent(s): 83c742a
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -76,6 +76,7 @@ def generate_plot(processed_map):
76
 
77
  def serialize_images(processed_map):
78
  """Serializes attention maps."""
 
79
  for i in range(processed_map.shape[0]):
80
  plt.imshow(processed_map[i].numpy())
81
  plt.title(f"Attention head: {i}", fontsize=14)
@@ -96,7 +97,7 @@ def generate_class_attn_map(image, block_id=0):
96
  processed_cls_attn_map = get_cls_attention_map(image_tensor, out, block_key)
97
 
98
  serialize_images(processed_cls_attn_map)
99
- all_attn_img_paths = sorted(glob.glob("*.png"))
100
  print(f"Number of images: {len(all_attn_img_paths)}")
101
  return all_attn_img_paths
102
 
 
76
 
77
  def serialize_images(processed_map):
78
  """Serializes attention maps."""
79
+ print(f"Number of maps: {processed_map.shape[0]}")
80
  for i in range(processed_map.shape[0]):
81
  plt.imshow(processed_map[i].numpy())
82
  plt.title(f"Attention head: {i}", fontsize=14)
 
97
  processed_cls_attn_map = get_cls_attention_map(image_tensor, out, block_key)
98
 
99
  serialize_images(processed_cls_attn_map)
100
+ all_attn_img_paths = sorted(glob.glob("attention_map_*.png"))
101
  print(f"Number of images: {len(all_attn_img_paths)}")
102
  return all_attn_img_paths
103