提交 2f0cf6e9 编写于 作者: W WuHaobo

Merge branch 'WuHaobo-fix_download'

ResNet18
ResNet34
ResNet50
ResNet101
ResNet152
ResNet50_vc
ResNet18_vd
ResNet34_vd
ResNet50_vd
ResNet50_vd_v2
ResNet101_vd
ResNet152_vd
ResNet200_vd
ResNet50_vd_ssld
MobileNetV3_large_x0_35
MobileNetV3_large_x0_5
MobileNetV3_large_x0_75
MobileNetV3_large_x1_0
MobileNetV3_large_x1_25
MobileNetV3_small_x0_35
MobileNetV3_small_x0_5
MobileNetV3_small_x0_75
MobileNetV3_small_x1_0
MobileNetV3_small_x1_25
MobileNetV3_large_x1_0_ssld
MobileNetV3_large_x1_0_ssld_int8
MobileNetV3_small_x1_0_ssld
MobileNetV2_x0_25
MobileNetV2_x0_5
MobileNetV2_x0_75
MobileNetV2
MobileNetV2_x1_5
MobileNetV2_x2_0
MobileNetV2_ssld
MobileNetV1_x0_25
MobileNetV1_x0_5
MobileNetV1_x0_75
MobileNetV1
MobileNetV1_ssld
ShuffleNetV2_x0_25
ShuffleNetV2_x0_33
ShuffleNetV2_x0_5
ShuffleNetV2
ShuffleNetV2_x1_5
ShuffleNetV2_x2_0
ShuffleNetV2_swish
ResNeXt50_32x4d
ResNeXt50_64x4d
ResNeXt101_32x4d
ResNeXt101_64x4d
ResNeXt152_32x4d
ResNeXt152_64x4d
ResNeXt50_vd_32x4d
ResNeXt50_vd_64x4d
ResNeXt101_vd_32x4d
ResNeXt101_vd_64x4d
ResNeXt152_vd_32x4d
ResNeXt152_vd_64x4d
SE_ResNet18_vd
SE_ResNet34_vd
SE_ResNet50_vd
SE_ResNeXt50_32x4d
SE_ResNeXt101_32x4d
SE_ResNeXt50_vd_32x4d
SENet154_vd
Res2Net50_26w_4s
Res2Net50_vd_26w_4s
Res2Net50_14w_8s
Res2Net101_vd_26w_4s
Res2Net200_vd_26w_4s
GoogLeNet
InceptionV4
Xception41
Xception41_deeplab
Xception65
Xception65_deeplab
Xception71
HRNet_W18_C
HRNet_W30_C
HRNet_W32_C
HRNet_W40_C
HRNet_W44_C
HRNet_W48_C
HRNet_W64_C
DPN68
DPN92
DPN98
DPN107
DPN131
DenseNet121
DenseNet161
DenseNet169
DenseNet201
DenseNet264
EfficientNetB0_small
EfficientNetB0
EfficientNetB1
EfficientNetB2
EfficientNetB3
EfficientNetB4
EfficientNetB5
EfficientNetB6
EfficientNetB7
ResNeXt101_32x8d_wsl
ResNeXt101_32x16d_wsl
ResNeXt101_32x32d_wsl
ResNeXt101_32x48d_wsl
Fix_ResNeXt101_32x48d_wsl
AlexNet
SqueezeNet1_0
SqueezeNet1_1
VGG11
VGG13
VGG16
VGG19
DarkNet53
ResNet50_ACNet_deploy
# 模型量化
模型量化是 [PaddleSlim](https://github.com/PaddlePaddle/PaddleSlim) 的特色功能之一,支持动态和静态两种量化训练方式,对权重全局量化和 Channel-Wise 量化,同时以兼容 Paddle Mobile 的格式保存模型。
模型量化是 [PaddleSlim](https://github.com/PaddlePaddle/PaddleSlim) 的特色功能之一,支持动态和静态两种量化训练方式,对权重全局量化和 Channel-Wise 量化,同时以兼容 Paddle-Lite 的格式保存模型。
[PaddleClas](https://github.com/PaddlePaddle/PaddleClas) 使用该量化工具,量化了78.9%的mobilenet_v3_large_x1_0的蒸馏模型, 量化后SD855上预测速度从19.308ms加速到14.395ms,存储大小从21M减小到10M, top1识别准确率75.9%。
具体的训练方法可以参见 [PaddleSlim 量化训练](https://paddlepaddle.github.io/PaddleSlim/quick_start/quant_aware_tutorial.html)
......@@ -17,4 +17,4 @@ from . import loss
from .architectures import *
from .loss import *
from .utils import similar_architectures
from .utils import *
......@@ -12,8 +12,8 @@
#See the License for the specific language governing permissions and
#limitations under the License.
import types
import architectures
import types
from difflib import SequenceMatcher
......@@ -28,12 +28,11 @@ def get_architectures():
return names
def similar_architectures(name='', thresh=0.1, topk=10):
def similar_architectures(name='', names=[], thresh=0.1, topk=10):
"""
inferred similar architectures
"""
scores = []
names = get_architectures()
for idx, n in enumerate(names):
if n[:2] == '__': continue
score = SequenceMatcher(None, n.lower(), name.lower()).quick_ratio()
......
......@@ -20,6 +20,7 @@ import sys
import paddle.fluid as fluid
from ppcls.modeling import get_architectures
from ppcls.modeling import similar_architectures
from ppcls.utils import logger
......@@ -60,7 +61,7 @@ def check_architecture(architecture):
"""
assert isinstance(architecture, str), \
("the type of architecture({}) should be str". format(architecture))
similar_names = similar_architectures(architecture)
similar_names = similar_architectures(architecture, get_architectures())
model_list = ', '.join(similar_names)
err = "{} is not exist! Maybe you want: [{}]" \
"".format(architecture, model_list)
......
......@@ -17,12 +17,13 @@ from __future__ import division
from __future__ import print_function
import os
import shutil
import requests
import tqdm
import shutil
import tarfile
import tqdm
import zipfile
from ppcls.modeling import similar_architectures
from ppcls.utils.check import check_architecture
from ppcls.utils import logger
......@@ -44,11 +45,7 @@ class ModelNameError(Exception):
""" ModelNameError
"""
def __init__(self, message='', architecture=''):
similar_names = similar_architectures(architecture)
model_list = ', '.join(similar_names)
message += '\n{} is not exist. \nMaybe you want: [{}]'.format(
architecture, model_list)
def __init__(self, message=''):
super(ModelNameError, self).__init__(message)
......@@ -171,8 +168,24 @@ def _decompress(fname):
os.remove(fname)
def _check_pretrained_name(architecture):
assert isinstance(architecture, str), \
("the type of architecture({}) should be str". format(architecture))
with open('./configs/pretrained.list') as flist:
pretrained = [line.strip() for line in flist]
similar_names = similar_architectures(architecture, pretrained)
model_list = ', '.join(similar_names)
err = "{} is not exist! Maybe you want: [{}]" \
"".format(architecture, model_list)
if architecture not in similar_names:
raise ModelNameError(err)
def get(architecture, path, decompress=True):
check_architecture(architecture)
"""
Get the pretrained model.
"""
_check_pretrained_name(architecture)
url = _get_url(architecture)
fname = _download(url, path)
if decompress: _decompress(fname)
......
......@@ -15,7 +15,6 @@
import sys
import argparse
sys.path.append("../")
from ppcls import model_zoo
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册