MCPcopy Create free account
hub / github.com/TensorPy/TensorPy / maybe_download_and_extract

Function maybe_download_and_extract

tensorpy/download_imagenet.py:22–40  ·  view source on GitHub ↗

Download and extract model tar file.

()

Source from the content-addressed store, hash-verified

20
21
22def maybe_download_and_extract():
23 """Download and extract model tar file."""
24 dest_directory = FLAGS.model_dir
25 if not os.path.exists(dest_directory):
26 os.makedirs(dest_directory)
27 filename = DATA_URL.split('/')[-1]
28 filepath = os.path.join(dest_directory, filename)
29 print("ImageNet Inception DB filepath: %s" % filepath)
30 if not os.path.exists(filepath):
31 def _progress(count, block_size, total_size):
32 sys.stdout.write('\r>> Downloading %s %.1f%%' % (
33 filename,
34 float(count * block_size) / float(total_size) * 100.0))
35 sys.stdout.flush()
36 filepath, _ = urllib.request.urlretrieve(DATA_URL, filepath, _progress)
37 print()
38 statinfo = os.stat(filepath)
39 print('Succesfully downloaded', filename, statinfo.st_size, 'bytes.')
40 tarfile.open(filepath, 'r:gz').extractall(dest_directory)
41
42
43def main(_):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected