设置 GLOG_minloglevel=1 以防止从 Caffe 在 shell 中输出 [英] Setting GLOG_minloglevel=1 to prevent output in shell from Caffe

查看:34
本文介绍了设置 GLOG_minloglevel=1 以防止从 Caffe 在 shell 中输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Caffe,它在加载神经网络时会向 shell 打印大量输出.
我想抑制该输出,据说可以通过在运行 Python 脚本时设置 GLOG_minloglevel=1 来完成.我已经尝试使用以下代码来做到这一点,但我仍然从加载网络中获得所有输出.如何正确抑制输出?

I'm using Caffe, which is printing a lot of output to the shell when loading the neural net.
I'd like to suppress that output, which supposedly can be done by setting GLOG_minloglevel=1 when running the Python script. I've tried doing that using the following code, but I still get all the output from loading the net. How do I suppress the output correctly?

os.environ["GLOG_minloglevel"] = "1"
net = caffe.Net(model_file, pretrained, caffe.TEST)
os.environ["GLOG_minloglevel"] = "0"

推荐答案

要抑制输出级别,您需要将日志级别增加至至少 2

To supress the output level you need to increase the loglevel to at least 2

 os.environ['GLOG_minloglevel'] = '2' 

级别是

0 - 调试
1 - 信息(仍然有很多输出)
2 - 警告
3 - 错误

0 - debug
1 - info (still a LOT of outputs)
2 - warnings
3 - errors

更新:
由于这个标志全局caffe,它必须在之前设置为caffe包的导入(正如所指出的来自 jbum).一旦设置了标志并且 caffe 被导入,GLOG 工具的行为就无法改变.

Update:
Since this flag is global to caffe, it must be set prior to importing of caffe package (as pointed out by jbum). Once the flag is set and caffe is imported the behavior of the GLOG tool cannot be changed.

这篇关于设置 GLOG_minloglevel=1 以防止从 Caffe 在 shell 中输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆