File tree 2 files changed +10
-2
lines changed
2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 5
5
from multiprocessing import Pool
6
6
from pathlib import Path
7
7
8
+ import faiss
8
9
import numpy as np
9
10
from omegaconf import DictConfig
10
11
from tqdm import tqdm
@@ -80,9 +81,9 @@ def __init__(self, cfg: DictConfig) -> None:
80
81
self .text2audio = "clap"
81
82
82
83
self .shape = (1 , 2 ) # shape of the similarity matrix
83
- self .cali_size = 3_800
84
+ self .cali_size = 800
84
85
self .train_size = 53_000 # TODO: no training data is needed for MSRVTT
85
- self .test_size = 3_000
86
+ self .test_size = 6_000
86
87
self .query_step = 5
87
88
self .img2txt_encoder = self .cfg_dataset .img_encoder
88
89
self .audio2txt_encoder = self .cfg_dataset .audio_encoder
@@ -202,6 +203,12 @@ def preprocess_retrieval_data(self) -> None:
202
203
203
204
# check the length of the reference order
204
205
assert len (self .ref_id_order ) == self .audio2txt_emb ["test" ].shape [0 ]
206
+ # build the faiss index for the test set
207
+ red_video_ids = np .array (self .ref_id_order , dtype = "int64" ) # Faiss requires int64 for IDs
208
+ self .audio2txt_faiss = faiss .IndexFlatIP (self .audio2txt_emb ["test" ].shape [1 ])
209
+ self .audio2txt_faiss .add_with_ids (self .audio2txt_emb ["test" ], red_video_ids )
210
+ self .img2txt_faiss = faiss .IndexFlatIP (self .img2txt_emb ["test" ].shape [1 ])
211
+ self .img2txt_faiss .add_with_ids (self .img2txt_emb ["test" ], red_video_ids )
205
212
206
213
def check_correct_retrieval (self , q_idx : int , r_idx : int ) -> bool :
207
214
"""Check if the retrieval is correct.
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ timm = "*"
69
69
albumentations = " *"
70
70
kaggle = " *"
71
71
moviepy = " *"
72
+ faiss-gpu = " *"
72
73
imagebind = {git = " https://github.com/facebookresearch/ImageBind" }
73
74
# LLaVA = {git = "https://github.com/haotian-liu/LLaVA.git"} # contradicting with imagebind
74
75
You can’t perform that action at this time.
0 commit comments