-
Notifications
You must be signed in to change notification settings - Fork 1
/
ret_utils.py
40 lines (35 loc) · 1.69 KB
/
ret_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import numpy as np
def load_clip_memory_bank(args):
first_iter=True
for bank_type in args.bank_type:
print("##########################################",bank_type)
if bank_type == "anet" or bank_type =="yc2":
rag = os.path.join(args.bank_path,bank_type) #which domain will be used
rag = os.path.join(rag,'clip')
# rag = os.path.join(rag,'clip')
text_sentence = np.load(os.path.join(rag,bank_type+"_scene_sentences.npy"))
text_embed = np.load(os.path.join(rag,bank_type+"_clip_token_embeds.npy"))
scene_videoID = np.load(os.path.join(rag,bank_type+"_scene_videoID.npy"))
else:
rag = os.path.join(args.bank_path,'knowledge') #which domain will be used
text_sentence = np.load(os.path.join(rag,bank_type+"_scene_sentences.npy"))
text_embed = np.load(os.path.join(rag,bank_type+"_clip_token_embeds.npy"))
scene_videoID = np.load(os.path.join(rag,bank_type+"_scene_videoID.npy"))
if first_iter:
text_sentences = text_sentence
scene_videoIDs = scene_videoID
text_embeds = text_embed
else:
text_sentences = np.concatenate((text_sentences, text_sentence))
text_embeds = np.concatenate((text_embeds, text_embed))
scene_videoIDs = np.concatenate((scene_videoIDs, scene_videoID))
first_iter=False
pair_bank={}
pair_bank = {
"vid_sentences": text_sentences,
"vid_sent_embeds": text_embeds,
"video_id": scene_videoIDs
}
print("memory loaded, ",len(pair_bank["vid_sent_embeds"]))
return pair_bank