未验证 提交 349cbb62 编写于 作者: D dyning 提交者: GitHub

Merge pull request #55 from WuHaobo/master

supporting python3
...@@ -4,20 +4,25 @@ ...@@ -4,20 +4,25 @@
- id: yapf - id: yapf
files: \.py$ 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 - repo: https://github.com/pre-commit/pre-commit-hooks
sha: a11d9314b22d8f8c7556443875b731ef05965464 rev: v2.5.0
hooks: hooks:
- id: flake8 - id: flake8
args: ['--ignore=E265'] args: ['--ignore=E265']
- id: check-yaml - id: check-yaml
- id: check-merge-conflict - id: check-merge-conflict
- id: check-symlinks
- id: detect-private-key - id: detect-private-key
files: (?!.*paddle)^.*$ files: (?!.*paddle)^.*$
- id: end-of-file-fixer - id: end-of-file-fixer
files: \.(md|yml)$ files: \.(md|yml)$
- id: trailing-whitespace - id: trailing-whitespace
files: \.(md|yml)$ files: \.(md|yml)$
- id: check-case-conflict
- repo: https://github.com/Lucas-C/pre-commit-hooks - repo: https://github.com/Lucas-C/pre-commit-hooks
sha: v1.0.1 sha: v1.0.1
......
#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 six
import types import types
from difflib import SequenceMatcher from difflib import SequenceMatcher
...@@ -24,7 +25,7 @@ def get_architectures(): ...@@ -24,7 +25,7 @@ def get_architectures():
""" """
names = [] names = []
for k, v in architectures.__dict__.items(): 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) names.append(k)
return names return names
...@@ -35,9 +36,11 @@ def similar_architectures(name='', names=[], thresh=0.1, topk=10): ...@@ -35,9 +36,11 @@ def similar_architectures(name='', names=[], thresh=0.1, topk=10):
""" """
scores = [] scores = []
for idx, n in enumerate(names): for idx, n in enumerate(names):
if n[:2] == '__': continue if n.startswith('__'):
continue
score = SequenceMatcher(None, n.lower(), name.lower()).quick_ratio() 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) scores.sort(key=lambda x: x[1], reverse=True)
similar_names = [names[s[0]] for s in scores[:min(topk, len(scores))]] similar_names = [names[s[0]] for s in scores[:min(topk, len(scores))]]
return similar_names return similar_names
#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 os import os
import yaml import yaml
from ppcls.utils import check from ppcls.utils import check
...@@ -84,20 +84,7 @@ def print_config(config): ...@@ -84,20 +84,7 @@ def print_config(config):
Arguments: Arguments:
config: configs config: configs
""" """
copyright = "PaddleClas is powered by PaddlePaddle !" logger.advertise()
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), ))
print_dict(config) print_dict(config)
......
#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 os
import logging import logging
logging.basicConfig() logging.basicConfig()
import random
DEBUG = logging.DEBUG #10 DEBUG = logging.DEBUG # 10
INFO = logging.INFO #20 INFO = logging.INFO # 20
WARN = logging.WARN #30 WARN = logging.WARN # 30
ERROR = logging.ERROR #40 ERROR = logging.ERROR # 40
class Logger(object): class Logger(object):
...@@ -72,3 +69,33 @@ def warning(fmt, *args): ...@@ -72,3 +69,33 @@ def warning(fmt, *args):
def error(fmt, *args): def error(fmt, *args):
"""error""" """error"""
_logger.error(fmt, *args) _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), ))
...@@ -20,15 +20,14 @@ import argparse ...@@ -20,15 +20,14 @@ import argparse
import os import os
import paddle.fluid as fluid import paddle.fluid as fluid
from paddle.fluid.incubate.fleet.base import role_maker
import program from paddle.fluid.incubate.fleet.collective import fleet
from ppcls.data import Reader from ppcls.data import Reader
from ppcls.utils import logger
from ppcls.utils.config import get_config from ppcls.utils.config import get_config
from ppcls.utils.save_load import init_model, save_model from ppcls.utils.save_load import init_model, save_model
import program
from paddle.fluid.incubate.fleet.collective import fleet
from paddle.fluid.incubate.fleet.base import role_maker
def parse_args(): def parse_args():
...@@ -109,3 +108,4 @@ def main(args): ...@@ -109,3 +108,4 @@ def main(args):
if __name__ == '__main__': if __name__ == '__main__':
args = parse_args() args = parse_args()
main(args) main(args)
logger.advertise()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册