@@ -44,22 +44,22 @@ class ImageNet(ImageFolder):
44
44
imgs (list): List of (image path, class_index) tuples
45
45
targets (list): The class_index value for each image in the dataset
46
46
"""
47
+
47
48
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 )
57
58
58
59
root = self .root = os .path .expanduser (root )
59
60
self .split = verify_str_arg (split , "split" , ("train" , "val" ))
60
61
61
- if download :
62
- self .download ()
62
+ self .extract_archives ()
63
63
wnid_to_classes = load_meta_file (self .root )[0 ]
64
64
65
65
super (ImageNet , self ).__init__ (self .split_folder , ** kwargs )
@@ -72,12 +72,15 @@ def __init__(self, root, split='train', download=None, **kwargs):
72
72
for idx , clss in enumerate (self .classes )
73
73
for cls in clss }
74
74
75
- def download (self ):
75
+ def extract_archives (self ):
76
76
def check_archive (archive_dict ):
77
- archive = os . path . join ( self . root , archive_dict ["file" ])
77
+ file = archive_dict ["file" ]
78
78
md5 = archive_dict ["md5" ]
79
+ archive = os .path .join (self .root , file )
79
80
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 ))
81
84
82
85
return archive
83
86
@@ -92,15 +95,6 @@ def check_archive(archive_dict):
92
95
parse_train_archive (archive )
93
96
elif self .split == 'val' :
94
97
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 ))
104
98
105
99
@property
106
100
def meta_file (self ):
0 commit comments