@@ -44,22 +44,22 @@ class ImageNet(ImageFolder):
4444 imgs (list): List of (image path, class_index) tuples
4545 targets (list): The class_index value for each image in the dataset
4646 """
47+
4748 def __init__ (self , root , split = 'train' , download = None , ** kwargs ):
48- if download is None :
49- download = False
50- else :
51- msg = ( "The use of the download flag is deprecated, since the public "
52- "download links were removed by the dataset authors. To use this "
53- "dataset, you need to download the archives externally. Afterwards "
54- "you can use the parse_{devkit|train|val}_archive() functions to "
55- "prepare them for usage ." )
56- warnings .warn (msg )
49+ if download is True :
50+ msg = ( "The dataset is no longer publicly accessible. You need to "
51+ "download the archives externally and place them in the root "
52+ "directory." )
53+ raise RuntimeError ( msg )
54+ elif download is False :
55+ msg = ( "The use of the download flag is deprecated, since the dataset "
56+ "is no longer publicly accessible ." )
57+ warnings .warn (msg , RuntimeWarning )
5758
5859 root = self .root = os .path .expanduser (root )
5960 self .split = verify_str_arg (split , "split" , ("train" , "val" ))
6061
61- if download :
62- self .download ()
62+ self .extract_archives ()
6363 wnid_to_classes = load_meta_file (self .root )[0 ]
6464
6565 super (ImageNet , self ).__init__ (self .split_folder , ** kwargs )
@@ -72,12 +72,15 @@ def __init__(self, root, split='train', download=None, **kwargs):
7272 for idx , clss in enumerate (self .classes )
7373 for cls in clss }
7474
75- def download (self ):
75+ def extract_archives (self ):
7676 def check_archive (archive_dict ):
77- archive = os . path . join ( self . root , archive_dict ["file" ])
77+ file = archive_dict ["file" ]
7878 md5 = archive_dict ["md5" ]
79+ archive = os .path .join (self .root , file )
7980 if not check_integrity (archive , md5 ):
80- self ._raise_download_error (archive )
81+ msg = ("The file {} is not present in the root directory. You need to "
82+ "download it externally and place it in {}." )
83+ raise RuntimeError (msg .format (file , self .root ))
8184
8285 return archive
8386
@@ -92,15 +95,6 @@ def check_archive(archive_dict):
9295 parse_train_archive (archive )
9396 elif self .split == 'val' :
9497 parse_val_archive (archive )
95- else :
96- msg = ("A folder '{}' already exist in the root directory. If you want to "
97- "re-extract the archive, delete the folder." )
98- warnings .warn (msg .format (self .split ), RuntimeWarning )
99-
100- def _raise_download_error (self , file ):
101- msg = ("The file {} is not present in the root directory and cannot be "
102- "downloaded anymore." )
103- raise RuntimeError (msg .format (file ))
10498
10599 @property
106100 def meta_file (self ):
0 commit comments