Skip to content

Commit

Permalink
update retrieval model script
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Mar 26, 2022
1 parent 17dcdd9 commit b7bb1ee
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions models/blip_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ def forward(self, image, caption, alpha, idx):
text_feat_m_all = torch.cat([text_feat_m.t(),self.text_queue.clone().detach()],dim=1)

sim_i2t_m = image_feat_m @ text_feat_m_all / self.temp
sim_t2i_m = text_feat_m @ image_feat_m_all / self.temp

sim_targets = torch.zeros(sim_i2t_m.size()).to(image.device)
sim_targets.fill_diagonal_(1)
sim_t2i_m = text_feat_m @ image_feat_m_all / self.temp

sim_i2t_targets = alpha * F.softmax(sim_i2t_m, dim=1) + (1 - alpha) * sim_targets
sim_t2i_targets = alpha * F.softmax(sim_t2i_m, dim=1) + (1 - alpha) * sim_targets
Expand Down

0 comments on commit b7bb1ee

Please sign in to comment.