diff --git a/ppcls/utils/model_zoo.py b/ppcls/utils/model_zoo.py index 543b2558e89b3e31b41ce458a2216b5c42bc1bda..e2e012330be3a31556ed0f69ef1c7643796948b7 100644 --- a/ppcls/utils/model_zoo.py +++ b/ppcls/utils/model_zoo.py @@ -17,10 +17,10 @@ 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.utils.check import check_architecture @@ -40,18 +40,6 @@ class UrlError(Exception): 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): """ RetryError """ @@ -172,7 +160,18 @@ def _decompress(fname): 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) fname = _download(url, path) if decompress: _decompress(fname)