download_model.py 5.2 KB
Newer Older
W
wuyefeilin 已提交
1 2
# coding: utf8
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve.
W
wuzewu 已提交
3
#
W
wuyefeilin 已提交
4
# Licensed under the Apache License, Version 2.0 (the "License");
W
wuzewu 已提交
5 6 7
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
W
wuyefeilin 已提交
8
#    http://www.apache.org/licenses/LICENSE-2.0
W
wuzewu 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#
# 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.

import sys
import os

LOCAL_PATH = os.path.dirname(os.path.abspath(__file__))
TEST_PATH = os.path.join(LOCAL_PATH, "..", "test")
sys.path.append(TEST_PATH)

from test_utils import download_file_and_uncompress

model_urls = {
W
wuzewu 已提交
26
    # ImageNet Pretrained
W
wuzewu 已提交
27 28
    "mobilenetv3_large_ssld_imagenet":
    "https://paddleseg.bj.bcebos.com/models/MobileNetV3_large_x1_0_ssld_pretrained.tar",
W
wuzewu 已提交
29
    "mobilenetv2-2-0_bn_imagenet":
W
wuzewu 已提交
30
    "https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_x2_0_pretrained.tar",
W
wuzewu 已提交
31
    "mobilenetv2-1-5_bn_imagenet":
W
wuzewu 已提交
32
    "https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_x1_5_pretrained.tar",
W
wuzewu 已提交
33
    "mobilenetv2-1-0_bn_imagenet":
W
wuzewu 已提交
34
    "https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_pretrained.tar",
W
wuzewu 已提交
35
    "mobilenetv2-0-5_bn_imagenet":
W
wuzewu 已提交
36
    "https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_x0_5_pretrained.tar",
W
wuzewu 已提交
37
    "mobilenetv2-0-25_bn_imagenet":
W
wuzewu 已提交
38
    "https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV2_x0_25_pretrained.tar",
W
wuzewu 已提交
39 40 41 42
    "mobilenetv3-1-0_large_bn_imagenet":
    "https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV3_large_x1_0_ssld_pretrained.tar",
    "mobilenetv3-1-0_small_bn_imagenet":
    "https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV3_small_x1_0_ssld_pretrained.tar",
W
wuzewu 已提交
43 44 45 46
    "xception41_imagenet":
    "https://paddleseg.bj.bcebos.com/models/Xception41_pretrained.tgz",
    "xception65_imagenet":
    "https://paddleseg.bj.bcebos.com/models/Xception65_pretrained.tgz",
C
chenguowei01 已提交
47 48
    "resnet50_vd_imagenet":
    "https://paddleseg.bj.bcebos.com/models/ResNet50_vd_ssld_pretrained.tgz",
W
wuyefeilin 已提交
49 50 51 52 53
    "hrnet_w18_bn_imagenet":
    "https://paddleseg.bj.bcebos.com/models/hrnet_w18_imagenet.tar",
    "hrnet_w30_bn_imagenet":
    "https://paddleseg.bj.bcebos.com/models/hrnet_w30_imagenet.tar",
    "hrnet_w32_bn_imagenet":
W
wuyefeilin 已提交
54
    "https://paddleseg.bj.bcebos.com/models/hrnet_w32_imagenet.tar",
W
wuyefeilin 已提交
55 56 57 58 59 60 61 62
    "hrnet_w40_bn_imagenet":
    "https://paddleseg.bj.bcebos.com/models/hrnet_w40_imagenet.tar",
    "hrnet_w44_bn_imagenet":
    "https://paddleseg.bj.bcebos.com/models/hrnet_w44_imagenet.tar",
    "hrnet_w48_bn_imagenet":
    "https://paddleseg.bj.bcebos.com/models/hrnet_w48_imagenet.tar",
    "hrnet_w64_bn_imagenet":
    "https://paddleseg.bj.bcebos.com/models/hrnet_w64_imagenet.tar",
W
wuzewu 已提交
63 64

    # COCO pretrained
W
wuzewu 已提交
65
    "deeplabv3p_mobilenetv2-1-0_bn_coco":
W
wuzewu 已提交
66
    "https://paddleseg.bj.bcebos.com/deeplab_mobilenet_x1_0_coco.tgz",
W
wuzewu 已提交
67 68
    "deeplabv3p_xception65_bn_coco":
    "https://paddleseg.bj.bcebos.com/models/xception65_coco.tgz",
W
wuzewu 已提交
69 70
    "unet_bn_coco":
    "https://paddleseg.bj.bcebos.com/models/unet_coco_v3.tgz",
P
pennypm 已提交
71 72 73 74
    "pspnet50_bn_coco":
    "https://paddleseg.bj.bcebos.com/models/pspnet50_coco.tgz",
    "pspnet101_bn_coco":
    "https://paddleseg.bj.bcebos.com/models/pspnet101_coco.tgz",
W
wuzewu 已提交
75 76

    # Cityscapes pretrained
W
wuzewu 已提交
77 78
    "deeplabv3p_mobilenetv3_large_cityscapes":
    "https://paddleseg.bj.bcebos.com/models/deeplabv3p_mobilenetv3_large_cityscapes.tar.gz",
W
wuzewu 已提交
79
    "deeplabv3p_mobilenetv2-1-0_bn_cityscapes":
W
wuzewu 已提交
80
    "https://paddleseg.bj.bcebos.com/models/mobilenet_cityscapes.tgz",
W
wuzewu 已提交
81 82 83 84
    "deeplabv3p_xception65_gn_cityscapes":
    "https://paddleseg.bj.bcebos.com/models/deeplabv3p_xception65_cityscapes.tgz",
    "deeplabv3p_xception65_bn_cityscapes":
    "https://paddleseg.bj.bcebos.com/models/xception65_bn_cityscapes.tgz",
C
chenguowei01 已提交
85 86
    "deeplabv3p_resnet50_vd_cityscapes":
    "https://paddleseg.bj.bcebos.com/models/deeplabv3p_resnet50_vd_cityscapes.tgz",
W
wuzewu 已提交
87 88
    "unet_bn_coco":
    "https://paddleseg.bj.bcebos.com/models/unet_coco_v3.tgz",
W
wuzewu 已提交
89
    "icnet_bn_cityscapes":
P
pennypm 已提交
90 91
    "https://paddleseg.bj.bcebos.com/models/icnet_cityscapes.tar.gz",
    "pspnet50_bn_cityscapes":
P
pennypm 已提交
92 93 94
    "https://paddleseg.bj.bcebos.com/models/pspnet50_cityscapes.tgz",
    "pspnet101_bn_cityscapes":
    "https://paddleseg.bj.bcebos.com/models/pspnet101_cityscapes.tgz",
W
wuyefeilin 已提交
95 96
    "hrnet_w18_bn_cityscapes":
    "https://paddleseg.bj.bcebos.com/models/hrnet_w18_bn_cityscapes.tgz",
L
LielinJiang 已提交
97 98
    "fast_scnn_cityscapes":
    "https://paddleseg.bj.bcebos.com/models/fast_scnn_cityscape.tar",
W
wuzewu 已提交
99 100
    "ocrnet_w18_bn_cityscapes":
    "https://paddleseg.bj.bcebos.com/models/ocrnet_w18_bn_cityscapes.tar.gz",
W
wuzewu 已提交
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
}

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("usage:\n  python download_model.py ${MODEL_NAME}")
        exit(1)

    model_name = sys.argv[1]
    if not model_name in model_urls.keys():
        print("Only support: \n  {}".format("\n  ".join(
            list(model_urls.keys()))))
        exit(1)

    url = model_urls[model_name]
    download_file_and_uncompress(
        url=url,
        savepath=LOCAL_PATH,
        extrapath=LOCAL_PATH,
        extraname=model_name)

    print("Pretrained Model download success!")