TongkunGuan commited on
Commit
3d2e6db
·
verified ·
1 Parent(s): 97be351

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +15 -6
utils.py CHANGED
@@ -136,12 +136,21 @@ def generate_similiarity_map(images, attn_map, all_bpe_strings, vis_list, target
136
  # print("target_height",images.size[1])
137
  # print("target_width",images.size[0])
138
 
139
- images = images[0]
140
- images_vis = T.ToTensor()(images) # images [<PIL.Image.Image image mode=RGB size=1024x608 at 0x7F9B6FC24B80>]
141
- print("images",images)
142
- print("images_vis",images_vis)
143
- target_height = images.size[1]
144
- target_width = images.size[0]
 
 
 
 
 
 
 
 
 
145
 
146
 
147
  print("attn_map",attn_map.shape)# torch.Size([4, 76, 128])
 
136
  # print("target_height",images.size[1])
137
  # print("target_width",images.size[0])
138
 
139
+ if len(images) == 1:
140
+ images_vis = torch.stack([T.ToTensor()(image) for image in images])
141
+ else:
142
+ images_vis = torch.stack([T.ToTensor()(image) for image in images[:-1]])
143
+ images_vis = make_grid(images_vis, nrow=target_aspect_ratio[0], padding=0, normalize=False)
144
+ target_width = image_size * target_aspect_ratio[0]
145
+ target_height = image_size * target_aspect_ratio[1]
146
+
147
+
148
+ # images = images[0]
149
+ # images_vis = T.ToTensor()(images) # images [<PIL.Image.Image image mode=RGB size=1024x608 at 0x7F9B6FC24B80>]
150
+ # print("images",images)
151
+ # print("images_vis",images_vis)
152
+ # target_height = images.size[1]
153
+ # target_width = images.size[0]
154
 
155
 
156
  print("attn_map",attn_map.shape)# torch.Size([4, 76, 128])