|
| 1 | +# Copyright 2016 The TensorFlow Authors. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# ============================================================================== |
| 15 | + |
| 16 | +"""Creates a text file with URLs to download FSNS dataset using aria2c. |
| 17 | +
|
| 18 | +The FSNS dataset has 640 files and takes 158Gb of the disk space. So it is |
| 19 | +highly recommended to use some kind of a download manager to download it. |
| 20 | +
|
| 21 | +Aria2c is a powerful download manager which can download multiple files in |
| 22 | +parallel, re-try if encounter an error and continue previously unfinished |
| 23 | +downloads. |
| 24 | +""" |
| 25 | + |
| 26 | +import os |
| 27 | + |
| 28 | +_FSNS_BASE_URL = 'http://download.tensorflow.org/data/fsns-20160927/' |
| 29 | +_SHARDS = {'test': 64, 'train': 512, 'validation':64} |
| 30 | +_OUTPUT_FILE = "fsns_urls.txt" |
| 31 | +_OUTPUT_DIR = "data/fsns" |
| 32 | + |
| 33 | +def fsns_paths(): |
| 34 | + paths = ['charset_size=134.txt'] |
| 35 | + for name, shards in _SHARDS.items(): |
| 36 | + for i in range(shards): |
| 37 | + paths.append('%s/%s-%05d-of-%05d' % (name, name, i, shards)) |
| 38 | + return paths |
| 39 | + |
| 40 | + |
| 41 | +if __name__ == "__main__": |
| 42 | + with open(_OUTPUT_FILE, "w") as f: |
| 43 | + for path in fsns_paths(): |
| 44 | + url = _FSNS_BASE_URL + path |
| 45 | + dst_path = os.path.join(_OUTPUT_DIR, path) |
| 46 | + f.write("%s\n out=%s\n" % (url, dst_path)) |
| 47 | + print("To download FSNS dataset execute:") |
| 48 | + print("aria2c -c -j 20 -i %s" % _OUTPUT_FILE) |
| 49 | + print("The downloaded FSNS dataset will be stored under %s" % _OUTPUT_DIR) |
0 commit comments