I want to load the imagenet database 2012 version using the tensorflow 2.0 library. I followed the steps mentioned in Preparing the ImageNet dataset with TensorFlow.
My final code is as follows:
import tensorflow_datasets as tfds
import os
dataset_dir = '/home/imagenet' # directory where you downloaded the tar files to
temp_dir = '/home/temp' # a temporary directory where the data will be stored intermediately
download_config = tfds.download.DownloadConfig(
extract_dir=os.path.join(temp_dir, 'extracted'),
manual_dir=dataset_dir
)
builder = tfds.builder("imagenet2012")
builder.download_and_prepare(download_config=download_config)
My Imagenet tar files are located in dataset_dir: /home/imagenet.
Tar file names are : ILSVRC2012_img_train.tar and ILSVRC2012_img_val.tar
Whenever I execute the above code, I get the following error:
DownloadError: Failed to get url http://www.image-net.org/challenges/LSVRC/2012/nnoupb/ILSVRC2012_img_train.tar. HTTP code: 404.
I am not sure why is it trying to download the Imagenet files. The DownloadConfig contains the manual_dir parameter which points to the location of the downloaded Imagenet tar files.
Any help is appreciated.
In TensorFlow DataSetBuilder documentation, it is mentioned that the method
download_and_prepare"downloads and prepares the dataset for reading".Alternatively, you can use tfds.load() function to load the dataset that has already been downloaded.
According to the documentation, tfds.load() comprises of following processes:
as_datasetfunction.You can utilize tfds.load() as follows:
More details can be found on the tfds.load() documentation.