Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
349cbb62
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
349cbb62
编写于
4月 21, 2020
作者:
D
dyning
提交者:
GitHub
4月 21, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #55 from WuHaobo/master
supporting python3
上级
4c6e658a
d9abd887
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
82 addition
and
60 deletion
+82
-60
.pre-commit-config.yaml
.pre-commit-config.yaml
+7
-2
ppcls/modeling/utils.py
ppcls/modeling/utils.py
+15
-12
ppcls/utils/config.py
ppcls/utils/config.py
+12
-25
ppcls/utils/logger.py
ppcls/utils/logger.py
+43
-16
tools/train.py
tools/train.py
+5
-5
未找到文件。
.pre-commit-config.yaml
浏览文件 @
349cbb62
...
...
@@ -4,20 +4,25 @@
-
id
:
yapf
files
:
\.py$
-
repo
:
https://github.com/pre-commit/mirrors-autopep8
rev
:
v1.5
hooks
:
-
id
:
autopep8
-
repo
:
https://github.com/pre-commit/pre-commit-hooks
sha
:
a11d9314b22d8f8c7556443875b731ef05965464
rev
:
v2.5.0
hooks
:
-
id
:
flake8
args
:
[
'
--ignore=E265'
]
-
id
:
check-yaml
-
id
:
check-merge-conflict
-
id
:
check-symlinks
-
id
:
detect-private-key
files
:
(?!.*paddle)^.*$
-
id
:
end-of-file-fixer
files
:
\.(md|yml)$
-
id
:
trailing-whitespace
files
:
\.(md|yml)$
-
id
:
check-case-conflict
-
repo
:
https://github.com/Lucas-C/pre-commit-hooks
sha
:
v1.0.1
...
...
ppcls/modeling/utils.py
浏览文件 @
349cbb62
#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");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
Licensed under the Apache License, Version 2.0 (the "License");
#
you may not use this file except in compliance with the License.
#
You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#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.
#
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
six
import
types
from
difflib
import
SequenceMatcher
...
...
@@ -24,7 +25,7 @@ def get_architectures():
"""
names
=
[]
for
k
,
v
in
architectures
.
__dict__
.
items
():
if
isinstance
(
v
,
(
types
.
FunctionType
,
types
.
ClassType
)):
if
isinstance
(
v
,
(
types
.
FunctionType
,
six
.
class_types
)):
names
.
append
(
k
)
return
names
...
...
@@ -35,9 +36,11 @@ def similar_architectures(name='', names=[], thresh=0.1, topk=10):
"""
scores
=
[]
for
idx
,
n
in
enumerate
(
names
):
if
n
[:
2
]
==
'__'
:
continue
if
n
.
startswith
(
'__'
):
continue
score
=
SequenceMatcher
(
None
,
n
.
lower
(),
name
.
lower
()).
quick_ratio
()
if
score
>
thresh
:
scores
.
append
((
idx
,
score
))
if
score
>
thresh
:
scores
.
append
((
idx
,
score
))
scores
.
sort
(
key
=
lambda
x
:
x
[
1
],
reverse
=
True
)
similar_names
=
[
names
[
s
[
0
]]
for
s
in
scores
[:
min
(
topk
,
len
(
scores
))]]
return
similar_names
ppcls/utils/config.py
浏览文件 @
349cbb62
#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");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
Licensed under the Apache License, Version 2.0 (the "License");
#
you may not use this file except in compliance with the License.
#
You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#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.
# 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
os
import
yaml
from
ppcls.utils
import
check
...
...
@@ -84,20 +84,7 @@ def print_config(config):
Arguments:
config: configs
"""
copyright
=
"PaddleClas is powered by PaddlePaddle !"
info
=
"For more info please go to the following website."
website
=
"https://github.com/PaddlePaddle/PaddleClas"
AD_LEN
=
55
logger
.
info
(
"
\n
{0}
\n
{1}
\n
{2}
\n
{3}
\n
{4}
\n
{5}
\n
{6}
\n
{7}
\n
"
.
format
(
"="
*
(
AD_LEN
+
4
),
"=={}=="
.
format
(
copyright
.
center
(
AD_LEN
)),
"="
*
(
AD_LEN
+
4
),
"=={}=="
.
format
(
' '
*
AD_LEN
),
"=={}=="
.
format
(
info
.
center
(
AD_LEN
)),
"=={}=="
.
format
(
' '
*
AD_LEN
),
"=={}=="
.
format
(
website
.
center
(
AD_LEN
)),
"="
*
(
AD_LEN
+
4
),
))
logger
.
advertise
()
print_dict
(
config
)
...
...
ppcls/utils/logger.py
浏览文件 @
349cbb62
#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");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
Licensed under the Apache License, Version 2.0 (the "License");
#
you may not use this file except in compliance with the License.
#
You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#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
os
# 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
logging
logging
.
basicConfig
()
import
random
DEBUG
=
logging
.
DEBUG
#10
INFO
=
logging
.
INFO
#20
WARN
=
logging
.
WARN
#30
ERROR
=
logging
.
ERROR
#40
DEBUG
=
logging
.
DEBUG
#
10
INFO
=
logging
.
INFO
#
20
WARN
=
logging
.
WARN
#
30
ERROR
=
logging
.
ERROR
#
40
class
Logger
(
object
):
...
...
@@ -72,3 +69,33 @@ def warning(fmt, *args):
def
error
(
fmt
,
*
args
):
"""error"""
_logger
.
error
(
fmt
,
*
args
)
def
advertise
():
"""
Show the advertising message like the following:
===========================================================
== PaddleClas is powered by PaddlePaddle ! ==
===========================================================
== ==
== For more info please go to the following website. ==
== ==
== https://github.com/PaddlePaddle/PaddleClas ==
===========================================================
"""
copyright
=
"PaddleClas is powered by PaddlePaddle !"
info
=
"For more info please go to the following website."
website
=
"https://github.com/PaddlePaddle/PaddleClas"
AD_LEN
=
6
+
len
(
max
([
copyright
,
info
,
website
],
key
=
len
))
_logger
.
info
(
"
\n
{0}
\n
{1}
\n
{2}
\n
{3}
\n
{4}
\n
{5}
\n
{6}
\n
{7}
\n
"
.
format
(
"="
*
(
AD_LEN
+
4
),
"=={}=="
.
format
(
copyright
.
center
(
AD_LEN
)),
"="
*
(
AD_LEN
+
4
),
"=={}=="
.
format
(
' '
*
AD_LEN
),
"=={}=="
.
format
(
info
.
center
(
AD_LEN
)),
"=={}=="
.
format
(
' '
*
AD_LEN
),
"=={}=="
.
format
(
website
.
center
(
AD_LEN
)),
"="
*
(
AD_LEN
+
4
),
))
tools/train.py
浏览文件 @
349cbb62
...
...
@@ -20,15 +20,14 @@ import argparse
import
os
import
paddle.fluid
as
fluid
import
program
from
paddle.fluid.incubate.fleet.base
import
role_maker
from
paddle.fluid.incubate.fleet.collective
import
fleet
from
ppcls.data
import
Reader
from
ppcls.utils
import
logger
from
ppcls.utils.config
import
get_config
from
ppcls.utils.save_load
import
init_model
,
save_model
from
paddle.fluid.incubate.fleet.collective
import
fleet
from
paddle.fluid.incubate.fleet.base
import
role_maker
import
program
def
parse_args
():
...
...
@@ -109,3 +108,4 @@ def main(args):
if
__name__
==
'__main__'
:
args
=
parse_args
()
main
(
args
)
logger
.
advertise
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录