AhmedSSabir commited on
Commit
0d826b8
1 Parent(s): 144db7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -36
app.py CHANGED
@@ -81,40 +81,6 @@ def sentence_prob_mean(text):
81
  return mean_prob
82
 
83
 
84
- # def cloze_prob(text):
85
-
86
- # whole_text_encoding = tokenizer.encode(text)
87
- # text_list = text.split()
88
- # stem = ' '.join(text_list[:-1])
89
- # stem_encoding = tokenizer.encode(stem)
90
- # cw_encoding = whole_text_encoding[len(stem_encoding):]
91
- # tokens_tensor = torch.tensor([whole_text_encoding])
92
-
93
- # with torch.no_grad():
94
- # outputs = model(tokens_tensor)
95
- # predictions = outputs[0]
96
-
97
- # logprobs = []
98
- # start = -1-len(cw_encoding)
99
- # for j in range(start,-1,1):
100
- # raw_output = []
101
- # for i in predictions[-1][j]:
102
- # raw_output.append(i.item())
103
-
104
- # logprobs.append(np.log(softmax(raw_output)))
105
-
106
-
107
- # conditional_probs = []
108
- # for cw,prob in zip(cw_encoding,logprobs):
109
- # conditional_probs.append(prob[cw])
110
-
111
-
112
- # return np.exp(np.sum(conditional_probs))
113
-
114
-
115
-
116
-
117
-
118
  def cos_sim(a, b):
119
  return np.inner(a, b) / (np.linalg.norm(a) * (np.linalg.norm(b)))
120
 
@@ -142,8 +108,7 @@ def Visual_re_ranker(caption_man, caption_woman, context_label, context_prob):
142
  LM_man = sentence_prob_mean(caption_man)
143
  LM_woman = sentence_prob_mean(caption_woman)
144
 
145
- #LM_man = cloze_prob(caption_man)
146
- #LM_woman = cloze_prob(caption_woman)
147
 
148
 
149
 
 
81
  return mean_prob
82
 
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  def cos_sim(a, b):
85
  return np.inner(a, b) / (np.linalg.norm(a) * (np.linalg.norm(b)))
86
 
 
108
  LM_man = sentence_prob_mean(caption_man)
109
  LM_woman = sentence_prob_mean(caption_woman)
110
 
111
+
 
112
 
113
 
114