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

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

问题描述

我正在使用Caffe,它在加载神经网络时会在外壳上打印很多输出.
我想抑制该输出,据说可以通过在运行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

更新:
由于此标志是 global caffe的标记,因此必须将其设置为 prior ,以导入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天全站免登陆