download.py 1.6 KB
Newer Older
W
WuHaobo 已提交
1 2
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
#
littletomatodonkey's avatar
littletomatodonkey 已提交
3 4 5
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
W
WuHaobo 已提交
6 7 8
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
littletomatodonkey's avatar
littletomatodonkey 已提交
9 10 11 12 13
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
W
WuHaobo 已提交
14

15 16 17 18 19 20
import argparse
import os
import sys
__dir__ = os.path.dirname(os.path.abspath(__file__))
sys.path.append(__dir__)
sys.path.append(os.path.abspath(os.path.join(__dir__, '..')))
W
WuHaobo 已提交
21

littletomatodonkey's avatar
littletomatodonkey 已提交
22 23
from ppcls import model_zoo

W
WuHaobo 已提交
24 25 26 27 28 29 30 31

def parse_args():
    def str2bool(v):
        return v.lower() in ("true", "t", "1")

    parser = argparse.ArgumentParser()
    parser.add_argument('-a', '--architecture', type=str, default='ResNet50')
    parser.add_argument('-p', '--path', type=str, default='./pretrained/')
32
    parser.add_argument('--postfix', type=str, default="tar")
W
WuHaobo 已提交
33
    parser.add_argument('-d', '--decompress', type=str2bool, default=True)
littletomatodonkey's avatar
littletomatodonkey 已提交
34
    parser.add_argument('-l', '--list', type=str2bool, default=False)
W
WuHaobo 已提交
35 36 37 38 39 40 41

    args = parser.parse_args()
    return args


def main():
    args = parse_args()
littletomatodonkey's avatar
littletomatodonkey 已提交
42 43 44
    if args.list:
        model_zoo.list_models()
    else:
45 46
        model_zoo.get(args.architecture, args.path, args.decompress,
                      args.postfix)
W
WuHaobo 已提交
47 48 49 50


if __name__ == '__main__':
    main()