@@ -473,7 +473,7 @@ def unzip(zip_file_path, extraction_path):
473473
474474def download_and_extract_nmnist_dataset (save_path = "./" ):
475475 nmnist_dataset = {
476- "url" : "https://prod-dcd-datasets-cache-zipfiles.s3.eu-west-1.amazonaws. com/468j46mzdv-1. zip" ,
476+ "url" : "https://data.mendeley. com/public-api/ zip/468j46mzdv/download/1 " ,
477477 "directory" : "468j46mzdv-1" ,
478478 "zip" : "dataset.zip" ,
479479 }
@@ -488,9 +488,13 @@ def download_and_extract_nmnist_dataset(save_path="./"):
488488 if not (os .path .exists (path ) and os .path .exists (train_path ) and os .path .exists (test_path )):
489489 if not os .path .exists (downloaded_zip_path ):
490490 print ("\n Downloading the N-MNIST dataset." )
491- response = requests .get (nmnist_dataset ["url" ], timeout = 10 )
492- with open (downloaded_zip_path , "wb" ) as file :
493- file .write (response .content )
491+ chunk_size = 1024 * 1024 # 1 MiB
492+ with requests .get (nmnist_dataset ["url" ], stream = True , timeout = 60 ) as r :
493+ r .raise_for_status ()
494+ with open (downloaded_zip_path , "wb" , buffering = chunk_size ) as f :
495+ for chunk in r .iter_content (chunk_size = chunk_size ):
496+ if chunk :
497+ f .write (chunk )
494498
495499 unzip (downloaded_zip_path , save_path )
496500 unzip (f"{ train_path } .zip" , path )
0 commit comments