未验证 提交 80087a1d 编写于 作者: X Xiaoyao Xi 提交者: GitHub

Merge pull request #36 from wangxiao1021/downloader

fix bugs
......@@ -18,12 +18,15 @@ import sys
import argparse
# create parser
parser = argparse.ArgumentParser(description = 'Download pretrain models for initializing params of backbones. ')
parser.add_argument("-l", "--list", action = 'store_true', help = 'show the list of pretrain models')
parser.add_argument("-d", "--download", action = 'store', help = 'download pretrain models')
parser = argparse.ArgumentParser(prog='download_models.py', usage='%(prog)s < -l | -d <model_name> > [-h] ',description = 'Download pretrain models for initializing params of backbones. ')
parser1= parser.add_argument_group("pretrain models")
parser1.add_argument('-l','--list', action = 'store_true', help = 'show the list of pretrain models', default = False)
parser1.add_argument('-d','--download', action = 'store', help = 'download pretrain models')
args = parser.parse_args()
if(args.list):
palm.downloader.ls('pretrain')
if(args.download):
elif(args.download):
palm.downloader.download('pretrain', args.download)
else:
print (parser.parse_args(['-h']))
......@@ -145,24 +145,26 @@ def download(item, scope='all', path='.'):
def _ls(item, scope, l = 10):
if scope != 'all':
assert scope in _items[item], '{} is not found. Support scopes: {}'.format(scope, list(_items[item].keys()))
print ('{} ==> {}'.format(item, scope))
print ('{}'.format(scope))
else:
for s in _items[item].keys():
if s == 'utils':
continue
print ('{} ==> {}'.format(item.ljust(l), s))
print ('{}'.format(s))
def ls(item='all', scope='all'):
if scope == 'utils':
return
print ('Download list:')
if item != 'all':
assert item in _items, '{} is not found. Support scopes: {}'.format(item, list(_items.keys()))
print ('Download list of \'{}\':'.format(item))
_ls(item, scope)
else:
l = max(map(len, _items.keys()))
print ('Download list: ')
for i in _items.keys():
print ('\'{}\':'.format(i))
_ls(i, scope, l)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册