Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
8885274f
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看板
提交
8885274f
编写于
4月 22, 2020
作者:
W
WuHaobo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Decorate logger to display only once
上级
ff7ab33b
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
23 addition
and
50 deletion
+23
-50
ppcls/utils/__init__.py
ppcls/utils/__init__.py
+3
-2
ppcls/utils/logger.py
ppcls/utils/logger.py
+20
-48
未找到文件。
ppcls/utils/__init__.py
浏览文件 @
8885274f
...
...
@@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
.
import
model_zoo
from
.
import
misc
from
.
import
logger
from
.
import
misc
from
.
import
model_zoo
from
.save_load
import
init_model
,
save_model
from
.config
import
get_config
from
.misc
import
AverageMeter
ppcls/utils/logger.py
浏览文件 @
8885274f
...
...
@@ -11,63 +11,35 @@
# 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
()
DEBUG
=
logging
.
DEBUG
# 10
INFO
=
logging
.
INFO
# 20
WARN
=
logging
.
WARN
# 30
ERROR
=
logging
.
ERROR
# 40
import
logging
import
os
class
Logger
(
object
):
"""
Logger
"""
def
__init__
(
self
,
level
=
DEBUG
):
self
.
init
(
level
)
logging
.
basicConfig
(
level
=
logging
.
INFO
)
_logger
=
logging
.
getLogger
(
__name__
)
def
init
(
self
,
level
=
DEBUG
):
def
anti_fleet
(
log
):
"""
init
Because of the fucking Fleet, logs will print multi-times.
So we only display one of them and ignore the others.
"""
self
.
_logger
=
logging
.
getLogger
()
self
.
_logger
.
setLevel
(
level
)
def
info
(
self
,
fmt
,
*
args
):
"""info"""
self
.
_logger
.
info
(
fmt
,
*
args
)
def
warning
(
self
,
fmt
,
*
args
):
"""warning"""
self
.
_logger
.
warning
(
fmt
,
*
args
)
def
error
(
self
,
fmt
,
*
args
):
"""error"""
self
.
_logger
.
error
(
fmt
,
*
args
)
_logger
=
Logger
()
def
init
(
level
=
DEBUG
):
"""init for external"""
_logger
.
init
(
level
)
def
wrapper
(
fmt
,
*
args
):
if
int
(
os
.
getenv
(
"PADDLE_TRAINER_ID"
,
0
))
==
0
:
log
(
fmt
,
*
args
)
return
wrapper
@
anti_fleet
def
info
(
fmt
,
*
args
):
"""info"""
_logger
.
info
(
fmt
,
*
args
)
@
anti_fleet
def
warning
(
fmt
,
*
args
):
"""warn"""
_logger
.
warning
(
fmt
,
*
args
)
@
anti_fleet
def
error
(
fmt
,
*
args
):
"""error"""
_logger
.
error
(
fmt
,
*
args
)
...
...
@@ -86,16 +58,16 @@ def advertise():
"""
copyright
=
"PaddleClas is powered by PaddlePaddle !"
info
=
"For more info please go to the following website."
ad
=
"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
))
AD_LEN
=
6
+
len
(
max
([
copyright
,
ad
,
website
],
key
=
len
))
_logger
.
info
(
"
\n
{0}
\n
{1}
\n
{2}
\n
{3}
\n
{4}
\n
{5}
\n
{6}
\n
{7}
\n
"
.
format
(
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
.
center
(
AD_LEN
)),
"=={}=="
.
format
(
' '
*
AD_LEN
),
"=={}=="
.
format
(
website
.
center
(
AD_LEN
)),
"="
*
(
AD_LEN
+
4
)
,
))
"="
*
(
AD_LEN
+
4
)
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录