MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / download

Function download

tensorflow/lite/tutorials/dataset.py:67–83  ·  view source on GitHub ↗

Download (and unzip) a file from the MNIST dataset if not already done.

(directory, filename)

Source from the content-addressed store, hash-verified

65
66
67def download(directory, filename):
68 """Download (and unzip) a file from the MNIST dataset if not already done."""
69 filepath = os.path.join(directory, filename)
70 if tf.gfile.Exists(filepath):
71 return filepath
72 if not tf.gfile.Exists(directory):
73 tf.gfile.MakeDirs(directory)
74 # CVDF mirror of http://yann.lecun.com/exdb/mnist/
75 url = 'https://storage.googleapis.com/cvdf-datasets/mnist/' + filename + '.gz'
76 _, zipped_filepath = tempfile.mkstemp(suffix='.gz')
77 print('Downloading %s to %s' % (url, zipped_filepath))
78 urllib.request.urlretrieve(url, zipped_filepath)
79 with gzip.open(zipped_filepath, 'rb') as f_in, \
80 tf.gfile.Open(filepath, 'wb') as f_out:
81 shutil.copyfileobj(f_in, f_out)
82 os.remove(zipped_filepath)
83 return filepath
84
85
86def dataset(directory, images_file, labels_file):

Callers 1

datasetFunction · 0.70

Calls 4

joinMethod · 0.45
ExistsMethod · 0.45
OpenMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected