File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
2
import random
3
3
import tarfile
4
- from urllib .request import urlopen , urlretrieve
4
+ from urllib .request import build_opener , install_opener , urlopen , urlretrieve
5
+ import traceback
5
6
6
7
import h5py
7
8
import numpy
8
9
from typing import Any , Callable , Dict , Tuple
9
10
11
+ # Needed for Cloudflare's firewall
12
+ opener = build_opener ()
13
+ opener .addheaders = [('User-agent' , 'Mozilla/5.0' )]
14
+ install_opener (opener )
15
+
16
+
10
17
def download (source_url : str , destination_path : str ) -> None :
11
18
"""
12
19
Downloads a file from the provided source URL to the specified destination path
@@ -54,6 +61,7 @@ def get_dataset(dataset_name: str) -> Tuple[h5py.File, int]:
54
61
dataset_url = f"https://ann-benchmarks.com/{ dataset_name } .hdf5"
55
62
download (dataset_url , hdf5_filename )
56
63
except :
64
+ traceback .print_exc ()
57
65
print (f"Cannot download { dataset_url } " )
58
66
if dataset_name in DATASETS :
59
67
print ("Creating dataset locally" )
You can’t perform that action at this time.
0 commit comments