Commit
·
d444161
1
Parent(s):
fd8d20e
Chnages.
Browse files
app.py
CHANGED
@@ -77,17 +77,6 @@ def generate_answers(img=None, aud = None, q = None, max_tokens = 30):
|
|
77 |
max_new_tokens=max_tokens,
|
78 |
return_dict_in_generate = True)
|
79 |
|
80 |
-
# for pos in range(max_tokens - 1):
|
81 |
-
# model_output_logits = phi2_model.forward(inputs_embeds = combined_embeds)['logits']
|
82 |
-
# print(model_output_logits.shape)
|
83 |
-
# predicted_word_token_logits = model_output_logits[:, -1, :].unsqueeze(1)
|
84 |
-
# predicted_word_token = torch.argmax(predicted_word_token_logits, dim = -1)
|
85 |
-
# predicted_caption[:, pos] = predicted_word_token.view(1,-1).to('cpu')
|
86 |
-
# print(predicted_caption)
|
87 |
-
# next_token_embeds = phi2_model.model.embed_tokens(predicted_word_token)
|
88 |
-
# combined_embeds = torch.cat([combined_embeds, next_token_embeds], dim=1)
|
89 |
-
# print("combined_embeds", combined_embeds.shape)
|
90 |
-
# predicted_captions_decoded = tokenizer.batch_decode(predicted_caption,ignore_index = 50256)[0]
|
91 |
predicted_captions_decoded =tokenizer.batch_decode(predicted_caption.sequences[:, 1:])[0]
|
92 |
predicted_captions_decoded = predicted_captions_decoded.replace("<|endoftext|>","")
|
93 |
return predicted_captions_decoded
|
|
|
77 |
max_new_tokens=max_tokens,
|
78 |
return_dict_in_generate = True)
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
predicted_captions_decoded =tokenizer.batch_decode(predicted_caption.sequences[:, 1:])[0]
|
81 |
predicted_captions_decoded = predicted_captions_decoded.replace("<|endoftext|>","")
|
82 |
return predicted_captions_decoded
|