1313 "name" : "SIFT1M" ,
1414 "url" : "https://static.visual-computing.com/paper/DEG/sift.tar.gz" ,
1515 "archive" : "sift.tar.gz" ,
16- "folder" : "sift " ,
16+ "folder" : "sift1m " ,
1717 "metric" : Metric .FP32_L2 ,
1818 "dim" : 128 ,
1919 "base_count" : 1000000 ,
20- "base_file" : "sift_base .fvecs" ,
21- "query_file" : "sift_query .fvecs" ,
20+ "base_file" : "sift1m_base .fvecs" ,
21+ "query_file" : "sift1m_query .fvecs" ,
2222 "gt_file" : "sift1m_groundtruth_top100_nb1000000.ivecs" ,
2323 "gt_half_file" : "sift1m_groundtruth_top100_nb500000.ivecs" ,
2424 },
6161 "gt_file" : "deep1m_groundtruth_top100_nb1000000.ivecs" ,
6262 "gt_half_file" : "deep1m_groundtruth_top100_nb500000.ivecs" ,
6363 },
64- "glove-100 " : {
64+ "glove" : {
6565 "name" : "GloVe-100" ,
6666 "url" : "https://static.visual-computing.com/paper/DEG/glove-100.tar.gz" ,
6767 "archive" : "glove-100.tar.gz" ,
7676 },
7777}
7878
79- # Aliases
80- DATASET_ALIASES = {
81- "glove" : "glove-100" ,
82- }
83-
8479def resolve_dataset_key (key : str ) -> str :
85- key = key .lower ()
86- return DATASET_ALIASES .get (key , key )
80+ return key .lower ()
8781
8882def get_default_cache_dir () -> Path :
8983 """Returns the default dataset cache directory (~/.cache/deg_datasets or DEG_CACHE_DIR)."""
@@ -178,41 +172,41 @@ def ensure_dataset(dataset_key: str, cache_dir: Path) -> Path:
178172
179173 meta = DATASET_METADATA [key ]
180174 archive_path = cache_dir / meta ["archive" ]
175+
176+ # 1. Check if direct folder (e.g., D:\Data\DEG\sift1m or D:\Data\DEG\sift) exists
181177 extracted_folder = cache_dir / meta ["folder" ]
178+ if not extracted_folder .is_dir ():
179+ # Check case-insensitive / fallback matches before triggering a download
180+ subdirs = [p for p in cache_dir .iterdir () if p .is_dir () and meta ["folder" ].lower () in p .name .lower ()]
181+ if subdirs :
182+ extracted_folder = subdirs [0 ]
182183
184+ # 2. If folder is still not found, check/download archive and extract
183185 if not extracted_folder .is_dir ():
184186 if not archive_path .is_file ():
185- download_file (meta ["url" ], archive_path )
187+ # Also check if archive exists inside a subfolder or cache_dir
188+ archive_matches = list (cache_dir .rglob (meta ["archive" ]))
189+ if archive_matches :
190+ archive_path = archive_matches [0 ]
191+ else :
192+ download_file (meta ["url" ], archive_path )
186193
187194 print (f"Extracting { archive_path } into { cache_dir } ..." )
188195 with tarfile .open (archive_path , "r:gz" ) as tar :
189196 tar .extractall (path = cache_dir )
190197 print ("Extraction complete." )
191-
192- if not extracted_folder .is_dir ():
193- subdirs = [p for p in cache_dir .iterdir () if p .is_dir () and meta ["folder" ].lower () in p .name .lower ()]
194- if subdirs :
195- extracted_folder = subdirs [0 ]
196- else :
197- extracted_folder = cache_dir
198+
199+ extracted_folder = cache_dir / meta ["folder" ]
200+ if not extracted_folder .is_dir ():
201+ subdirs = [p for p in cache_dir .iterdir () if p .is_dir () and meta ["folder" ].lower () in p .name .lower ()]
202+ if subdirs :
203+ extracted_folder = subdirs [0 ]
204+ else :
205+ extracted_folder = cache_dir
198206
199207 return extracted_folder
200208
201- def find_file (directory : Path , expected_name : str , pattern : str ) -> Path :
202- """Finds a file by exact name or matching pattern in directory tree."""
203- target = directory / expected_name
204- if target .is_file ():
205- return target
206-
207- matches = list (directory .rglob (expected_name ))
208- if matches :
209- return matches [0 ]
210209
211- matches = list (directory .rglob (f"*{ pattern } *" ))
212- if matches :
213- return matches [0 ]
214-
215- raise FileNotFoundError (f"Could not find file '{ expected_name } ' or pattern '{ pattern } ' in { directory } " )
216210
217211def compute_and_save_anns_gt (base_vecs : np .ndarray , query_vecs : np .ndarray , float_space : FloatSpace , k : int , out_path : Path ):
218212 """Computes ANNS ground truth against the full base dataset."""
@@ -275,8 +269,10 @@ def load_dataset_for_dynamic(
275269
276270 cleanup_legacy_gt (folder )
277271
278- base_path = find_file (folder , meta ["base_file" ], "base" )
279- query_path = find_file (folder , meta ["query_file" ], "query" )
272+ files_dir = folder / meta ["folder" ] if (folder / meta ["folder" ]).is_dir () else folder
273+
274+ base_path = files_dir / meta ["base_file" ]
275+ query_path = files_dir / meta ["query_file" ]
280276
281277 print (f"Loading base features from { base_path } ..." )
282278 base_vecs = repo .fvecs_read (base_path )
@@ -289,29 +285,19 @@ def load_dataset_for_dynamic(
289285 float_space = FloatSpace .create (dims , metric )
290286
291287 # Full ANNS Ground Truth
292- gt_file_name = meta ["gt_file" ]
293- gt_path = folder / gt_file_name
288+ gt_path = files_dir / meta ["gt_file" ]
294289 if not gt_path .is_file ():
295- sub_matches = list (folder .rglob (gt_file_name ))
296- if sub_matches :
297- gt_path = sub_matches [0 ]
298- else :
299- print (f"ANNS Full Ground Truth not found at { gt_path } ." )
300- compute_and_save_anns_gt (base_vecs , query_vecs , float_space , 100 , gt_path )
290+ print (f"ANNS Full Ground Truth not found at { gt_path } ." )
291+ compute_and_save_anns_gt (base_vecs , query_vecs , float_space , 100 , gt_path )
301292
302293 print (f"Loading full groundtruth indices from { gt_path } ..." )
303294 gt_vecs_full = repo .ivecs_read (gt_path )
304295
305296 # Half ANNS Ground Truth (against first base_count/2 vectors)
306- gt_half_file_name = meta ["gt_half_file" ]
307- gt_half_path = folder / gt_half_file_name
297+ gt_half_path = files_dir / meta ["gt_half_file" ]
308298 if not gt_half_path .is_file ():
309- sub_matches = list (folder .rglob (gt_half_file_name ))
310- if sub_matches :
311- gt_half_path = sub_matches [0 ]
312- else :
313- print (f"ANNS Half Ground Truth not found at { gt_half_path } ." )
314- compute_and_save_anns_gt_half (base_vecs , query_vecs , float_space , 100 , gt_half_path )
299+ print (f"ANNS Half Ground Truth not found at { gt_half_path } ." )
300+ compute_and_save_anns_gt_half (base_vecs , query_vecs , float_space , 100 , gt_half_path )
315301
316302 print (f"Loading half groundtruth indices from { gt_half_path } ..." )
317303 gt_vecs_half = repo .ivecs_read (gt_half_path )
0 commit comments