[Tensorflow] 使用 tf.keras.utils.get_file() 下载 MS-COCO 2014 数据集

 1 import argparse
 2 
 3 import tensorflow as tf
 4 tf.enable_eager_execution()
 5 
 6 
 7 def main(args):
 8     """Download the Microsoft COCO 2014 data set."""
 9     # Annotation zip
10     tf.keras.utils.get_file(fname=args.annotation_zip,
11                             origin=args.annotation_origin,
12                             cache_dir=args.cache_dir,
13                             cache_subdir=args.cache_subdir,
14                             extract=True)
15 
16     # Train image zip
17     tf.keras.utils.get_file(fname=args.train_zip,
18                             origin=args.train_origin,
19                             cache_dir=args.cache_dir,
20                             cache_subdir=args.cache_subdir,
21                             extract=True)
22 
23     # Val image zip
24     tf.keras.utils.get_file(fname=args.val_zip,
25                             origin=args.val_origin,
26                             cache_dir=args.cache_dir,
27                             cache_subdir=args.cache_subdir,
28                             extract=True)
29 
30     # Test image zip
31     tf.keras.utils.get_file(fname=args.test_zip,
32                             origin=args.test_origin,
33                             cache_dir=args.cache_dir,
34                             cache_subdir=args.cache_subdir,
35                             extract=True)
36 
37 
38 if __name__ == '__main__':
39     parser = argparse.ArgumentParser()
40     parser.add_argument('--cache_dir', type=str, default='F:/', help='location to store cached files')
41     parser.add_argument('--cache_subdir', type=str, default='COCO2014/', help='subdirectory under the cache dir')
42     parser.add_argument('--annotation_zip', type=str, default='annotation2014.zip', help='name of annotation zip')
43     parser.add_argument('--annotation_origin', type=str,
44                         default='http://images.cocodataset.org/annotations/annotations_trainval2014.zip',
45                         help='origin of annotation zip')
46     parser.add_argument('--train_zip', type=str, default='train2014.zip', help='name of train zip')
47     parser.add_argument('--train_origin', type=str,
48                         default='http://images.cocodataset.org/zips/train2014.zip',
49                         help='origin of train zip')
50     parser.add_argument('--val_zip', type=str, default='val2014.zip', help='name of val zip')
51     parser.add_argument('--val_origin', type=str,
52                         default='http://images.cocodataset.org/zips/val2014.zip',
53                         help='origin of val zip')
54     parser.add_argument('--test_zip', type=str, default='test2014.zip', help='name of test zip')
55     parser.add_argument('--test_origin', type=str,
56                         default='http://images.cocodataset.org/zips/test2014.zip',
57                         help='origin of test zip')
58 
59     args = parser.parse_args()
60     print(args)
61 
62     main(args)

 

posted on 2019-08-09 08:45  LZ_Jaja 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/zlian2016/p/11324982.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值