Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
a6b0f49c
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
1 年多 前同步成功
通知
115
Star
4999
Fork
1114
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
6
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleClas
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
6
合并请求
6
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a6b0f49c
编写于
5月 04, 2020
作者:
littletomatodonkey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add pretrain list show
上级
eef1e879
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
15 deletion
+31
-15
ppcls/utils/model_zoo.py
ppcls/utils/model_zoo.py
+18
-5
ppcls/utils/pretrained.list
ppcls/utils/pretrained.list
+0
-0
tools/download.py
tools/download.py
+13
-10
未找到文件。
ppcls/utils/model_zoo.py
浏览文件 @
a6b0f49c
...
@@ -24,7 +24,6 @@ import tqdm
...
@@ -24,7 +24,6 @@ import tqdm
import
zipfile
import
zipfile
from
ppcls.modeling
import
similar_architectures
from
ppcls.modeling
import
similar_architectures
from
ppcls.utils.check
import
check_architecture
from
ppcls.utils
import
logger
from
ppcls.utils
import
logger
__all__
=
[
'get'
]
__all__
=
[
'get'
]
...
@@ -168,11 +167,16 @@ def _decompress(fname):
...
@@ -168,11 +167,16 @@ def _decompress(fname):
os
.
remove
(
fname
)
os
.
remove
(
fname
)
def
_get_pretrained
():
with
open
(
'./ppcls/utils/pretrained.list'
)
as
flist
:
pretrained
=
[
line
.
strip
()
for
line
in
flist
]
return
pretrained
def
_check_pretrained_name
(
architecture
):
def
_check_pretrained_name
(
architecture
):
assert
isinstance
(
architecture
,
str
),
\
assert
isinstance
(
architecture
,
str
),
\
(
"the type of architecture({}) should be str"
.
format
(
architecture
))
(
"the type of architecture({}) should be str"
.
format
(
architecture
))
with
open
(
'./configs/pretrained.list'
)
as
flist
:
pretrained
=
_get_pretrained
()
pretrained
=
[
line
.
strip
()
for
line
in
flist
]
similar_names
=
similar_architectures
(
architecture
,
pretrained
)
similar_names
=
similar_architectures
(
architecture
,
pretrained
)
model_list
=
', '
.
join
(
similar_names
)
model_list
=
', '
.
join
(
similar_names
)
err
=
"{} is not exist! Maybe you want: [{}]"
\
err
=
"{} is not exist! Maybe you want: [{}]"
\
...
@@ -181,6 +185,14 @@ def _check_pretrained_name(architecture):
...
@@ -181,6 +185,14 @@ def _check_pretrained_name(architecture):
raise
ModelNameError
(
err
)
raise
ModelNameError
(
err
)
def
list_models
():
pretrained
=
_get_pretrained
()
msg
=
"All avialable pretrained models are as follows: {}"
.
format
(
pretrained
)
logger
.
info
(
msg
)
return
def
get
(
architecture
,
path
,
decompress
=
True
):
def
get
(
architecture
,
path
,
decompress
=
True
):
"""
"""
Get the pretrained model.
Get the pretrained model.
...
@@ -188,5 +200,6 @@ def get(architecture, path, decompress=True):
...
@@ -188,5 +200,6 @@ def get(architecture, path, decompress=True):
_check_pretrained_name
(
architecture
)
_check_pretrained_name
(
architecture
)
url
=
_get_url
(
architecture
)
url
=
_get_url
(
architecture
)
fname
=
_download
(
url
,
path
)
fname
=
_download
(
url
,
path
)
if
decompress
:
_decompress
(
fname
)
if
decompress
:
_decompress
(
fname
)
logger
.
info
(
"download {} finished "
.
format
(
fname
))
logger
.
info
(
"download {} finished "
.
format
(
fname
))
config
s/pretrained.list
→
ppcls/util
s/pretrained.list
浏览文件 @
a6b0f49c
文件已移动
tools/download.py
浏览文件 @
a6b0f49c
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
#
#
#Licensed under the Apache License, Version 2.0 (the "License");
#
Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#
you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
#
#Unless required by applicable law or agreed to in writing, software
#
Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#
distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#
See the License for the specific language governing permissions and
#limitations under the License.
#
limitations under the License.
import
sys
import
argparse
import
argparse
from
ppcls
import
model_zoo
from
ppcls
import
model_zoo
...
@@ -26,6 +25,7 @@ def parse_args():
...
@@ -26,6 +25,7 @@ def parse_args():
parser
.
add_argument
(
'-a'
,
'--architecture'
,
type
=
str
,
default
=
'ResNet50'
)
parser
.
add_argument
(
'-a'
,
'--architecture'
,
type
=
str
,
default
=
'ResNet50'
)
parser
.
add_argument
(
'-p'
,
'--path'
,
type
=
str
,
default
=
'./pretrained/'
)
parser
.
add_argument
(
'-p'
,
'--path'
,
type
=
str
,
default
=
'./pretrained/'
)
parser
.
add_argument
(
'-d'
,
'--decompress'
,
type
=
str2bool
,
default
=
True
)
parser
.
add_argument
(
'-d'
,
'--decompress'
,
type
=
str2bool
,
default
=
True
)
parser
.
add_argument
(
'-l'
,
'--list'
,
type
=
str2bool
,
default
=
False
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
return
args
return
args
...
@@ -33,7 +33,10 @@ def parse_args():
...
@@ -33,7 +33,10 @@ def parse_args():
def
main
():
def
main
():
args
=
parse_args
()
args
=
parse_args
()
model_zoo
.
get
(
args
.
architecture
,
args
.
path
,
args
.
decompress
)
if
args
.
list
:
model_zoo
.
list_models
()
else
:
model_zoo
.
get
(
args
.
architecture
,
args
.
path
,
args
.
decompress
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录