提交 a39ae69c 编写于 作者: W WuHaobo

polish download pretrain model and add comments to the func

上级 fef101dd
...@@ -17,10 +17,10 @@ from __future__ import division ...@@ -17,10 +17,10 @@ from __future__ import division
from __future__ import print_function from __future__ import print_function
import os import os
import shutil
import requests import requests
import tqdm import shutil
import tarfile import tarfile
import tqdm
import zipfile import zipfile
from ppcls.utils.check import check_architecture from ppcls.utils.check import check_architecture
...@@ -40,18 +40,6 @@ class UrlError(Exception): ...@@ -40,18 +40,6 @@ class UrlError(Exception):
super(UrlError, self).__init__(message) super(UrlError, self).__init__(message)
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)
super(ModelNameError, self).__init__(message)
class RetryError(Exception): class RetryError(Exception):
""" RetryError """ RetryError
""" """
...@@ -172,7 +160,18 @@ def _decompress(fname): ...@@ -172,7 +160,18 @@ def _decompress(fname):
def get(architecture, path, decompress=True): def get(architecture, path, decompress=True):
check_architecture(architecture) """
Get the pretrained model.
Args:
architecture: the name of which architecture to get.
If the name is not exist, will raises UrlError with error code 404.
path: which dir to save the pretrained model.
decompress: decompress the download or not.
Raises:
RetryError or UrlError if download failed
"""
url = _get_url(architecture) url = _get_url(architecture)
fname = _download(url, path) fname = _download(url, path)
if decompress: _decompress(fname) if decompress: _decompress(fname)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册